Skip to content

Commit

Permalink
Also filter based on directory, so we don't try to run a test that do…
Browse files Browse the repository at this point in the history
…esn't exist

Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall committed Dec 10, 2024
1 parent f067d9a commit b3f272b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/platform-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ jobs:
- name: List tests
id: list_tests
run: |
allTests=$(find charts/k8s-monitoring/tests/platform -type d -depth 1 -exec basename {} \; | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')
if [ "${{ github.event_name }}" == "pull_request" ]; then
# All labels on this PR
labels='${{ toJson(github.event.pull_request.labels.*.name) }}'
tests=$(echo "${labels}" | jq --raw-output --compact-output '[.[] | select(startswith("platform-test-")) | sub("^platform-test-"; "")]')

Check failure on line 30 in .github/workflows/platform-test.yml

View workflow job for this annotation

GitHub Actions / runner / yamllint

[yamllint] reported by reviewdog 🐶 [error] trailing spaces (trailing-spaces) Raw Output: ./.github/workflows/platform-test.yml:30:1: [error] trailing spaces (trailing-spaces)
# Filter out labels that don't start with "platform-test-" and remove the prefix
chosenTests=$(echo "${labels}" | jq --raw-output --compact-output '[.[] | select(startswith("platform-test-")) | sub("^platform-test-"; "")]')

Check failure on line 33 in .github/workflows/platform-test.yml

View workflow job for this annotation

GitHub Actions / runner / yamllint

[yamllint] reported by reviewdog 🐶 [error] trailing spaces (trailing-spaces) Raw Output: ./.github/workflows/platform-test.yml:33:1: [error] trailing spaces (trailing-spaces)
# Choose the tests that match the labels
tests=$(jq -n --argjson allTests "${allTests}" --argjson chosenTests "${chosenTests}" '$allTests | map(select(. as $test | $chosenTests | index($test)))')
else
tests=$(find charts/k8s-monitoring/tests/platform -type d -depth 1 -exec basename {} \; | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')
tests=allTests
fi
echo "Running tests: ${tests}"
echo "tests=${tests}" >> "${GITHUB_OUTPUT}"
Expand Down

0 comments on commit b3f272b

Please sign in to comment.