Skip to content

Commit 2a6ece6

Browse files
committed
Add a workflow that tests the action.
1 parent 8ef9a56 commit 2a6ece6

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

Diff for: .github/workflows/test.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Test GitHub Action
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test-action:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
action: [install, report, done]
18+
fail_on_error: [true, false]
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set up environment
24+
if: matrix.os == 'ubuntu-latest'
25+
shell: bash
26+
run: |
27+
echo "Running on Linux"
28+
- name: Set up environment
29+
if: matrix.os == 'macos-latest'
30+
shell: bash
31+
run: |
32+
echo "Running on macOS"
33+
- name: Set up environment
34+
if: matrix.os == 'windows-latest'
35+
shell: pwsh
36+
run: |
37+
echo "Running on Windows"
38+
39+
- name: Run Test Action
40+
uses: ./
41+
with:
42+
github-token: ${{ secrets.GITHUB_TOKEN }}
43+
fail-on-error: ${{ matrix.fail_on_error }}
44+
debug: true
45+
env:
46+
CI: true
47+
48+
- name: Simulate Failure Scenarios
49+
if: ${{ matrix.action == 'install' }}
50+
shell: ${{ startsWith(matrix.os, 'windows') && 'pwsh' || 'bash' }}
51+
run: |
52+
# Fail download step intentionally
53+
echo "Testing download failure scenario"
54+
exit 1 # Simulate download failure
55+
56+
- name: Simulate Report Command Failure
57+
if: ${{ matrix.action == 'report' }}
58+
shell: ${{ startsWith(matrix.os, 'windows') && 'pwsh' || 'bash' }}
59+
run: |
60+
echo "Testing report command failure"
61+
~/bin/coveralls report # Simulated failure
62+
63+
- name: Simulate Done Command Failure
64+
if: ${{ matrix.action == 'done' }}
65+
shell: ${{ startsWith(matrix.os, 'windows') && 'pwsh' || 'bash' }}
66+
run: |
67+
echo "Testing done command failure"
68+
~/bin/coveralls done # Simulated failure
69+
70+
- name: Verify Outcome
71+
shell: ${{ startsWith(matrix.os, 'windows') && 'pwsh' || 'bash' }}
72+
run: |
73+
if [[ "${{ matrix.fail_on_error }}" == "true" ]]; then
74+
# Expect failure exit code
75+
if [[ $? -eq 0 ]]; then
76+
echo "Test failed: expected failure but action succeeded."
77+
exit 1
78+
else
79+
echo "Test succeeded: expected failure and action failed as expected."
80+
fi
81+
else
82+
# Expect success exit code
83+
if [[ $? -ne 0 ]]; then
84+
echo "Test failed: expected success but action failed."
85+
exit 1
86+
else
87+
echo "Test succeeded: expected success and action succeeded."
88+
fi
89+
fi

0 commit comments

Comments
 (0)