From b195ff4b7410c3dec522ad52f73431a03372353e Mon Sep 17 00:00:00 2001 From: gardar Date: Mon, 15 May 2023 18:18:42 +0000 Subject: [PATCH] test: allow triggering role test with label Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index afd19819f..53f1d4a56 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -7,6 +7,7 @@ on: - edited - reopened - synchronize + - labeled workflow_dispatch: env: @@ -68,10 +69,12 @@ jobs: since_last_remote_commit: "true" - name: Discover role tests - if: steps.changed-roles.outputs.any_changed == 'true' + if: ${{ (steps.changed-roles.outputs.any_changed == 'true') && (contains(github.event.label.name, 'test-role-')) }} id: set-molecule-tests run: | - echo tests="[`for role in ${{ steps.changed-roles.outputs.all_changed_and_modified_files }}; do + roles="${{ steps.changed-roles.outputs.all_changed_and_modified_files }} ${${{ github.event.label.name }}##*-}" + echo $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