Skip to content

Commit

Permalink
Add coverage-reporter-platform input option to control which architec…
Browse files Browse the repository at this point in the history
…ure-specific version of coverage-reporter is downloaded and run by the github-action. Since this optionis not available for MacOS or Windows, we will deliver warning messages if the option is set, but continue processing with default behaviour. We have also stepped back from the previous implementation of the exception for coverage-reporter-version on MacOS and have turned that error message + exit code 1 into a warning message, allowing processing to proceed. We have also added tests to test different values for coverage-reporter-platform.
  • Loading branch information
afinetooth committed Oct 19, 2024
1 parent 0db2c3c commit ab814ce
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
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 || '' }}
coverage-reporter-platform: ${{ matrix.coverage_reporter_platform }}
env:
CI: true
continue-on-error: true
51 changes: 39 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,28 @@ inputs:
description: "Version of coverage-reporter to use. Make sure to prefix the version number with 'v'. For example: v0.6.9"
required: false
default: 'latest'
coverage-reporter-platform:
description: "Platform of coverage-reporter to use on Linux runners. Supported values: x86_64 (default) and aarch64 (or arm64)"
required: false
default: 'x86_64'
branding:
color: 'green'
icon: 'percent'
runs:
using: 'composite'
steps:
- name: Report coverage-reporter-version exception for macOS
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
shell: bash
run: |
echo "Warning: The coverage-reporter-version parameter is not available on macOS. The latest version will be installed via Homebrew." >&2
- name: Report coverage-reporter-platform exception for macOS
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-platform != '' }}
shell: bash
run: |
echo "Warning: The coverage-reporter-platform parameter is not available on macOS. The default version for macOS will be used." >&2
- name: Install coveralls reporter (macOS)
if: runner.os == 'macOS'
shell: bash
Expand All @@ -100,21 +116,11 @@ runs:
exit 1
fi
- name: Report coverage-reporter-version exception for macOS
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
shell: bash
run: |
echo "The coverage-reporter-version parameter is not available on macOS." >&2
if [[ "${{ inputs.fail-on-error }}" == "true" ]]; then
exit 1
else
exit 0
fi
- name: Install coveralls reporter (Linux)
if: runner.os == 'Linux'
env:
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
COVERAGE_REPORTER_PLATFORM: ${{ inputs.coverage-reporter-platform }}
shell: bash
run: |
# Enable debugging if 'debug' is true
Expand All @@ -130,8 +136,23 @@ runs:
asset_path="download/${COVERAGE_REPORTER_VERSION}"
fi
# Determine the platform-specific filename
case "$COVERAGE_REPORTER_PLATFORM" in
x86_64)
platform_filename="coveralls-linux-x86_64.tar.gz"
;;
aarch64|arm64)
platform_filename="coveralls-linux-aarch64.tar.gz"
;;
*)
echo "Unsupported platform: $COVERAGE_REPORTER_PLATFORM"
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
exit 1
;;
esac
# Try to download the binary and checksum file
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz" ||
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/${platform_filename}" ||
! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
echo "Failed to download coveralls binary or checksum (Linux)."
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
Expand All @@ -157,6 +178,12 @@ runs:
rm coveralls-checksums.txt
echo ~/bin >> $GITHUB_PATH
- name: Report coverage-reporter-platform exception for Windows
if: ${{ startsWith(runner.os, 'Windows') && inputs.coverage-reporter-platform != '' }}
shell: pwsh
run: |
Write-Host "Warning: The coverage-reporter-platform parameter is not available on Windows. The default version for Windows will be used." -ForegroundColor Yellow
- name: Install coveralls reporter (Windows)
if: startsWith(runner.os, 'Windows')
env:
Expand Down

0 comments on commit ab814ce

Please sign in to comment.