Skip to content

Commit 4061f15

Browse files
committed
Remove the code the verifies the existence of the binary to each OS-specific installation step so we can keep a generic call to each coveralls command and not have to create OS-specific steps for those too.
1 parent 1f4e104 commit 4061f15

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

Diff for: action.yml

+41-28
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ runs:
8383
brew tap coverallsapp/coveralls --quiet
8484
brew install coveralls --quiet
8585
86+
# Check if the binary exists in the expected location
87+
if [ ! -f /usr/local/bin/coveralls ]; then
88+
echo "Coveralls binary not found after installation (MacOS)."
89+
exit 1
90+
fi
91+
8692
- name: Report coverage-reporter-version information for macOS
8793
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
8894
shell: bash
8995
run: |
90-
echo "The coverage-reporter-version parameter is not available on macOS" >&2
96+
echo "The coverage-reporter-version parameter is not available on macOS." >&2
9197
exit 1
9298
9399
- name: Install coveralls reporter (Linux)
@@ -111,7 +117,7 @@ runs:
111117
# Try to download the binary and checksum file
112118
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz" ||
113119
! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
114-
echo "Failed to download coveralls binary or checksum."
120+
echo "Failed to download coveralls binary or checksum (Linux)."
115121
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
116122
exit 1
117123
fi
@@ -124,7 +130,7 @@ runs:
124130
125131
# Verify the downloaded binary
126132
if ! grep coveralls-linux.tar.gz coveralls-checksums.txt | sha256sum --check; then
127-
echo "Checksum verification failed."
133+
echo "Checksum verification failed (Linux)."
128134
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
129135
exit 1
130136
fi
@@ -141,6 +147,12 @@ runs:
141147
rm coveralls-checksums.txt
142148
echo ~/bin >> $GITHUB_PATH
143149
150+
# Check if the binary exists
151+
if [ ! -f ~/bin/coveralls ]; then
152+
echo "Coveralls binary not found after extraction (Linux)."
153+
exit 1
154+
fi
155+
144156
- name: Install coveralls reporter (Windows)
145157
if: startsWith(runner.os, 'Windows')
146158
env:
@@ -156,22 +168,28 @@ runs:
156168
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-windows.exe" -OutFile "coveralls.exe"
157169
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-checksums.txt" -OutFile "sha256sums.txt"
158170
}
159-
(Get-FileHash coveralls.exe).Hash -eq (Get-Content ./sha256sums.txt | Where-Object{$_ -match 'windows.exe'} | ForEach-Object{($_ -split "\s+")[0]})
160-
Remove-Item *.txt -Force
171+
172+
if ((Get-FileHash coveralls.exe).Hash -ne (Get-Content sha256sums.txt | Select-String 'windows.exe' | ForEach-Object { ($_ -split "\s+")[0] })) {
173+
Write-Host "Checksum verification failed (Windows)."
174+
exit 1
175+
}
176+
177+
# Check if the binary exists
178+
if (!(Test-Path -Path "$env:HOME\bin\coveralls.exe")) {
179+
Write-Host "Coveralls binary not found after download and verification (Windows)."
180+
exit 1
181+
}
182+
183+
Remove-Item sha256sums.txt -Force
161184
echo $env:HOME\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
162185
163186
- name: Done report
164187
if: inputs.parallel-finished == 'true'
165188
shell: ${{ startsWith(runner.os, 'Windows') && 'pwsh' || 'bash' }}
166-
run: |
167-
if [ ! -f ~/bin/coveralls ]; then
168-
echo "Coveralls binary not found."
169-
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
170-
exit 1
171-
fi
172-
~/bin/coveralls done \
173-
${{ inputs.debug == 'true' && '--debug' || '' }} \
174-
${{ inputs.measure == 'true' && '--measure' || '' }} \
189+
run: >-
190+
coveralls done
191+
${{ inputs.debug == 'true' && '--debug' || '' }}
192+
${{ inputs.measure == 'true' && '--measure' || '' }}
175193
${{ inputs.fail-on-error == 'false' && '--no-fail' || '' }}
176194
env:
177195
COVERALLS_DEBUG: ${{ inputs.debug }}
@@ -186,20 +204,15 @@ runs:
186204
- name: Coverage report
187205
if: inputs.parallel-finished != 'true'
188206
shell: ${{ startsWith(runner.os, 'Windows') && 'pwsh' || 'bash' }}
189-
run: |
190-
if [ ! -f ~/bin/coveralls ]; then
191-
echo "Coveralls binary not found."
192-
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
193-
exit 1
194-
fi
195-
~/bin/coveralls report \
196-
${{ inputs.debug == 'true' && '--debug' || '' }} \
197-
${{ inputs.measure == 'true' && '--measure' || '' }} \
198-
${{ inputs.fail-on-error == 'false' && '--no-fail' || '' }} \
199-
${{ inputs.allow-empty == 'true' && '--allow-empty' || '' }} \
200-
${{ inputs.base-path && format('--base-path {0}', inputs.base-path) || '' }} \
201-
${{ inputs.format && format('--format {0}', inputs.format) || '' }} \
202-
${{ inputs.file || inputs.path-to-lcov }} \
207+
run: >-
208+
coveralls report
209+
${{ inputs.debug == 'true' && '--debug' || '' }}
210+
${{ inputs.measure == 'true' && '--measure' || '' }}
211+
${{ inputs.fail-on-error == 'false' && '--no-fail' || '' }}
212+
${{ inputs.allow-empty == 'true' && '--allow-empty' || '' }}
213+
${{ inputs.base-path && format('--base-path {0}', inputs.base-path) || '' }}
214+
${{ inputs.format && format('--format {0}', inputs.format) || '' }}
215+
${{ inputs.file || inputs.path-to-lcov }}
203216
${{ inputs.files }}
204217
env:
205218
COVERALLS_DEBUG: ${{ inputs.debug }}

0 commit comments

Comments
 (0)