1
1
# action.yml
2
2
name : ' Coveralls GitHub Action'
3
3
description : ' Send test coverage data to Coveralls.io for analysis, change tracking, and notifications.'
4
- author : ' Nick Merwin ( Coveralls, Inc.) '
4
+ author : Coveralls.io
5
5
inputs :
6
6
github-token :
7
7
description : ' Put secrets.GITHUB_TOKEN here'
@@ -80,14 +80,28 @@ runs:
80
80
if : runner.os == 'macOS'
81
81
shell : bash
82
82
run : |
83
+ # Enable debugging if 'debug' is true
84
+ [ "${{ inputs.debug }}" == "true" ] && set -x
85
+
86
+ # Try to install coverage-reporter via Homebrew
83
87
brew tap coverallsapp/coveralls --quiet
84
88
brew install coveralls --quiet
85
89
86
- - name : Report coverage-reporter-version information for macOS
90
+ # Check if the binary exists in the possible locations
91
+ if [ -f /usr/local/bin/coveralls ]; then
92
+ echo "/usr/local/bin" >> $GITHUB_PATH
93
+ elif [ -f /opt/homebrew/bin/coveralls ]; then
94
+ echo "/opt/homebrew/bin" >> $GITHUB_PATH
95
+ else
96
+ echo "Coveralls binary not found after installation (MacOS)."
97
+ exit 1
98
+ fi
99
+
100
+ - name : Report coverage-reporter-version exception for macOS
87
101
if : ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
88
102
shell : bash
89
103
run : |
90
- echo "The coverage-reporter-version parameter is not available on macOS" >&2
104
+ echo "The coverage-reporter-version parameter is not available on macOS. " >&2
91
105
exit 1
92
106
93
107
- name : Install coveralls reporter (Linux)
@@ -96,18 +110,43 @@ runs:
96
110
COVERAGE_REPORTER_VERSION : ${{ inputs.coverage-reporter-version }}
97
111
shell : bash
98
112
run : |
113
+ # Enable debugging if 'debug' is true
114
+ [ "${{ inputs.debug }}" == "true" ] && set -x
115
+
99
116
mkdir -p ~/bin/
100
117
cd ~/bin/
101
- if [ $COVERAGE_REPORTER_VERSION == "latest" ]
102
- then
103
- asset_path=latest/download
118
+
119
+ # Determine which version of coverage-reporter to download
120
+ if [ "$COVERAGE_REPORTER_VERSION" == "latest" ]; then
121
+ asset_path="latest/download"
104
122
else
105
123
asset_path="download/${COVERAGE_REPORTER_VERSION}"
106
124
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"
109
- cat coveralls-checksums.txt | grep coveralls-linux.tar.gz | sha256sum --check
125
+
126
+ # Try to download the binary and checksum file
127
+ if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz" ||
128
+ ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
129
+ echo "Failed to download coveralls binary or checksum (Linux)."
130
+ [ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
131
+ exit 1
132
+ fi
133
+
134
+ # Try to verify the downloaded binary
135
+ if ! grep coveralls-linux.tar.gz coveralls-checksums.txt | sha256sum --check; then
136
+ echo "Checksum verification failed (Linux)."
137
+ [ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
138
+ exit 1
139
+ fi
140
+
110
141
tar -xzf coveralls-linux.tar.gz
142
+
143
+ # Check if the binary exists
144
+ if [ ! -f ~/bin/coveralls ]; then
145
+ echo "Coveralls binary not found after extraction (Linux)."
146
+ exit 1
147
+ fi
148
+
149
+ # Cleanup
111
150
rm coveralls-checksums.txt
112
151
echo ~/bin >> $GITHUB_PATH
113
152
@@ -117,6 +156,12 @@ runs:
117
156
COVERAGE_REPORTER_VERSION : ${{ inputs.coverage-reporter-version }}
118
157
shell : pwsh
119
158
run : |
159
+ # Enable debugging if 'debug' is true
160
+ if ("${{ inputs.debug }}" -eq "true") {
161
+ Set-PSDebug -Trace 1
162
+ }
163
+
164
+ # Try to download the binary and checksum file
120
165
New-Item -Path $env:HOME\bin -ItemType directory -Force
121
166
Push-Location $env:HOME\bin
122
167
if($env:COVERAGE_REPORTER_VERSION -eq "latest") {
@@ -126,8 +171,21 @@ runs:
126
171
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-windows.exe" -OutFile "coveralls.exe"
127
172
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-checksums.txt" -OutFile "sha256sums.txt"
128
173
}
129
- (Get-FileHash coveralls.exe).Hash -eq (Get-Content ./sha256sums.txt | Where-Object{$_ -match 'windows.exe'} | ForEach-Object{($_ -split "\s+")[0]})
130
- Remove-Item *.txt -Force
174
+
175
+ # Try to verify the downloaded binary
176
+ if ((Get-FileHash coveralls.exe).Hash -ne (Get-Content sha256sums.txt | Select-String 'windows.exe' | ForEach-Object { ($_ -split "\s+")[0] })) {
177
+ Write-Host "Checksum verification failed (Windows)."
178
+ exit 1
179
+ }
180
+
181
+ # Check if the binary exists
182
+ if (!(Test-Path -Path "$env:HOME\bin\coveralls.exe")) {
183
+ Write-Host "Coveralls binary not found after download and verification (Windows)."
184
+ exit 1
185
+ }
186
+
187
+ # Cleanup
188
+ Remove-Item sha256sums.txt -Force
131
189
echo $env:HOME\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
132
190
133
191
- name : Done report
0 commit comments