mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-10 06:14:13 +00:00
refactor(ci): split up molecule matrices to avoid job limit
Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
parent
6662e567d9
commit
1223f4dc11
2 changed files with 58 additions and 15 deletions
30
.github/workflows/ansible-ci.yml
vendored
30
.github/workflows/ansible-ci.yml
vendored
|
@ -63,24 +63,21 @@ jobs:
|
|||
needs:
|
||||
- ansible-lint
|
||||
outputs:
|
||||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
||||
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
||||
ansible-roles: ${{ steps.set-ansible-roles.outputs.roles }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Discover role tests
|
||||
id: set-molecule-tests
|
||||
- name: Discover ansible roles
|
||||
id: set-ansible-roles
|
||||
env:
|
||||
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
||||
run: |
|
||||
roles=$(echo $LABELS | jq -r '.[]' | grep '^roles/' | sed 's|^roles/||')
|
||||
echo tests="[`for role in $roles; do
|
||||
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
|
||||
roles=$(echo $LABELS | jq -c '[.[] | select(startswith("roles/")) | ltrimstr("roles/")]')
|
||||
echo $roles
|
||||
echo "roles=$roles" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Discover integration tests
|
||||
id: set-integration-tests
|
||||
|
@ -89,17 +86,20 @@ jobs:
|
|||
echo '{"test":\"'"${test}"'\","name":\"'"${test}\"'"}';
|
||||
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
|
||||
ansible-test-molecule:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
molecule:
|
||||
uses: ./.github/workflows/ansible-test-molecule.yml
|
||||
needs:
|
||||
- discover-ansible-tests
|
||||
- discover-ansible-versions
|
||||
if: needs.discover-ansible-tests.outputs.molecule-tests != '[]' &&
|
||||
needs.discover-ansible-tests.outputs.molecule-tests != ''
|
||||
if: needs.discover-ansible-tests.outputs.ansible-roles != '[]' &&
|
||||
needs.discover-ansible-tests.outputs.ansible-roles != ''
|
||||
with:
|
||||
targets: ${{ needs.discover-ansible-tests.outputs.molecule-tests }}
|
||||
role: ${{ matrix.role }}
|
||||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
||||
coverage: never
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
role: ${{ fromJson(needs.discover-ansible-tests.outputs.ansible-roles) }}
|
||||
|
||||
ansible-test-integration:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
|
|
43
.github/workflows/ansible-test-molecule.yml
vendored
Normal file
43
.github/workflows/ansible-test-molecule.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
name: Ansible Molecule
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
role:
|
||||
required: true
|
||||
type: string
|
||||
ansible-core-versions:
|
||||
required: false
|
||||
default: '["stable-2.14"]'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
discover-molecule-scenarios:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
||||
|
||||
name: "${{ inputs.role }}-discover-molecule-scenarios"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Discover ${{ inputs.role }} molecule scenarios"
|
||||
id: set-molecule-tests
|
||||
run: |
|
||||
role=${{ inputs.role }}
|
||||
echo tests="[`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 | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
|
||||
ansible-test-integration-molecule:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
needs:
|
||||
- discover-molecule-scenarios
|
||||
if: needs.discover-molecule-scenarios.outputs.molecule-tests != '[]' &&
|
||||
needs.discover-molecule-scenarios.outputs.molecule-tests != ''
|
||||
with:
|
||||
targets: ${{ needs.discover-molecule-scenarios.outputs.molecule-tests }}
|
||||
ansible-core-versions: ${{ inputs.ansible-core-versions }}
|
||||
coverage: never
|
Loading…
Reference in a new issue