Skip to content

Commit 1e133ed

Browse files
committed
Add logic to handle the introduction of new platform-specific filenames available and different contents of coveralls-checksums.txt from version v0.6.15 forward and be backwards compatible with versions <= v0.6.14.
1 parent f1ae604 commit 1e133ed

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

Diff for: action.yml

+36-15
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,48 @@ runs:
138138
version_message="$COVERAGE_REPORTER_VERSION"
139139
fi
140140
141-
# Determine the platform-specific filename
141+
# Function to compare version numbers
142+
version_ge() {
143+
# Compare two version numbers
144+
[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]
145+
}
146+
147+
# Determine the platform-specific filename:
148+
# This logic is necessary due to the introduction of multiple platform support starting from v0.6.15.
149+
# It selects the correct filename based on the specified platform and version, while ensuring
150+
# backward compatibility with earlier versions that only supported a generic Linux binary for x86_64.
142151
case "$COVERAGE_REPORTER_PLATFORM" in
143152
x86_64|"")
144-
platform_filename="coveralls-linux-x86_64.tar.gz"
153+
if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
154+
platform_filename="coveralls-linux-x86_64.tar.gz"
155+
else
156+
platform_filename="coveralls-linux.tar.gz"
157+
fi
145158
;;
146159
aarch64|arm64)
147-
platform_filename="coveralls-linux-aarch64.tar.gz"
160+
if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
161+
platform_filename="coveralls-linux-aarch64.tar.gz"
162+
else
163+
echo "Warning: The aarch64/arm64 platform is only supported from version v0.6.15 onwards. Proceeding with v0.6.15." >&2
164+
asset_path="download/v0.6.15"
165+
platform_filename="coveralls-linux-aarch64.tar.gz"
166+
fi
148167
;;
149168
*)
150169
echo "Warning: Unsupported platform: $COVERAGE_REPORTER_PLATFORM. The default x86_64 version ($version_message) will be used." >&2
151-
platform_filename="coveralls-linux-x86_64.tar.gz"
170+
if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
171+
platform_filename="coveralls-linux-x86_64.tar.gz"
172+
else
173+
platform_filename="coveralls-linux.tar.gz"
174+
fi
152175
;;
153176
esac
154177
178+
# Checksum verification:
179+
# The following code was chosen to replace the more simple `sha256sum -c` because it provides
180+
# clearer debugging information around our new matrix of supported coverage-reporter versions and platforms.
181+
# We may drop back to `${platform_filename}" coveralls-checksums.txt | sha256sum -c` when we're more confidently handling these.
182+
155183
# Try to download the binary and checksum file
156184
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/${platform_filename}" ||
157185
! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
@@ -160,29 +188,22 @@ runs:
160188
exit 1
161189
fi
162190
163-
# Try to verify the downloaded binary
164-
# if ! grep "${platform_filename}" coveralls-checksums.txt | sha256sum -c; then
165-
# echo "Checksum verification failed (Linux)."
166-
# [ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
167-
# exit 1
168-
# fi
169-
170-
# Print contents of checksum file for debugging
191+
# DEBUG: Print contents of checksum file for debugging
171192
echo "Contents of coveralls-checksums.txt:"
172193
cat coveralls-checksums.txt
173194
174-
# Extract the expected checksum
195+
# Extract expected checksum
175196
expected_checksum=$(grep "${platform_filename}" coveralls-checksums.txt | awk '{print $1}')
176197
if [ -z "$expected_checksum" ]; then
177198
echo "Failed to extract checksum for ${platform_filename}"
178199
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
179200
exit 1
180201
fi
181202
182-
# Compute the actual checksum
203+
# Compute actual checksum
183204
actual_checksum=$(sha256sum "${platform_filename}" | awk '{print $1}')
184205
185-
# Compare checksums
206+
# Perform verification by comparing expected and actual checksums
186207
if [ "$expected_checksum" != "$actual_checksum" ]; then
187208
echo "Checksum verification failed (Linux)."
188209
echo "Expected: $expected_checksum"

0 commit comments

Comments
 (0)