Skip to content

Commit 3242aa4

Browse files
authored
fix: nested matrix structure (#441)
* limit test suite scope Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * fix trigger Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * helpful error message Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * typo Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * retry Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * again Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * huh Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * ready Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * tidy up error message Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * nested matrix Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * flatten nested matrix Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> * revert test suite Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> --------- Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
1 parent dc47399 commit 3242aa4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.github/workflows/test_suite.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33

44
on:
55
pull_request:
6-
paths: [.github/workflows/tf_tests.yaml, action.yml, tests/**]
6+
paths: [.github/workflows/test_suite.yaml, action.yml, tests/**]
77
types: [opened, reopened, synchronize, closed]
88

99
jobs:

action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ runs:
106106
job_id=$(echo "$workflow_run" | jq --raw-output '(.jobs[] | select((.name | ascii_downcase | gsub("-|_"; " ")) == (env.GITHUB_JOB | ascii_downcase | gsub("-|_"; " "))) | .id) // .jobs[0].id' | tail -n 1)
107107
else
108108
# For matrix jobs, join the matrix values with comma separator into a single string and get the ID of the job which contains it.
109-
matrix=$(echo "$GH_MATRIX" | jq --raw-output 'to_entries | map(.value) | join(", ")')
109+
matrix=$(echo "$GH_MATRIX" | jq --raw-output 'to_entries | map(if .value | type == "object" then (.value | to_entries[0].value) else .value end) | join(", ")')
110110
job_id=$(echo "$workflow_run" | jq --raw-output --arg matrix "$matrix" '.jobs[] | select(.name | contains($matrix)) | .id' | tail -n 1)
111111
fi
112112
echo "job=$job_id" >> "$GITHUB_OUTPUT"
@@ -168,7 +168,8 @@ runs:
168168
run: |
169169
# Download plan file.
170170
# Get the artifact ID of the latest matching plan files for download.
171-
artifact_id=$(gh api /repos/${{ github.repository }}/actions/artifacts --header "$GH_API" --method GET --field "name=${{ steps.identifier.outputs.name }}" --jq '.artifacts[0].id')
171+
artifact_id=$(gh api /repos/${{ github.repository }}/actions/artifacts --header "$GH_API" --method GET --field "name=${{ steps.identifier.outputs.name }}" --jq '.artifacts[0].id' 2>/dev/null)
172+
if [ -z "$artifact_id" ]; then echo "Unable to locate plan file: ${{ steps.identifier.outputs.name }}." && exit 1; fi
172173
gh api /repos/${{ github.repository }}/actions/artifacts/${artifact_id}/zip --header "$GH_API" --method GET > "${{ steps.identifier.outputs.name }}.zip"
173174
174175
# Unzip the plan file to the working directory, then clean up the zip file.

0 commit comments

Comments
 (0)