Skip to content

Commit 643bc37

Browse files
Allow pinning of coverage reporter version (#208)
This add a coverage-reporter-version parameter that allows users to specify a version of coverage-reporter to use. It will default to the latest version if not specified. This currently only works for Linux and Windows until versioning can be added to the Coveralls Homebrew tap. --------- Co-authored-by: Mike Burns <[email protected]>
1 parent 1064f6c commit 643bc37

File tree

2 files changed

+51
-24
lines changed

2 files changed

+51
-24
lines changed

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,27 @@ The action's step needs to run after your test suite has outputted an LCOV file.
1212

1313
### Inputs:
1414

15-
| Name | Requirement | Description |
16-
| --------------------- | ----------- | ----------- |
17-
| `github-token` | _required_ | Default if not specified: `${{ github.token }}`. Can be also specified this way: `github-token: ${{ secrets.GITHUB_TOKEN }}`; Coveralls uses this token to verify the appropriate repo at Coveralls and send any new status updates based on your coverage results. This variable is built into Github Actions, so __do not add it to your secrets store__. [More Info](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)|
18-
| `file` | _optional_ | Default: all coverage files that could be found. Local path to the coverage report file produced by your test suite. An error will be thrown if no file was found. This is the file that will be sent to the Coveralls API. Leave empty if you want to combine many files reports. |
19-
| `files` | _optional_ | Default: all coverage files that could be found. Space-separated list of coverage report files produced by your test suite. Example: `files: coverage/test1.lcov coverage/test2.lcov` |
20-
| `format` | _optional_ | Force coverage report file format. If not specified, coveralls will try to detect the format based on file extension and/or content. Possible values: `lcov`, `simplecov`, `cobertura`, `jacoco`, `gcov`, `golang`, `python`. See also [actual supported coverage report formats list](https://github.com/coverallsapp/coverage-reporter#supported-coverage-report-formats). |
21-
| `flag-name` | _optional (unique required if parallel)_ | Job flag name, e.g. "Unit", "Functional", or "Integration". Will be shown in the Coveralls UI. |
22-
| `parallel` | _optional_ | Set to true for parallel (or matrix) based steps, where multiple posts to Coveralls will be performed in the check. `flag-name` needs to be set and unique, e.g. `flag-name: run ${{ join(matrix.*, ' - ') }}` |
23-
| `parallel-finished` | _optional_ | Set to true in the last job, after the other parallel jobs steps have completed, this will send a webhook to Coveralls to set the build complete. |
24-
| `carryforward` | _optional_ | Comma separated flags used to carryforward results from previous builds if some of the parallel jobs are missing. Used only with `parallel-finished`. |
25-
| `coveralls-endpoint` | _optional_ | Hostname and protocol: `https://<host>`; Specifies a [Coveralls Enterprise](https://enterprise.coveralls.io/) hostname. |
26-
| `allow-empty` | _optional_ | Default: `false`. Don't fail if coverage report is empty or contains no coverage data. |
27-
| `base-path` | _optional_ | Path to the root folder of the project the coverage was collected in. Should be used in monorepos so that coveralls can process the LCOV correctly (e.g. packages/my-project) |
28-
| `git-branch` | _optional_ | Default: GITHUB_REF environment variable. Override the branch name. |
29-
| `git-commit` | _optional_ | Default: GITHUB_SHA environment variable. Override the commit SHA. |
30-
| `compare-ref` | _optional_ | Branch name to compare coverage with. Specify if you want to always check coverage change for PRs against one branch. |
31-
| `compare-sha` | _optional_ | Commit SHA to compare coverage with. |
32-
| `debug` | _optional_ | Default: `false`. Set to `true` to enable debug logging. |
33-
| `measure` | _optional_ | Default: `false`. Set to `true` to enable time time measurement logging. |
34-
| `fail-on-error` | _optional_ | Default: `true`. Set to `false` to avoid CI failure when upload fails due to any errors. |
15+
| Name | Requirement | Description |
16+
| --------------------------- | ----------- | ----------- |
17+
| `github-token` | _required_ | Default if not specified: `${{ github.token }}`. Can be also specified this way: `github-token: ${{ secrets.GITHUB_TOKEN }}`; Coveralls uses this token to verify the appropriate repo at Coveralls and send any new status updates based on your coverage results. This variable is built into Github Actions, so __do not add it to your secrets store__. [More Info](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)|
18+
| `file` | _optional_ | Default: all coverage files that could be found. Local path to the coverage report file produced by your test suite. An error will be thrown if no file was found. This is the file that will be sent to the Coveralls API. Leave empty if you want to combine many files reports. |
19+
| `files` | _optional_ | Default: all coverage files that could be found. Space-separated list of coverage report files produced by your test suite. Example: `files: coverage/test1.lcov coverage/test2.lcov` |
20+
| `format` | _optional_ | Force coverage report file format. If not specified, coveralls will try to detect the format based on file extension and/or content. Possible values: `lcov`, `simplecov`, `cobertura`, `jacoco`, `gcov`, `golang`, `python`. See also [actual supported coverage report formats list](https://github.com/coverallsapp/coverage-reporter#supported-coverage-report-formats). |
21+
| `flag-name` | _optional (unique required if parallel)_ | Job flag name, e.g. "Unit", "Functional", or "Integration". Will be shown in the Coveralls UI. |
22+
| `parallel` | _optional_ | Set to true for parallel (or matrix) based steps, where multiple posts to Coveralls will be performed in the check. `flag-name` needs to be set and unique, e.g. `flag-name: run ${{ join(matrix.*, ' - ') }}` |
23+
| `parallel-finished` | _optional_ | Set to true in the last job, after the other parallel jobs steps have completed, this will send a webhook to Coveralls to set the build complete. |
24+
| `carryforward` | _optional_ | Comma separated flags used to carryforward results from previous builds if some of the parallel jobs are missing. Used only with `parallel-finished`. |
25+
| `coveralls-endpoint` | _optional_ | Hostname and protocol: `https://<host>`; Specifies a [Coveralls Enterprise](https://enterprise.coveralls.io/) hostname. |
26+
| `allow-empty` | _optional_ | Default: `false`. Don't fail if coverage report is empty or contains no coverage data. |
27+
| `base-path` | _optional_ | Path to the root folder of the project the coverage was collected in. Should be used in monorepos so that coveralls can process the LCOV correctly (e.g. packages/my-project) |
28+
| `git-branch` | _optional_ | Default: GITHUB_REF environment variable. Override the branch name. |
29+
| `git-commit` | _optional_ | Default: GITHUB_SHA environment variable. Override the commit SHA. |
30+
| `compare-ref` | _optional_ | Branch name to compare coverage with. Specify if you want to always check coverage change for PRs against one branch. |
31+
| `compare-sha` | _optional_ | Commit SHA to compare coverage with. |
32+
| `debug` | _optional_ | Default: `false`. Set to `true` to enable debug logging. |
33+
| `measure` | _optional_ | Default: `false`. Set to `true` to enable time time measurement logging. |
34+
| `fail-on-error` | _optional_ | Default: `true`. Set to `false` to avoid CI failure when upload fails due to any errors. |
35+
| `coverage-reporter-version` | _optional_ | Default: `latest`. Version of coverage-reporter to use. Make sure to prefix the version number with 'v'. For example: v0.6.9. Not available currently on macOS. |
3536

3637
### Outputs:
3738

action.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ inputs:
6666
description: 'Whether to fail (exit code 1) on any issues while uploading the coverage'
6767
required: false
6868
default: 'true'
69+
coverage-reporter-version:
70+
description: "Version of coverage-reporter to use. Make sure to prefix the version number with 'v'. For example: v0.6.9"
71+
required: false
72+
default: 'latest'
6973
branding:
7074
color: 'green'
7175
icon: 'percent'
@@ -79,27 +83,49 @@ runs:
7983
brew tap coverallsapp/coveralls --quiet
8084
brew install coveralls --quiet
8185
86+
- name: Report coverage-reporter-version information for macOS
87+
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
88+
shell: bash
89+
run: |
90+
echo "The coverage-reporter-version parameter is not available on macOS" >&2
91+
exit 1
92+
8293
- name: Install coveralls reporter (Linux)
8394
if: runner.os == 'Linux'
95+
env:
96+
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
8497
shell: bash
8598
run: |
8699
mkdir -p ~/bin/
87100
cd ~/bin/
88-
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-linux.tar.gz
89-
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt
101+
if [ $COVERAGE_REPORTER_VERSION == "latest" ]
102+
then
103+
asset_path=latest/download
104+
else
105+
asset_path="download/${COVERAGE_REPORTER_VERSION}"
106+
fi
107+
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz"
108+
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"
90109
cat coveralls-checksums.txt | grep coveralls-linux.tar.gz | sha256sum --check
91110
tar -xzf coveralls-linux.tar.gz
92111
rm coveralls-checksums.txt
93112
echo ~/bin >> $GITHUB_PATH
94113
95114
- name: Install coveralls reporter (Windows)
96115
if: startsWith(runner.os, 'Windows')
116+
env:
117+
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
97118
shell: pwsh
98119
run: |
99120
New-Item -Path $env:HOME\bin -ItemType directory -Force
100121
Push-Location $env:HOME\bin
101-
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-windows.exe" -OutFile "coveralls.exe"
102-
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt" -OutFile "sha256sums.txt"
122+
if($env:COVERAGE_REPORTER_VERSION -eq "latest") {
123+
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-windows.exe" -OutFile "coveralls.exe"
124+
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt" -OutFile "sha256sums.txt"
125+
} else {
126+
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-windows.exe" -OutFile "coveralls.exe"
127+
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-checksums.txt" -OutFile "sha256sums.txt"
128+
}
103129
(Get-FileHash coveralls.exe).Hash -eq (Get-Content ./sha256sums.txt | Where-Object{$_ -match 'windows.exe'} | ForEach-Object{($_ -split "\s+")[0]})
104130
Remove-Item *.txt -Force
105131
echo $env:HOME\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

0 commit comments

Comments
 (0)