From f0e10f46ff84f4d32178b4b76e1ef180b16f82c3 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 31 Mar 2025 06:35:49 -0500 Subject: [PATCH] 1.7.1 for windows and some small cleanup (#17) * 171 for windows and some small cleanup * startWith -> startsWith --- .github/workflows/tests.yaml | 36 +++++++++++------------------------- action.yaml | 4 ++-- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index eb992bd..a5028dd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -155,15 +155,13 @@ jobs: if: runner.os == 'Linux' || runner.os == 'macOS' # language=sh run: | - _installed='${{ steps.install-jq.outputs.installed }}' - _err= if [[ '${{ matrix.force }}' == 'true' ]]; then # enabling "force" must result in an install if [[ '${{ steps.install-jq.outputs.installed }}' != 'true' ]]; then echo 'Unexpected value for "installed":' echo 'Expected: "true"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi else if [[ '${{ steps.install-jq.outputs.found }}' == 'true' ]]; then @@ -172,7 +170,7 @@ jobs: echo 'Unexpected value for "installed":' echo 'Expected: "false"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi else # if not found, must be installed @@ -180,12 +178,10 @@ jobs: echo 'Unexpected value for "installed":' echo 'Expected: "true"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi fi fi - if [ -n "${_err}" ]; then exit 1; fi; - - name: Check jq - Windows-ish if: runner.os == 'Windows' && matrix.force == 'true' @@ -210,7 +206,6 @@ jobs: $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest $_installed='${{ steps.install-jq.outputs.installed }}' - $_err = 0 if ("${{ matrix.force }}" -eq "true") { # enabling "force" must result in an install @@ -219,7 +214,7 @@ jobs: Write-Host "Unexpected value for installed" Write-Host "Expected: true" Write-Host "Actual: ${{ steps.install-jq.outputs.installed }}" - $_err=1 + exit 1 } } else @@ -232,7 +227,7 @@ jobs: Write-Host "Unexpected value for installed" Write-Host "Expected: false" Write-Host "Actual: ${{ steps.install-jq.outputs.installed }}" - $_err=1 + exit 1 } } else @@ -242,14 +237,10 @@ jobs: Write-Host "Unexpected value for installed" Write-Host "Expected: true" Write-Host "Actual: ${{ steps.install-jq.outputs.installed }}" - $_err=1 + exit 1 } } } - if ("${_err}" -ne 0) - { - exit 1 - } test-container: strategy: matrix: @@ -281,35 +272,31 @@ jobs: - name: Check jq # language=sh run: | - _err= _which="$(which jq)" _vers="$(jq --version)" if [[ "${_which}" != "$RUNNER_TOOL_CACHE/jq/jq" ]]; then echo "jq found at unexpected path." echo " Expected: \"$RUNNER_TOOL_CACHE/jq/jq\"" echo " Actual: \"${_which}\"" - _err=1 + exit 1 fi if [[ "${_vers}" != 'jq-${{ matrix.version }}' ]]; then echo "jq --version returned unexpected value" echo ' Expected: "jq-${{ matrix.version }}"' echo " Actual: \"${_vers}\"" - _err=1 + exit 1 fi - if [ -n "${_err}" ]; then exit 1; fi; - name: Check Outputs # language=sh run: | - _installed='${{ steps.install-jq.outputs.installed }}' - _err= if [[ '${{ matrix.force }}' == 'true' ]]; then # enabling "force" must result in an install if [[ '${{ steps.install-jq.outputs.installed }}' != 'true' ]]; then echo 'Unexpected value for "installed":' echo 'Expected: "true"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi else if [[ '${{ steps.install-jq.outputs.found }}' == 'true' ]]; then @@ -318,7 +305,7 @@ jobs: echo 'Unexpected value for "installed":' echo 'Expected: "false"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi else # if not found, must be installed @@ -326,8 +313,7 @@ jobs: echo 'Unexpected value for "installed":' echo 'Expected: "true"' echo 'Actual: "${{ steps.install-jq.outputs.installed }}"' - _err=1 + exit 1 fi fi fi - if [ -n "${_err}" ]; then exit 1; fi; diff --git a/action.yaml b/action.yaml index c70eb23..0efdcba 100644 --- a/action.yaml +++ b/action.yaml @@ -72,14 +72,14 @@ runs: } - name: 'Install jq - Windows-ish non-1.7' - if: runner.os == 'Windows' && (inputs.version == '1.5' || inputs.version == '1.6') && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true') + if: runner.os == 'Windows' && (startsWith(inputs.version, '1.5') || startsWith(inputs.version, '1.6')) && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true') shell: powershell env: JQ_VERSION: '${{ inputs.version }}' run: ${{ github.action_path }}\scripts\windowsish.ps1 - name: 'Install jq - Windows-ish 1.7' - if: runner.os == 'Windows' && inputs.version == '1.7' && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true') + if: runner.os == 'Windows' && startsWith(inputs.version, '1.7') && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true') shell: powershell env: JQ_VERSION: '${{ inputs.version }}'