Repository navigation
75 lines (75 loc) · 2.89 KB
/
Copy path__test-action-test.yml
File metadata and controls
75 lines (75 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
name: Internal - Test test action
"on":
workflow_call: null
permissions: {}
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
outputs:
artifact-id: ${{ steps.failed-test.outputs.report-artifact-id }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
name: Arrange - Check out the repository
- name: Assert - Action contract tests pass
uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
with:
command: test:ci
arguments: '["actions/test/action.test.cjs"]'
coverage: ""
comment: "false"
- uses: $/actions/setup-python
with:
working-directory: tests/python-project
name: Arrange - Install dependencies
- id: test
uses: $/actions/test
with:
working-directory: tests/python-project
name: Act - Run default tests
- id: failed-test
continue-on-error: true
uses: $/actions/test
with:
working-directory: tests/python-project
command: |-
printf '%s' '<testsuites tests="1" failures="1"><testsuite name="failure" tests="1" failures="1"><testcase name="fails"><failure message="expected">failure</failure></testcase></testsuite></testsuites>' > junit.xml
exit 17
coverage: ""
name: Act - Run a failing test command
- name: Assert failures and reports
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
SUCCESS_ARTIFACT: ${{ steps.test.outputs.report-artifact-id }}
FAILURE_ARTIFACT: ${{ steps.failed-test.outputs.report-artifact-id }}
TEST_OUTCOME: ${{ steps.failed-test.outcome }}
with:
script: |
const assert = require('node:assert/strict');
assert.equal(process.env.TEST_OUTCOME, 'failure');
assert.ok(process.env.SUCCESS_ARTIFACT, 'Successful tests retain reports');
assert.ok(process.env.FAILURE_ARTIFACT, 'Failed tests retain reports');
assert.notEqual(process.env.SUCCESS_ARTIFACT, process.env.FAILURE_ARTIFACT);
verify:
needs: test
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: hoverkraft-tech/ci-github-common/actions/download-artifact@af0bdd6313bd49aaf4a8a7f0de005fb0db856b03 # 4.3.3
with:
artifact-ids: ${{ needs.test.outputs.artifact-id }}
path: ${{ runner.temp }}/failed-reports
- name: Verify retained failure report
shell: bash
env:
REPORT_DIRECTORY: ${{ runner.temp }}/failed-reports
run: |
test -f "$REPORT_DIRECTORY/junit.xml"
grep -q 'message="expected"' "$REPORT_DIRECTORY/junit.xml"