From d90406f69f15da5b00552235da139da47bc71a42 Mon Sep 17 00:00:00 2001 From: Leandro Motta Barros Date: Thu, 6 Jun 2024 14:33:43 -0300 Subject: [PATCH] More proper validation --- .github/workflows/yocto-build-deploy.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/yocto-build-deploy.yml b/.github/workflows/yocto-build-deploy.yml index caa400a37..fac85faf5 100644 --- a/.github/workflows/yocto-build-deploy.yml +++ b/.github/workflows/yocto-build-deploy.yml @@ -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 @@ -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}"