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:
|
2023-01-13 01:36:41 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
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-01-13 01:36:41 +00:00
|
|
|
discover-ansible-versions:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
versions: ${{ steps.supported-ansible-versions.outputs.result }}
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Get Ansible versions that the collection supports
|
|
|
|
id: supported-ansible-versions
|
|
|
|
uses: mikefarah/yq@master
|
|
|
|
with:
|
2023-04-11 14:08:59 +00:00
|
|
|
cmd: yq -o json -I=0 '.requires_ansible | split(",") | .[] |= sub("(.*?)(\d+\.\d+)(.*)"; "stable-${2}")' meta/runtime.yml
|
2023-01-13 01:36:41 +00:00
|
|
|
|
2023-01-11 19:55:24 +00:00
|
|
|
ansible-test-sanity:
|
2023-05-15 19:42:49 +00:00
|
|
|
if: |
|
|
|
|
!github.event.label
|
2023-01-11 19:55:24 +00:00
|
|
|
uses: ./.github/workflows/ansible-test-sanity.yml
|
2023-01-13 01:36:41 +00:00
|
|
|
needs:
|
|
|
|
- ansible-lint
|
|
|
|
- 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
|
|
|
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
|
|
|
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
2023-01-11 19:55:24 +00:00
|
|
|
steps:
|
2023-01-13 01:38:53 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Discover role tests
|
|
|
|
id: set-molecule-tests
|
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: |
|
2023-07-23 09:40:04 +00:00
|
|
|
roles=$(echo $LABELS | jq -r '.[]' | grep '^roles/' | sed 's|^roles/||')
|
2023-05-15 19:04:11 +00:00
|
|
|
echo tests="[`for role in $roles; do
|
2023-01-13 01:38:53 +00:00
|
|
|
for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -iname "molecule-${role}-*" -printf "%f\n"); do
|
|
|
|
echo '{"test":\"'"${test}"'\","name":\"'"${test#*-}\"'"}';
|
|
|
|
done
|
|
|
|
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
ansible-test-molecule:
|
|
|
|
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.molecule-tests != '[]' &&
|
|
|
|
needs.discover-ansible-tests.outputs.molecule-tests != ''
|
2023-01-11 19:55:24 +00:00
|
|
|
with:
|
|
|
|
targets: ${{ needs.discover-ansible-tests.outputs.molecule-tests }}
|
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
|
|
|
|
|
|
|
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 }}
|