Skip to content

Commit 22d5073

Browse files
committed
ci/cd: add real action test
1 parent b9c2a6e commit 22d5073

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

.github/workflows/test.yml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,51 @@ jobs:
2727
working-directory: ./test-project
2828
run: npm install
2929

30-
- name: Run all tests
31-
run: npm test
30+
- name: Run Jest tests
31+
run: npm test
32+
33+
# Test the actual GitHub Action
34+
- name: Test action - should find errors and fail
35+
id: test-fail
36+
uses: ./
37+
continue-on-error: true
38+
with:
39+
working-directory: './test-project'
40+
fail-on-warnings: false
41+
fail-on-hints: false
42+
43+
- name: Verify action found errors
44+
run: |
45+
echo "Action outcome: ${{ steps.test-fail.outcome }}"
46+
echo "Errors found: ${{ steps.test-fail.outputs.errors }}"
47+
echo "Warnings found: ${{ steps.test-fail.outputs.warnings }}"
48+
echo "Hints found: ${{ steps.test-fail.outputs.hints }}"
49+
50+
if [ "${{ steps.test-fail.outcome }}" != "failure" ]; then
51+
echo "❌ Expected action to fail due to errors"
52+
exit 1
53+
fi
54+
55+
if [ "${{ steps.test-fail.outputs.errors }}" -eq "0" ]; then
56+
echo "❌ Expected to find TypeScript errors"
57+
exit 1
58+
fi
59+
60+
echo "✅ Action correctly failed with ${{ steps.test-fail.outputs.errors }} errors"
61+
62+
- name: Test action - should fail on warnings when enabled
63+
id: test-warnings
64+
uses: ./
65+
continue-on-error: true
66+
with:
67+
working-directory: './test-project'
68+
fail-on-warnings: true
69+
fail-on-hints: false
70+
71+
- name: Verify action failed on warnings
72+
run: |
73+
if [ "${{ steps.test-warnings.outcome }}" != "failure" ]; then
74+
echo "❌ Expected action to fail on warnings"
75+
exit 1
76+
fi
77+
echo "✅ Action correctly failed when fail-on-warnings enabled"

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ async function run(): Promise<void> {
4040

4141
core.info(`svelte-check exit code: ${exitCode}`);
4242

43-
const errorCount = (output.match(/^Error:/gm) || []).length;
44-
const warningCount = (output.match(/^Warning:/gm) || []).length;
45-
const hintCount = (output.match(/^Hint:/gm) || []).length;
43+
const errorCount = (output.match(/Error:/g) || []).length;
44+
const warningCount = (output.match(/Warning:/g) || []).length;
45+
const hintCount = (output.match(/Hint:/g) || []).length;
4646

4747
core.setOutput('errors', errorCount.toString());
4848
core.setOutput('warnings', warningCount.toString());

0 commit comments

Comments
 (0)