coverallsapp / coverallsapp/github-action

`grep` failure handling is lousy

Open
#255 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
520
Forks
78
PR merge metrics
No merged PRs in 30d

Description

https://github.com/coverallsapp/github-action/blob/ba6dae83310bbd6d33ff77092650dc40bd444a2a/action.yml#L199-L208

https://github.com/PowerDNS/pdns/actions/runs/19634781529/job/56223536933


2025-11-24T12:56:40.8466822Z ##[group]Run # Enable debugging if 'debug' is true
2025-11-24T12:56:40.8467217Z # Enable debugging if 'debug' is true
2025-11-24T12:56:40.8467494Z [ "false" == "true" ] && set -x
2025-11-24T12:56:40.8467733Z 
2025-11-24T12:56:40.8467911Z mkdir -p ~/bin/
2025-11-24T12:56:40.8468111Z cd ~/bin/
2025-11-24T12:56:40.8468288Z 
2025-11-24T12:56:40.8468539Z # Determine which version of coverage-reporter to download
2025-11-24T12:56:40.8469011Z if [ -z "$COVERAGE_REPORTER_VERSION" ] || [ "$COVERAGE_REPORTER_VERSION" == "latest" ]; then
2025-11-24T12:56:40.8469411Z   asset_path="latest/download"
2025-11-24T12:56:40.8469659Z   version_message="latest"
2025-11-24T12:56:40.8469875Z else
2025-11-24T12:56:40.8470103Z   asset_path="download/${COVERAGE_REPORTER_VERSION}"
2025-11-24T12:56:40.8470433Z   version_message="$COVERAGE_REPORTER_VERSION"
2025-11-24T12:56:40.8470695Z fi
2025-11-24T12:56:40.8470848Z 
2025-11-24T12:56:40.8471035Z # Function to compare version numbers
2025-11-24T12:56:40.8471286Z version_ge() {
2025-11-24T12:56:40.8471501Z   # Compare two version numbers
2025-11-24T12:56:40.8471787Z   [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]
2025-11-24T12:56:40.8472055Z }
2025-11-24T12:56:40.8472211Z 
2025-11-24T12:56:40.8472411Z # Determine the platform-specific filename:
2025-11-24T12:56:40.8472892Z # This logic is necessary due to the introduction of multiple platform support starting from v0.6.15.
2025-11-24T12:56:40.8473646Z # It selects the correct filename based on the specified platform and version, while ensuring
2025-11-24T12:56:40.8474235Z # backward compatibility with earlier versions that only supported a generic Linux binary for x86_64.
2025-11-24T12:56:40.8475078Z if [ -z "$COVERAGE_REPORTER_PLATFORM" ] || [ "$COVERAGE_REPORTER_PLATFORM" == "auto-detect" ]; then
2025-11-24T12:56:40.8475511Z   COVERAGE_REPORTER_PLATFORM="$(uname -m)"
2025-11-24T12:56:40.8475762Z fi
2025-11-24T12:56:40.8475953Z case "$COVERAGE_REPORTER_PLATFORM" in
2025-11-24T12:56:40.8476199Z   x86_64|"")
2025-11-24T12:56:40.8476457Z     if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
2025-11-24T12:56:40.8476818Z       platform_filename="coveralls-linux-x86_64.tar.gz"
2025-11-24T12:56:40.8477096Z     else
2025-11-24T12:56:40.8477492Z       platform_filename="coveralls-linux.tar.gz"
2025-11-24T12:56:40.8477766Z     fi
2025-11-24T12:56:40.8477931Z     ;;
2025-11-24T12:56:40.8478103Z   aarch64|arm64)
2025-11-24T12:56:40.8478368Z     if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
2025-11-24T12:56:40.8478725Z       platform_filename="coveralls-linux-aarch64.tar.gz"
2025-11-24T12:56:40.8479012Z     else
2025-11-24T12:56:40.8479434Z       echo "Warning: The aarch64/arm64 platform is only supported from version v0.6.15 onwards. Proceeding with v0.6.15." >&2
2025-11-24T12:56:40.8479933Z       asset_path="download/v0.6.15"
2025-11-24T12:56:40.8480238Z       platform_filename="coveralls-linux-aarch64.tar.gz"
2025-11-24T12:56:40.8480521Z     fi
2025-11-24T12:56:40.8480690Z     ;;
2025-11-24T12:56:40.8480846Z   *)
2025-11-24T12:56:40.8481309Z     echo "Warning: Unsupported platform: $COVERAGE_REPORTER_PLATFORM. The default x86_64 version ($version_message) will be used." >&2
2025-11-24T12:56:40.8481887Z     if version_ge "$COVERAGE_REPORTER_VERSION" "v0.6.15"; then
2025-11-24T12:56:40.8482242Z       platform_filename="coveralls-linux-x86_64.tar.gz"
2025-11-24T12:56:40.8482513Z     else
2025-11-24T12:56:40.8482731Z       platform_filename="coveralls-linux.tar.gz"
2025-11-24T12:56:40.8482992Z     fi
2025-11-24T12:56:40.8483145Z     ;;
2025-11-24T12:56:40.8483307Z esac
2025-11-24T12:56:40.8483467Z 
2025-11-24T12:56:40.8483634Z # Checksum verification:
2025-11-24T12:56:40.8484025Z # The following code was chosen to replace the more simple `sha256sum -c` because it provides
2025-11-24T12:56:40.8484781Z # clearer debugging information around our new matrix of supported coverage-reporter versions and platforms.
2025-11-24T12:56:40.8485508Z # We may drop back to `${platform_filename}" coveralls-checksums.txt | sha256sum -c` when we're more confidently handling these.
2025-11-24T12:56:40.8485992Z 
2025-11-24T12:56:40.8486188Z # Try to download the binary and checksum file
2025-11-24T12:56:40.8486725Z if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/${platform_filename}" ||
2025-11-24T12:56:40.8487466Z   ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
2025-11-24T12:56:40.8488047Z   echo "Failed to download coveralls binary or checksum (Linux)."
2025-11-24T12:56:40.8488374Z   [ "false" == "false" ] && exit 0
2025-11-24T12:56:40.8488603Z   exit 1
2025-11-24T12:56:40.8488773Z fi
2025-11-24T12:56:40.8488922Z 
2025-11-24T12:56:40.8489145Z # DEBUG: Print contents of checksum file for debugging
2025-11-24T12:56:40.8489483Z echo "Contents of coveralls-checksums.txt:"
2025-11-24T12:56:40.8489907Z cat coveralls-checksums.txt
2025-11-24T12:56:40.8490137Z 
2025-11-24T12:56:40.8490310Z # Extract expected checksum
2025-11-24T12:56:40.8490714Z expected_checksum=$(grep "${platform_filename}" coveralls-checksums.txt | awk '{print $1}')
2025-11-24T12:56:40.8491138Z if [ -z "$expected_checksum" ]; then
2025-11-24T12:56:40.8491465Z   echo "Failed to extract checksum for ${platform_filename}"
2025-11-24T12:56:40.8491782Z   [ "false" == "false" ] && exit 0
2025-11-24T12:56:40.8492010Z   exit 1
2025-11-24T12:56:40.8492183Z fi
2025-11-24T12:56:40.8492346Z 
2025-11-24T12:56:40.8492514Z # Compute actual checksum
2025-11-24T12:56:40.8492856Z actual_checksum=$(sha256sum "${platform_filename}" | awk '{print $1}')
2025-11-24T12:56:40.8493187Z 
2025-11-24T12:56:40.8493572Z # Perform verification by comparing expected and actual checksums
2025-11-24T12:56:40.8493982Z if [ "$expected_checksum" != "$actual_checksum" ]; then
2025-11-24T12:56:40.8494314Z   echo "Checksum verification failed (Linux)."
2025-11-24T12:56:40.8494716Z   echo "Expected: $expected_checksum"
2025-11-24T12:56:40.8494978Z   echo "Actual: $actual_checksum"
2025-11-24T12:56:40.8495230Z   [ "false" == "false" ] && exit 0
2025-11-24T12:56:40.8495458Z   exit 1
2025-11-24T12:56:40.8495627Z fi
2025-11-24T12:56:40.8495777Z 
2025-11-24T12:56:40.8495957Z tar -xzf "${platform_filename}"
2025-11-24T12:56:40.8496188Z 
2025-11-24T12:56:40.8496352Z # Check if the binary exists
2025-11-24T12:56:40.8496600Z if [ ! -f ~/bin/coveralls ]; then
2025-11-24T12:56:40.8496916Z   echo "Coveralls binary not found after extraction (Linux)."
2025-11-24T12:56:40.8497231Z   [ "false" == "false" ] && exit 0
2025-11-24T12:56:40.8497469Z   exit 1
2025-11-24T12:56:40.8497638Z fi
2025-11-24T12:56:40.8497786Z 
2025-11-24T12:56:40.8497942Z # Cleanup
2025-11-24T12:56:40.8498143Z rm coveralls-checksums.txt
2025-11-24T12:56:40.8498387Z echo ~/bin >> $GITHUB_PATH
2025-11-24T12:56:40.8500465Z shell: bash --noprofile --norc -e -o pipefail {0}
2025-11-24T12:56:40.8500801Z env:
2025-11-24T12:56:40.8501086Z   COMPILER: clang
2025-11-24T12:56:40.8501359Z   CLANG_VERSION: 13
2025-11-24T12:56:40.8501679Z   REPO_HOME: /__w/pdns/pdns
2025-11-24T12:56:40.8501937Z   BUILDER_VERSION: 0.0.0-git1
2025-11-24T12:56:40.8502142Z   COVERAGE: yes
2025-11-24T12:56:40.8502344Z   LLVM_PROFILE_FILE: /tmp/code-%p.profraw
2025-11-24T12:56:40.8502593Z   OPTIMIZATIONS: yes
2025-11-24T12:56:40.8502807Z   INV_CMD: . ${REPO_HOME}/.venv/bin/activate && inv
2025-11-24T12:56:40.8503067Z   BRANCH_NAME: 16349/merge
2025-11-24T12:56:40.8503287Z   normalized-branch-name: 16349-merge
2025-11-24T12:56:40.8503546Z   COVERAGE_REPORTER_VERSION: latest
2025-11-24T12:56:40.8503791Z   COVERAGE_REPORTER_PLATFORM: auto-detect
2025-11-24T12:56:40.8504027Z ##[endgroup]
2025-11-24T12:56:48.8687981Z Contents of coveralls-checksums.txt:
2025-11-24T12:56:48.8695954Z <!DOCTYPE html>
2025-11-24T12:56:48.8696266Z <!--
2025-11-24T12:56:48.8696432Z 
2025-11-24T12:56:48.8696791Z Hello future GitHubber! I bet you're here to remove those nasty inline styles,
2025-11-24T12:56:48.8697541Z DRY up these templates and make 'em nice and re-usable, right?
2025-11-24T12:56:48.8697960Z 
2025-11-24T12:56:48.8698220Z Please, don't. https://github.com/styleguide/templates/2.0
2025-11-24T12:56:48.8698590Z 
2025-11-24T12:56:48.8698698Z -->
2025-11-24T12:56:48.8698951Z <html>
2025-11-24T12:56:48.8699204Z   <head>
2025-11-24T12:56:48.8699520Z     <title>Unicorn! &middot; GitHub</title>
...
2025-11-24T12:56:48.9307319Z </html>
2025-11-24T12:56:48.9317831Z ##[error]Process completed with exit code 1.

The code ran:

         expected_checksum=$(grep "${platform_filename}" coveralls-checksums.txt | awk '{print $1}') 

But, the grep failed because the file was broken, and thus it never reached this failure handling code:

         if [ -z "$expected_checksum" ]; then 
           echo "Failed to extract checksum for ${platform_filename}" 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in action.yml at lines 199-208 and inspect the grep/awk checksum extraction under the bash shell shown in the linked workflow log. Exercise the path with a malformed coveralls-checksums.txt response; done means the extraction failure reaches the existing explicit checksum error handling instead of terminating at grep.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, shell
Domain
ci-cd
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.