-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__test-action-parse-ci-reports.yml
More file actions
124 lines (110 loc) · 4.29 KB
/
Copy path__test-action-parse-ci-reports.yml
File metadata and controls
124 lines (110 loc) · 4.29 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Internal - Tests for parse-ci-reports action
on:
workflow_call:
permissions:
contents: read
jobs:
continuous-integration:
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@df348077afa4e79725151d50606e9dc63f86dcb6 # 0.24.4
permissions:
contents: read
id-token: write
packages: read
pull-requests: write
security-events: write
with:
working-directory: ./actions/parse-ci-reports
build: null
lint: null
test: '{ "coverage": null }'
integration-tests:
name: Tests for parse-ci-reports action
runs-on: ubuntu-latest
steps:
- name: Arrange - Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Arrange - Create test report files
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { mkdirSync, writeFileSync } = require('node:fs');
mkdirSync('test-reports', { recursive: true });
writeFileSync(
'test-reports/junit.xml',
[
'<?xml version="1.0" encoding="UTF-8"?>',
'<testsuite name="Test Suite" tests="3" failures="0" errors="0" skipped="0" time="1.234">',
' <testcase name="test_example_1" classname="TestClass" time="0.123"/>',
' <testcase name="test_example_2" classname="TestClass" time="0.456"/>',
' <testcase name="test_example_3" classname="TestClass" time="0.655"/>',
'</testsuite>',
'',
].join('\n')
);
writeFileSync(
'test-reports/lcov.info',
[
'TN:',
'SF:src/example.js',
'FN:1,exampleFunction',
'FNDA:5,exampleFunction',
'FNF:1',
'FNH:1',
'DA:1,5',
'DA:2,5',
'DA:3,5',
'LF:3',
'LH:3',
'end_of_record',
'',
].join('\n')
);
writeFileSync(
'test-reports/eslint.json',
[
'[',
' {',
' "filePath": "src/example.js",',
' "messages": [],',
' "errorCount": 0,',
' "warningCount": 0',
' }',
']',
'',
].join('\n')
);
core.info('Created test report files under test-reports');
- name: Act - Run parse-ci-reports action
id: parse-ci-reports
uses: ./actions/parse-ci-reports
with:
report-paths: |
test-reports/junit.xml
test-reports/lcov.info
test-reports/eslint.json
report-name: "Test Reports"
output-format: "summary,markdown"
- name: Assert - Check parse-ci-reports outputs
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
STEPS_PARSE_CI_REPORTS_OUTPUTS_MARKDOWN: ${{ steps.parse-ci-reports.outputs.markdown }}
STEPS_PARSE_CI_REPORTS_OUTPUTS_SUMMARY: ${{ steps.parse-ci-reports.outputs.summary }}
STEPS_PARSE_CI_REPORTS_OUTPUTS_PARSED_FILES: ${{ steps.parse-ci-reports.outputs.parsed-files }}
with:
script: |
const assert = require('node:assert/strict');
const markdown = process.env.STEPS_PARSE_CI_REPORTS_OUTPUTS_MARKDOWN;
const summary = process.env.STEPS_PARSE_CI_REPORTS_OUTPUTS_SUMMARY;
const parsedFiles = process.env.STEPS_PARSE_CI_REPORTS_OUTPUTS_PARSED_FILES;
try {
assert.ok(markdown && markdown.length > 0, 'parse-ci-reports markdown output is empty');
assert.ok(summary && summary.length > 0, 'parse-ci-reports summary output is empty');
assert.ok(parsedFiles && parsedFiles.length > 0, 'parse-ci-reports parsed-files output is empty');
JSON.parse(parsedFiles);
} catch (error) {
core.setFailed(error.message);
return;
}
core.info('All outputs are valid');