CI #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CI | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
schedule: | |
- cron: '30 1 * * 3' | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-22.04 | |
outputs: | |
container_supported: ${{ steps.get_min_ansible_container_version.outputs.result }} | |
steps: | |
- name: Check out the codebase | |
uses: actions/checkout@v4 | |
- name: Pull Lint image | |
run: docker pull -q ghcr.io/rheinwerk/molecule:lint | |
- name: Ansible Linting | |
run: docker run --rm -v ${GITHUB_WORKSPACE}:/git -w /git ghcr.io/rheinwerk/molecule:lint ansible-lint --force-color -p --offline /git | |
- name: Yaml Linting | |
run: docker run --rm -v ${GITHUB_WORKSPACE}:/git -w /git ghcr.io/rheinwerk/molecule:lint yamllint -f colored /git | |
- name: Get min_ansible_container_version from meta/main.yml | |
id: get_min_ansible_container_version | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq ".galaxy_info.min_ansible_container_version" ${GITHUB_WORKSPACE}/meta/main.yml | |
molecule: | |
name: Molecule for Ansible ${{ matrix.ansible_scenario }} / ${{ matrix.distro }} / Python ${{ matrix.python_version }} | |
runs-on: ubuntu-22.04 | |
continue-on-error: ${{ matrix.experimental }} | |
needs: lint | |
if: needs.lint.outputs.container_supported != 'X' | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- distro: ubuntu-20.04 | |
ansible_scenario: ansible_current | |
test_type: unit | |
python_version: '3.8' | |
experimental: false | |
- distro: ubuntu-20.04 | |
ansible_scenario: ansible_next | |
test_type: unit | |
python_version: '3.8' | |
experimental: true | |
- distro: ubuntu-22.04 | |
ansible_scenario: ansible_latest | |
test_type: unit | |
python_version: '3.10' | |
experimental: true | |
steps: | |
- uses: Rheinwerk/molecule@v3 | |
with: | |
distro: ${{ matrix.distro }} | |
ansible_scenario: ${{ matrix.ansible_scenario }} | |
test_type: ${{ matrix.test_type }} | |
python_version: ${{ matrix.python_version }} | |
release: | |
name: Release | |
runs-on: ubuntu-22.04 | |
needs: molecule | |
# https://github.com/actions/runner/issues/491#issuecomment-850884422 | |
if: | | |
always() && | |
startsWith(github.event.ref, 'refs/tags/v') && | |
(needs.molecule.result == 'success' || needs.molecule.result == 'skipped') | |
steps: | |
# Ansible ist bereits im Ubuntu Image enthalten, wir brauchen keine spezielle Version für den Galaxy Import: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md | |
# AnsibleLint config wird anscheinend ignoriert: https://github.com/ansible/galaxy/issues/2868 | |
- name: Trigger import of Role at Ansible Galaxy | |
run: | | |
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo $GITHUB_REPOSITORY | cut -d/ -f1) $(echo $GITHUB_REPOSITORY | cut -d/ -f2) |