-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
74 lines (64 loc) · 2.64 KB
/
tests-on-pr-report.yml
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
name: Test results
on:
workflow_run:
workflows:
- UI tests
types:
- completed
jobs:
test-results:
name: Test Results
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'skipped' }}
permissions:
checks: write
# for commenting the test results
pull-requests: write
# for using the artifacts API
actions: read
steps:
- name: Download the tests results artifacts
id: results
uses: actions/github-script@v7
with:
script: |
const { readFile, writeFile, unlink } = require('node:fs/promises');
const { resolve } = require('node:path');
const __dirname = process.env.GITHUB_WORKSPACE;
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const resultArtifacts = artifacts.filter(({ name }) => name.startsWith('test-results'));
for (const artifact of resultArtifacts) {
const { data: artifactData } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
const zipPath = resolve(__dirname, './test-results.zip');
await writeFile(zipPath, Buffer.from(artifactData));
await exec.exec('unzip', [zipPath, '-d', './test-results']);
await unlink(zipPath);
}
const eventDataArtifact = artifacts.find(({ name }) => name === 'event-data');
const { data: eventDataArtifactData } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: eventDataArtifact.id,
archive_format: 'zip',
});
const eventDataZipPath = resolve(__dirname, './event-data.zip');
await writeFile(eventDataZipPath, Buffer.from(eventDataArtifactData));
await exec.exec('unzip', [eventDataZipPath, '-d', './event-data']);
await unlink(eventDataZipPath);
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event-data/event.json
event_name: ${{ github.event.workflow_run.event }}
files: 'test-results/*.xml'
check_name: 'UI Tests Results'