Skip to content

Commit c25ea5c

Browse files
committed
Modify workflow that tests the action.
1 parent 07136b0 commit c25ea5c

File tree

1 file changed

+46
-64
lines changed

1 file changed

+46
-64
lines changed

Diff for: .github/workflows/test.yml

+46-64
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test GitHub Action
1+
name: Test Modified GitHub Action Steps
22

33
on:
44
push:
@@ -9,81 +9,63 @@ on:
99
- main
1010

1111
jobs:
12-
test-action:
13-
runs-on: ${{ matrix.os }}
12+
test-modified-steps:
13+
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macos-latest]
17-
action: [install, report, done]
16+
step: [download, report, done]
1817
fail_on_error: [true, false]
1918
steps:
2019
- name: Checkout code
2120
uses: actions/checkout@v3
2221

23-
- name: Set up environment
24-
if: ${{ matrix.os == 'ubuntu-latest' }}
22+
# Test Download & Verification Step
23+
- name: Test Download & Verification
24+
if: ${{ matrix.step == 'download' }}
2525
shell: bash
2626
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-latest') && 'pwsh' || 'bash' }}
51-
run: |
52-
# Fail download step intentionally
53-
echo "Testing download failure scenario"
54-
exit 1 # Simulate download failure
27+
echo "Testing Download & Verification"
28+
asset_path="latest/download"
5529
56-
- name: Simulate Report Command Failure
57-
if: ${{ matrix.action == 'report' }}
58-
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
59-
run: |
60-
echo "Testing report command failure"
61-
~/bin/coveralls report # Simulated failure
30+
# Simulate download and verification failure scenario
31+
if ! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-linux.tar.gz" ||
32+
! curl -sLO "https://github.com/coverallsapp/coverage-reporter/releases/${asset_path}/coveralls-checksums.txt" ||
33+
! grep coveralls-linux.tar.gz coveralls-checksums.txt | sha256sum --check; then
34+
echo "Download or verification failed."
35+
if [ "${{ matrix.fail_on_error }}" == "false" ]; then exit 0; else exit 1; fi
36+
fi
37+
echo "Download & verification succeeded."
6238
63-
- name: Simulate Done Command Failure
64-
if: ${{ matrix.action == 'done' }}
65-
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
39+
# Test Coveralls Report Step
40+
- name: Test Coveralls Report
41+
if: ${{ matrix.step == 'report' }}
42+
shell: bash
6643
run: |
67-
echo "Testing done command failure"
68-
~/bin/coveralls done # Simulated failure
44+
echo "Testing Coveralls Report Step"
45+
if [ ! -f ~/bin/coveralls ]; then
46+
echo "Coveralls binary not found."
47+
if [ "${{ matrix.fail_on_error }}" == "false" ]; then exit 0; else exit 1; fi
48+
fi
49+
# Simulate coveralls report execution
50+
~/bin/coveralls report || {
51+
echo "Coveralls report failed."
52+
if [ "${{ matrix.fail_on_error }}" == "false" ]; then exit 0; else exit 1; fi
53+
}
54+
echo "Coveralls report succeeded."
6955
70-
- name: Verify Outcome
71-
shell: ${{ startsWith(matrix.os, 'windows-latest') && 'pwsh' || 'bash' }}
56+
# Test Coveralls Done Step
57+
- name: Test Coveralls Done
58+
if: ${{ matrix.step == 'done' }}
59+
shell: bash
7260
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
61+
echo "Testing Coveralls Done Step"
62+
if [ ! -f ~/bin/coveralls ]; then
63+
echo "Coveralls binary not found."
64+
if [ "${{ matrix.fail_on_error }}" == "false" ]; then exit 0; else exit 1; fi
8965
fi
66+
# Simulate coveralls done execution
67+
~/bin/coveralls done || {
68+
echo "Coveralls done failed."
69+
if [ "${{ matrix.fail_on_error }}" == "false" ]; then exit 0; else exit 1; fi
70+
}
71+
echo "Coveralls done succeeded."

0 commit comments

Comments
 (0)