Skip to content

Commit

Permalink
Verify that coverage-reporter-version option is recognized (#229)
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
afinetooth authored Oct 15, 2024
1 parent c258231 commit 43f11c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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}"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 43f11c4

Please sign in to comment.