Skip to content

Extend behavior of fail-on-error option to setup failures #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8ef9a56
Add logic to check download, verification and existence of coveralls …
afinetooth Oct 8, 2024
2a6ece6
Add a workflow that tests the action.
afinetooth Oct 9, 2024
720879c
Tweak syntax in response to error.
afinetooth Oct 9, 2024
07136b0
Tweak syntax in response to error.
afinetooth Oct 9, 2024
c25ea5c
Modify workflow that tests the action.
afinetooth Oct 9, 2024
6635afa
Modify workflow that tests the action.
afinetooth Oct 10, 2024
8c75162
Modify workflow that tests the action.
afinetooth Oct 10, 2024
a6db77a
Fix call to binary, given that ~/bin/ is in PATH.
afinetooth Oct 10, 2024
f656bbb
Modify code per linter.
afinetooth Oct 10, 2024
31f3859
Fix syntax error.
afinetooth Oct 10, 2024
0d6d860
Fix syntax error.
afinetooth Oct 10, 2024
d3af382
Add debug statements to understand error.
afinetooth Oct 10, 2024
83ff3df
Fix syntax error.
afinetooth Oct 10, 2024
9f5d3d9
Fix syntax error.
afinetooth Oct 10, 2024
79d722b
Fix syntax error.
afinetooth Oct 10, 2024
2b49c81
Fix syntax error.
afinetooth Oct 10, 2024
a722a85
Comment out still-problematic sections of workflow.
afinetooth Oct 10, 2024
e3a746a
Tweak debugging.
afinetooth Oct 10, 2024
1f4e104
Add continue-on-error to let step pass when fail-on-erroris true.
afinetooth Oct 10, 2024
4061f15
Remove the code the verifies the existence of the binary to each OS-s…
afinetooth Oct 10, 2024
0926305
Fix macos issue given different homebrew install locations across dif…
afinetooth Oct 10, 2024
45b61bf
Remove install action. Not needed because it's implicit in both repor…
afinetooth Oct 10, 2024
913318b
Add code to enable debugging in setup steps on each OS when the debug…
afinetooth Oct 10, 2024
772d865
Change debug enablement on Windows / pwsh.
afinetooth Oct 10, 2024
1b3b28a
Step back Windows pwsh debugging from to .
afinetooth Oct 10, 2024
63cbc6d
Fix error by adding back key, which was mistakenly removed in a prev…
afinetooth Oct 10, 2024
bb6c0c4
Start reducing manual debugging lines. Make pwsh debugging option mor…
afinetooth Oct 10, 2024
23b7fa1
Further remove manually added debugging lines to rely solely on shell…
afinetooth Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test GitHub Action

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-action:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
action: [report, done] # Note: We're also testing 'install' since it's implicitly in each of these two actions
fail_on_error: [true, false]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up environment (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
echo "Running on Linux"
- name: Set up environment (MacOS)
if: ${{ matrix.os == 'macos-latest' }}
shell: bash
run: |
echo "Running on macOS"
- name: Set up environment (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
echo "Running on Windows"

- name: Run Test Action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: ${{ matrix.fail_on_error }}
debug: true
parallel-finished: ${{ matrix.action == 'done' }} # Only set 'parallel-finished' to true when testing 'done'
env:
CI: true
continue-on-error: ${{ matrix.fail_on_error }}
80 changes: 69 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# action.yml
name: 'Coveralls GitHub Action'
description: 'Send test coverage data to Coveralls.io for analysis, change tracking, and notifications.'
author: 'Nick Merwin (Coveralls, Inc.)'
author: Coveralls.io
inputs:
github-token:
description: 'Put secrets.GITHUB_TOKEN here'
Expand Down Expand Up @@ -80,14 +80,28 @@ runs:
if: runner.os == 'macOS'
shell: bash
run: |
# Enable debugging if 'debug' is true
[ "${{ inputs.debug }}" == "true" ] && set -x

# Try to install coverage-reporter via Homebrew
brew tap coverallsapp/coveralls --quiet
brew install coveralls --quiet

- name: Report coverage-reporter-version information for macOS
# Check if the binary exists in the possible locations
if [ -f /usr/local/bin/coveralls ]; then
echo "/usr/local/bin" >> $GITHUB_PATH
elif [ -f /opt/homebrew/bin/coveralls ]; then
echo "/opt/homebrew/bin" >> $GITHUB_PATH
else
echo "Coveralls binary not found after installation (MacOS)."
exit 1
fi

- name: Report coverage-reporter-version exception for macOS
if: ${{ runner.os == 'macOS' && inputs.coverage-reporter-version != 'latest' }}
shell: bash
run: |
echo "The coverage-reporter-version parameter is not available on macOS" >&2
echo "The coverage-reporter-version parameter is not available on macOS." >&2
exit 1

- name: Install coveralls reporter (Linux)
Expand All @@ -96,18 +110,43 @@ runs:
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
shell: bash
run: |
# Enable debugging if 'debug' is true
[ "${{ inputs.debug }}" == "true" ] && set -x

mkdir -p ~/bin/
cd ~/bin/
if [ $COVERAGE_REPORTER_VERSION == "latest" ]
then
asset_path=latest/download

# Determine which version of coverage-reporter to download
if [ "$COVERAGE_REPORTER_VERSION" == "latest" ]; then
asset_path="latest/download"
else
asset_path="download/${COVERAGE_REPORTER_VERSION}"
fi
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz"
curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"
cat coveralls-checksums.txt | grep coveralls-linux.tar.gz | sha256sum --check

# Try to download the binary and checksum file
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz" ||
! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt"; then
echo "Failed to download coveralls binary or checksum (Linux)."
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
exit 1
fi

# Try to verify the downloaded binary
if ! grep coveralls-linux.tar.gz coveralls-checksums.txt | sha256sum --check; then
echo "Checksum verification failed (Linux)."
[ "${{ inputs.fail-on-error }}" == "false" ] && exit 0
exit 1
fi

tar -xzf coveralls-linux.tar.gz

# Check if the binary exists
if [ ! -f ~/bin/coveralls ]; then
echo "Coveralls binary not found after extraction (Linux)."
exit 1
fi

# Cleanup
rm coveralls-checksums.txt
echo ~/bin >> $GITHUB_PATH

Expand All @@ -117,6 +156,12 @@ runs:
COVERAGE_REPORTER_VERSION: ${{ inputs.coverage-reporter-version }}
shell: pwsh
run: |
# Enable debugging if 'debug' is true
if ("${{ inputs.debug }}" -eq "true") {
Set-PSDebug -Trace 1
}

# Try to download the binary and checksum file
New-Item -Path $env:HOME\bin -ItemType directory -Force
Push-Location $env:HOME\bin
if($env:COVERAGE_REPORTER_VERSION -eq "latest") {
Expand All @@ -126,8 +171,21 @@ runs:
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-windows.exe" -OutFile "coveralls.exe"
Invoke-WebRequest -Uri "https://github.com/coverallsapp/coverage-reporter/releases/download/$env:COVERAGE_REPORTER_VERSION/coveralls-checksums.txt" -OutFile "sha256sums.txt"
}
(Get-FileHash coveralls.exe).Hash -eq (Get-Content ./sha256sums.txt | Where-Object{$_ -match 'windows.exe'} | ForEach-Object{($_ -split "\s+")[0]})
Remove-Item *.txt -Force

# Try to verify the downloaded binary
if ((Get-FileHash coveralls.exe).Hash -ne (Get-Content sha256sums.txt | Select-String 'windows.exe' | ForEach-Object { ($_ -split "\s+")[0] })) {
Write-Host "Checksum verification failed (Windows)."
exit 1
}

# Check if the binary exists
if (!(Test-Path -Path "$env:HOME\bin\coveralls.exe")) {
Write-Host "Coveralls binary not found after download and verification (Windows)."
exit 1
}

# Cleanup
Remove-Item sha256sums.txt -Force
echo $env:HOME\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Done report
Expand Down
Loading