Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ci): split up molecule matrices to avoid job limit #396

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/ansible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/ansible-test-molecule.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions .github/workflows/conventional-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
- name: "Confirm correct pull request title"
uses: mmubeen/action-pr-title@master # until PR gets merged https://github.com/deepakputhraya/action-pr-title/pull/29
with:
allowed_prefixes: >-
breaking,chore,feat,feature,fix,major,minor,enhancement,
deprecated,removed,security,bug,bugfix,docs,packaging,
test,refactor,refactoring,skip-release,skip_changelog,patch
allowed_prefixes: "breaking,chore,feat,feature,fix,major,minor,enhancement,\
deprecated,removed,security,bug,bugfix,docs,packaging,\
test,refactor,refactoring,skip-release,skip_changelog,patch"

- name: "Apply label"
if: github.event.pull_request.labels.length == 0
Expand Down
Loading