Skip to content

CI (Lint + Molecule) #589

CI (Lint + Molecule)

CI (Lint + Molecule) #589

Workflow file for this run

---
name: CI (Lint + Molecule)
"on":
workflow_dispatch:
inputs:
lint:
description: "Lint"
required: true
default: true
type: boolean
distro:
description: "Select a Distribution to run"
required: false
type: choice
default: "ubuntu2204"
options:
- ubuntu1804
- ubuntu2004
- ubuntu2204
- debian10
- debian11
- rockylinux8
- rockylinux9
- fedora35
- fedora36
- fedora37
- fedora38
- ALL
ansible_version:
description: "Select Ansible Versions to run"
required: false
type: choice
default: "ansible-6"
options:
- ansible-4,ansible-5,ansible-6,ansible-7,ansible-8
- ansible-4,ansible-5,ansible-6
- ansible-7,ansible-8
- ansible-4
- ansible-5
- ansible-6
- ansible-7
- ansible-8
pull_request:
branches-ignore:
- renovate/**
push:
branches:
- master
- renovate/**
paths:
- ".github/workflows/ci.yml"
- "defaults/*"
- "handlers/*"
- "meta/**"
- "molecule/**"
- "tasks/*"
- "vars/*"
- ".ansible-lint"
- ".gitattributes"
- ".yamllint"
- "pyproject.toml"
- "requirements.yml"
- "tox.ini"
schedule:
# At 05:00 on Sunday.
- cron: "0 5 * * 0"
permissions: read-all
jobs:
lint:
name: Lint
if: ${{ github.event.inputs.lint != 'false' }}
runs-on: ubuntu-latest
steps:
- name: check out the codebase
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: set up python 3
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4
with:
python-version: "3.9"
- name: Install yamllint package.
run: pip3 install "yamllint==1.*"
- name: Lint YAML (GitHub Annotations)
run: |
cat <<HEREDOC
Wondering about why there are no file names?
This command outputs information parsed by GitHub
to be displayed in 'Annotations' tab.
HEREDOC
yamllint . -f github
- name: Lint YAML (Standard Output)
if: always()
run: yamllint . -f standard
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
# half length of matrix's distro list:
max-parallel: 6
matrix:
distro:
# ensure diversity in first half:
- ubuntu1804
- ubuntu2204
- debian11
- rockylinux9
- fedora35
- fedora38
# other:
- ubuntu2004
- debian10
- rockylinux8
- fedora36
- fedora37
env:
WORKFLOW_DISPATCH_IF: >-
${{github.event_name == 'workflow_dispatch' &&
(github.event.inputs.distro == 'ALL' ||
contains(matrix.distro, github.event.inputs.distro)) }}
steps:
- name: if this step is run, this is a real ci run
run: >
cat << EOF
If this step is NOT skipped, this workflow run was manually dispatched
and the chosen distro does not match the current matrix distro.
This is a hack because GitHub CI does not allow for a state other than "failed"
as per https://github.com/actions/runner/issues/662
EOF
if: github.event_name != 'workflow_dispatch' || env.WORKFLOW_DISPATCH_IF == 'true'
- name: check out the codebase
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: set up python 3
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4
with:
python-version: "3.9"
- name: setup/activate pre-commit cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
path: ~/.cache/pre-commit
key: ${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Install test dependencies.
run: pip3 install -r requirements-dev.txt
- name: Run Molecule tests (normal).
run: tox
env:
TOX_SKIP_ENV: pre-commit
TOX_PARALLEL_NO_SPINNER: 1
MOLECULE_DISTRO: ${{ matrix.distro }}
if: github.event_name != 'workflow_dispatch'
- name: Run Molecule tests (debug).
run: tox
env:
TOXENV: py3-${{ github.event.inputs.ansible_version }}
TOX_SKIP_ENV: pre-commit
TOX_PARALLEL_NO_SPINNER: 1
MOLECULE_DESTROY: never
MOLECULE_DISTRO: ${{ matrix.distro }}
if: env.WORKFLOW_DISPATCH_IF == 'true'
- name: Upload output of /molecule/resources/debug.yml as CI Artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: debug-${{ matrix.distro }}.yml
path: |
/var/tmp/vars.yml
/var/tmp/environment.yml
- name: setup tmate session if previous step failed and if this is a manual run
if: failure() && env.WORKFLOW_DISPATCH_IF == 'true'
uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # v3
timeout-minutes: 30