Skip to content

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

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

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

Workflow file for this run

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: [install, report, done]
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
env:
CI: true
- name: Simulate Failure Scenarios
if: ${{ matrix.action == 'install' }}
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}

Check failure on line 50 in .github/workflows/test.yml

View workflow run for this annotation

GitHub Actions / Test GitHub Action

Invalid workflow file

The workflow is not valid. .github/workflows/test.yml (Line: 50, Col: 16): Unrecognized named-value: 'matrix'. Located at position 12 within expression: startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' .github/workflows/test.yml (Line: 58, Col: 16): Unrecognized named-value: 'matrix'. Located at position 12 within expression: startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash'
run: |
# Fail download step intentionally
echo "Testing download failure scenario"
exit 1 # Simulate download failure
- name: Simulate Report Command Failure
if: ${{ matrix.action == 'report' }}
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
run: |
echo "Testing report command failure"
~/bin/coveralls report # Simulated failure
- name: Simulate Done Command Failure
if: ${{ matrix.action == 'done' }}
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
run: |
echo "Testing done command failure"
~/bin/coveralls done # Simulated failure
- name: Verify Outcome
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
run: |
if [[ "${{ matrix.fail_on_error }}" == "true" ]]; then
# Expect failure exit code
if [[ $? -eq 0 ]]; then
echo "Test failed: expected failure but action succeeded."
exit 1
else
echo "Test succeeded: expected failure and action failed as expected."
fi
else
# Expect success exit code
if [[ $? -ne 0 ]]; then
echo "Test failed: expected success but action failed."
exit 1
else
echo "Test succeeded: expected success and action succeeded."
fi
fi