Skip to content

Commit 1007579

Browse files
committed
test: ✅ Tests to see if the setup command fails in the build script
checks to see if the setup command fails by not cloning the test repository (currently the kernel)
1 parent fd2fbe3 commit 1007579

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

.github/workflows/build-image.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ jobs:
113113
repository: ["ZestCommunity/ZestCode"]
114114
ref: ["main"]
115115
caller_token: ["${{ github.token }}"]
116+
clone_repo: [true, false] # false tests setup command
117+
expect_error: [false, true]
118+
exclude:
119+
# We only really need to test if the action fails the setup command in one case
120+
- write_job_summary: false
121+
clone_repo: false
122+
116123
with:
117124
write_job_summary: ${{ matrix.write_job_summary }}
118125
repository: ${{ matrix.repository }}

.github/workflows/test.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,28 @@ on:
1818
description: Whether to write the artifact URL to the job summary
1919
default: true
2020
type: boolean
21+
clone_repo:
22+
description: Whether to clone the repo
23+
default: true
24+
type: boolean
25+
expect_error:
26+
description: Whether to expect an error
27+
default: false
28+
type: boolean
2129

2230
jobs:
2331
test:
2432
name: "Testing Container: Write Job Summary?${{ inputs.write_job_summary }}"
2533
runs-on: ubuntu-latest
2634
steps:
27-
- name: Checkout
35+
- name: Checkout Repository to Test
2836
uses: actions/checkout@v4
37+
if: ${{ inputs.clone_repo }}
2938
with:
3039
repository: ${{ inputs.repository }}
3140
ref: ${{ inputs.ref }}
3241

33-
- name: Checkout
42+
- name: Checkout Action
3443
uses: actions/checkout@v4
3544
with:
3645
path: ./action/
@@ -55,6 +64,16 @@ jobs:
5564
- name: Test Action
5665
id: test-action
5766
uses: ./action/
58-
continue-on-error: False
67+
continue-on-error: ${{ inputs.expect_error }}
5968
with:
6069
write_job_summary: ${{ inputs.write_job_summary }}
70+
71+
- name: Check for Failure If Expected
72+
if: ${{ inputs.expect_error }}
73+
run: |
74+
if [ "${{ (steps.test-action.outcome == 'success') }}" == "true" ]; then
75+
echo "Test Action step succeeded when it was expected to fail. Failing job.."
76+
exit 1
77+
else
78+
echo "Test Action step failed as expected."
79+
fi

0 commit comments

Comments
 (0)