From 1223f4dc1102d10e063b00e25a42f4635391fe2f Mon Sep 17 00:00:00 2001 From: gardar Date: Tue, 2 Jul 2024 02:32:29 +0000 Subject: [PATCH 1/2] refactor(ci): split up molecule matrices to avoid job limit Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 30 +++++++------- .github/workflows/ansible-test-molecule.yml | 43 +++++++++++++++++++++ 2 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/ansible-test-molecule.yml diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index 3baa043ec..efb23d308 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -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 diff --git a/.github/workflows/ansible-test-molecule.yml b/.github/workflows/ansible-test-molecule.yml new file mode 100644 index 000000000..eacb36510 --- /dev/null +++ b/.github/workflows/ansible-test-molecule.yml @@ -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 From 1f44b4c5542b8f3474c5471b4e4aae6fc526e82e Mon Sep 17 00:00:00 2001 From: gardar Date: Tue, 2 Jul 2024 02:33:38 +0000 Subject: [PATCH 2/2] fix: avoid extra whitespaces in label list Signed-off-by: gardar --- .github/workflows/conventional-label.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conventional-label.yml b/.github/workflows/conventional-label.yml index ee512f06f..174c00016 100644 --- a/.github/workflows/conventional-label.yml +++ b/.github/workflows/conventional-label.yml @@ -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