From 43f11c4e058174f808ee9cd63701b6c42fe3f5e3 Mon Sep 17 00:00:00 2001 From: James Kessler Date: Tue, 15 Oct 2024 12:43:25 -0400 Subject: [PATCH] Verify that `coverage-reporter-version` option is recognized (#229) * Add test for coverage-reporter-version. * Add logic to handle when coverage-reporter-version is empty, in addition to when it is null/unset. * Apply fail-on-error logic to error when user tries to set coverage-reporter-version on MacOS (not available there). --- .github/workflows/test.yml | 6 ++++-- action.yml | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a6802f1..4fbb2e0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] action: [report, done, build-number-report, build-number-done] # Note: We're also testing 'install' since it's implicit in each action fail_on_error: [true, false] + coverage_reporter_version: ['v0.6.14', 'latest', ''] steps: - name: Checkout code uses: actions/checkout@v3 @@ -40,10 +41,11 @@ jobs: uses: ./ with: github-token: ${{ secrets.GITHUB_TOKEN }} - fail-on-error: ${{ matrix.fail_on_error }} debug: true + fail-on-error: ${{ matrix.fail_on_error }} build-number: ${{ (matrix.action == 'build-number-report' || matrix.action == 'build-number-done') && github.sha || '' }} # Only set 'build-number' to `${{ github.sha }}` when testing `build-number-report` or `build-number-done` parallel-finished: ${{ matrix.action == 'done' || matrix.action == 'build-number-done' }} # Only set `parallel-finished` to `true` when testing `done` or `build-number-done` + coverage-reporter-version: ${{ matrix.coverage_reporter_version != '' && matrix.coverage_reporter_version || '' }} env: CI: true - continue-on-error: ${{ matrix.fail_on_error }} + continue-on-error: true diff --git a/action.yml b/action.yml index e9032638..e6fafad2 100644 --- a/action.yml +++ b/action.yml @@ -105,7 +105,11 @@ runs: shell: bash run: | echo "The coverage-reporter-version parameter is not available on macOS." >&2 - exit 1 + if [[ "${{ inputs.fail-on-error }}" == "true" ]]; then + exit 1 + else + exit 0 + fi - name: Install coveralls reporter (Linux) if: runner.os == 'Linux' @@ -120,7 +124,7 @@ runs: cd ~/bin/ # Determine which version of coverage-reporter to download - if [ "$COVERAGE_REPORTER_VERSION" == "latest" ]; then + if [ -z "$COVERAGE_REPORTER_VERSION" ] || [ "$COVERAGE_REPORTER_VERSION" == "latest" ]; then asset_path="latest/download" else asset_path="download/${COVERAGE_REPORTER_VERSION}" @@ -167,7 +171,7 @@ runs: # Try to download the binary and checksum file New-Item -Path $env:HOME\bin -ItemType directory -Force Push-Location $env:HOME\bin - if($env:COVERAGE_REPORTER_VERSION -eq "latest") { + if ([string]::IsNullOrEmpty($env:COVERAGE_REPORTER_VERSION) -or $env:COVERAGE_REPORTER_VERSION -eq "latest") { Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-windows.exe" -OutFile "coveralls.exe" Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt" -OutFile "sha256sums.txt" } else {