Skip to content

Commit

Permalink
More proper validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbarros committed Jun 6, 2024
1 parent 9f0dc87 commit d90406f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/yocto-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ jobs:
Please contact a member of the organization for assistance."
exit 1
- name: Validate inputs
run: |
# This can't possibly work, can it?
validate_json_array() {
echo ${{ inputs.$1 }} | jq ".[]"
status=$?
if [ $status -ne 0 ]; then
echo "INPUT ERROR: $1 must be JSON array, got ${{ inputs.$1 }}"
exit 1
fi
}
echo "Here we go..."
validate_json_array runs-on
validate_json_array test-suites
validate_json_array test-workers
echo "All done..."
# this must be done before putting files in the workspace
# https://github.com/easimon/maximize-build-space
- name: Maximize build space
Expand Down Expand Up @@ -978,11 +996,6 @@ jobs:
"WORKER_TYPE": ${{ inputs.test-workers }}
}
run: |
# Validate inputs meant to be JSON arrays.
echo ${{ inputs.runs-on }} | jq ".[]" || echo "INPUT ERROR: runs-on must be JSON array, got ${{ inputs.test-suites }}"
echo ${{ inputs.test-suites }} | jq ".[]" || echo "INPUT ERROR: test-suites must be JSON array, got ${{ inputs.test-suites }}"
echo ${{ inputs.test-workers }} | jq ".[]" || echo "INPUT ERROR: test-workers must be JSON array, got ${{ inputs.test-suites }}"
echo $json
json=$(jq -e -c . <<<"${MATRIX}") || exit $?
echo "json=${json}" >> "${GITHUB_OUTPUT}"
Expand Down

0 comments on commit d90406f

Please sign in to comment.