Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pinning of coverage reporter version #208

Merged
merged 7 commits into from
May 7, 2024
32 changes: 28 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ inputs:
description: 'Whether to fail (exit code 1) on any issues while uploading the coverage'
required: false
default: 'true'
coverage-reporter-version:
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'
branding:
color: 'green'
icon: 'percent'
Expand All @@ -79,27 +83,47 @@ runs:
brew tap coverallsapp/coveralls --quiet
brew install coveralls --quiet

- name: Report coverage-reporter-version information 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"
littleforest marked this conversation as resolved.
Show resolved Hide resolved

- name: Install coveralls reporter (Linux)
if: runner.os == 'Linux'
env:
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
shell: bash
run: |
mkdir -p ~/bin/
cd ~/bin/
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-linux.tar.gz
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt
if [ $COVERAGE_REPORTER_VERSION == "latest" ]
then
asset_path=latest/download
else
asset_path="download/${COVERAGE_REPORTER_VERSION}"
fi
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz"
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"
cat coveralls-checksums.txt | grep coveralls-linux.tar.gz | sha256sum --check
tar -xzf coveralls-linux.tar.gz
rm coveralls-checksums.txt
echo ~/bin >> $GITHUB_PATH

- name: Install coveralls reporter (Windows)
if: startsWith(runner.os, 'Windows')
env:
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
shell: pwsh
run: |
New-Item -Path $env:HOME\bin -ItemType directory -Force
Push-Location $env:HOME\bin
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"
if($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 {
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-windows.exe" -OutFile "coveralls.exe"
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-checksums.txt" -OutFile "sha256sums.txt"
}
(Get-FileHash coveralls.exe).Hash -eq (Get-Content ./sha256sums.txt | Where-Object{$_ -match 'windows.exe'} | ForEach-Object{($_ -split "\s+")[0]})
Remove-Item *.txt -Force
echo $env:HOME\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Expand Down