2023-01-11 19:55:24 +00:00
|
|
|
---
|
|
|
|
name: Ansible CI
|
2023-02-17 18:53:28 +00:00
|
|
|
on:
|
2023-03-01 17:49:05 +00:00
|
|
|
pull_request:
|
2023-02-17 18:53:28 +00:00
|
|
|
types:
|
2023-03-01 17:49:05 +00:00
|
|
|
- opened
|
|
|
|
- edited
|
|
|
|
- reopened
|
2023-03-06 21:57:59 +00:00
|
|
|
- synchronize
|
2023-05-15 19:04:11 +00:00
|
|
|
- labeled
|
2023-02-17 18:53:28 +00:00
|
|
|
workflow_dispatch:
|
2023-01-11 19:55:24 +00:00
|
|
|
|
2023-05-21 02:49:18 +00:00
|
|
|
concurrency:
|
|
|
|
group: ansible-${{ github.event.pull_request.number || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-01-11 19:55:24 +00:00
|
|
|
env:
|
|
|
|
ANSIBLE_FORCE_COLOR: true
|
2023-02-17 18:54:03 +00:00
|
|
|
ANSIBLE_GALAXY_SERVER_GALAXY_URL: "https://galaxy.ansible.com"
|
|
|
|
ANSIBLE_GALAXY_SERVER_GALAXY_TIMEOUT: 120
|
|
|
|
ANSIBLE_GALAXY_SERVER_LIST: "galaxy"
|
2023-01-11 19:55:24 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
ansible-lint:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-04-25 14:24:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-01-13 01:36:41 +00:00
|
|
|
|
2023-01-11 19:55:24 +00:00
|
|
|
- name: Lint collection
|
2023-08-16 14:48:10 +00:00
|
|
|
uses: ansible/ansible-lint@main
|
2023-01-11 19:55:24 +00:00
|
|
|
|
2023-08-16 15:49:02 +00:00
|
|
|
arguments-spec-lint:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: quay.io/prometheus/golang-builder:base
|
|
|
|
steps:
|
2024-04-25 14:24:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-16 15:49:02 +00:00
|
|
|
- name: Lint arguments spec
|
|
|
|
run: ./.github/scripts/lint_arguments_spec.sh
|
|
|
|
|
2024-09-30 15:35:39 +00:00
|
|
|
check-unused-variables:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Run action
|
2024-10-20 16:44:59 +00:00
|
|
|
uses: hoo29/little-timmy@v2-action
|
2024-09-30 15:35:39 +00:00
|
|
|
|
2023-01-13 01:36:41 +00:00
|
|
|
discover-ansible-versions:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
versions: ${{ steps.supported-ansible-versions.outputs.result }}
|
|
|
|
steps:
|
2024-04-25 14:24:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-01-13 01:36:41 +00:00
|
|
|
|
|
|
|
- name: Get Ansible versions that the collection supports
|
|
|
|
id: supported-ansible-versions
|
2023-05-26 21:34:26 +00:00
|
|
|
run: |
|
2023-12-12 13:07:10 +00:00
|
|
|
echo "result=$(python ./.github/scripts/collection_version_parser.py)" >> $GITHUB_OUTPUT
|
2023-01-13 01:36:41 +00:00
|
|
|
|
2023-01-11 19:55:24 +00:00
|
|
|
ansible-test-sanity:
|
|
|
|
uses: ./.github/workflows/ansible-test-sanity.yml
|
2023-01-13 01:36:41 +00:00
|
|
|
needs:
|
|
|
|
- discover-ansible-versions
|
2023-01-11 19:55:24 +00:00
|
|
|
with:
|
2023-01-13 01:36:41 +00:00
|
|
|
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
2023-01-11 19:55:24 +00:00
|
|
|
|
|
|
|
discover-ansible-tests:
|
|
|
|
runs-on: ubuntu-latest
|
2023-05-21 03:00:17 +00:00
|
|
|
needs:
|
|
|
|
- ansible-lint
|
2023-01-11 19:55:24 +00:00
|
|
|
outputs:
|
2023-01-13 01:38:53 +00:00
|
|
|
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
2024-07-02 02:32:29 +00:00
|
|
|
ansible-roles: ${{ steps.set-ansible-roles.outputs.roles }}
|
2023-01-11 19:55:24 +00:00
|
|
|
steps:
|
2024-04-25 14:24:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-01-13 01:38:53 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-07-02 02:32:29 +00:00
|
|
|
- name: Discover ansible roles
|
|
|
|
id: set-ansible-roles
|
2023-05-21 03:00:17 +00:00
|
|
|
env:
|
|
|
|
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
2023-01-13 01:38:53 +00:00
|
|
|
run: |
|
2024-07-02 02:32:29 +00:00
|
|
|
roles=$(echo $LABELS | jq -c '[.[] | select(startswith("roles/")) | ltrimstr("roles/")]')
|
|
|
|
echo $roles
|
|
|
|
echo "roles=$roles" >> $GITHUB_OUTPUT
|
2023-01-13 01:38:53 +00:00
|
|
|
|
|
|
|
- name: Discover integration tests
|
|
|
|
id: set-integration-tests
|
2023-01-11 19:55:24 +00:00
|
|
|
run: |
|
2023-01-13 01:38:53 +00:00
|
|
|
echo tests="[`for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -not -iname "molecule-*" -printf "%f\n"); do
|
|
|
|
echo '{"test":\"'"${test}"'\","name":\"'"${test}\"'"}';
|
|
|
|
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
2023-01-11 19:55:24 +00:00
|
|
|
|
2024-07-02 02:32:29 +00:00
|
|
|
molecule:
|
|
|
|
uses: ./.github/workflows/ansible-test-molecule.yml
|
2023-01-13 01:36:41 +00:00
|
|
|
needs:
|
|
|
|
- discover-ansible-tests
|
|
|
|
- discover-ansible-versions
|
2024-07-02 02:32:29 +00:00
|
|
|
if: needs.discover-ansible-tests.outputs.ansible-roles != '[]' &&
|
|
|
|
needs.discover-ansible-tests.outputs.ansible-roles != ''
|
2023-01-11 19:55:24 +00:00
|
|
|
with:
|
2024-07-02 02:32:29 +00:00
|
|
|
role: ${{ matrix.role }}
|
2023-01-13 01:36:41 +00:00
|
|
|
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
2024-07-02 02:32:29 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
role: ${{ fromJson(needs.discover-ansible-tests.outputs.ansible-roles) }}
|
2023-01-11 19:55:24 +00:00
|
|
|
|
|
|
|
ansible-test-integration:
|
|
|
|
uses: ./.github/workflows/ansible-test-integration.yml
|
2023-01-13 01:36:41 +00:00
|
|
|
needs:
|
|
|
|
- discover-ansible-tests
|
|
|
|
- discover-ansible-versions
|
2023-01-13 01:38:53 +00:00
|
|
|
if:
|
|
|
|
needs.discover-ansible-tests.outputs.integration-tests != '[]' &&
|
|
|
|
needs.discover-ansible-tests.outputs.integration-tests != ''
|
2023-01-11 19:55:24 +00:00
|
|
|
with:
|
|
|
|
targets: ${{ needs.discover-ansible-tests.outputs.integration-tests }}
|
2023-01-13 01:36:41 +00:00
|
|
|
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|