|
1 |
| -name: Test GitHub Action |
| 1 | +name: Test Modified GitHub Action Steps |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
|
9 | 9 | - main
|
10 | 10 |
|
11 | 11 | jobs:
|
12 |
| - test-action: |
13 |
| - runs-on: ${{ matrix.os }} |
| 12 | + test-modified-steps: |
| 13 | + runs-on: ubuntu-latest |
14 | 14 | strategy:
|
15 | 15 | matrix:
|
16 |
| - os: [ubuntu-latest, windows-latest, macos-latest] |
17 |
| - action: [install, report, done] |
| 16 | + step: [download, report, done] |
18 | 17 | fail_on_error: [true, false]
|
19 | 18 | steps:
|
20 | 19 | - name: Checkout code
|
21 | 20 | uses: actions/checkout@v3
|
22 | 21 |
|
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' }} |
25 | 25 | shell: bash
|
26 | 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-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" |
55 | 29 |
|
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." |
62 | 38 |
|
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 |
66 | 43 | 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." |
69 | 55 |
|
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 |
72 | 60 | 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 |
89 | 65 | 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