Repository navigation
Expand file tree
/
Copy path__test-action-parse-ci-reports.yml
More file actions
65 lines (65 loc) · 2.48 KB
/
Copy path__test-action-parse-ci-reports.yml
File metadata and controls
65 lines (65 loc) · 2.48 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
---
name: Internal - Test parse-ci-reports action
"on":
workflow_call: null
permissions: {}
jobs:
reports:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
outputs:
artifact-id: ${{ steps.report.outputs.artifact-id }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Assert - Action contract tests pass
uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
with:
command: test:ci
arguments: '[".github/actions/parse-ci-reports/action.test.cjs"]'
coverage: ""
comment: "false"
- name: Arrange - Empty report directory
run: mkdir -p "$RUNNER_TEMP/empty-reports"
- name: Act - Retain no reports
id: empty
uses: $/.github/actions/parse-ci-reports
with:
directory: ${{ runner.temp }}/empty-reports
group: reports
- name: Assert - No empty artifact is created
env:
ARTIFACT: ${{ steps.empty.outputs.artifact-id }}
run: test -z "$ARTIFACT"
- name: Arrange - One report and an unrelated private file
run: |
mkdir -p "$RUNNER_TEMP/report-fixture"
printf '%s\n' '<testsuites tests="1"><testsuite name="fixture" tests="1"><testcase name="passes"/></testsuite></testsuites>' > "$RUNNER_TEMP/report-fixture/junit.xml"
printf '%s\n' 'not a report' > "$RUNNER_TEMP/report-fixture/private.txt"
- name: Act - Retain the selected report
id: report
uses: $/.github/actions/parse-ci-reports
with:
directory: ${{ runner.temp }}/report-fixture
group: reports
report-paths: junit.xml
verify:
needs: reports
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Assert - Artifact can be downloaded
uses: hoverkraft-tech/ci-github-common/actions/download-artifact@af0bdd6313bd49aaf4a8a7f0de005fb0db856b03 # 4.3.3
with:
artifact-ids: ${{ needs.reports.outputs.artifact-id }}
path: ${{ runner.temp }}/downloaded-reports
- name: Assert - Only the selected file was retained
run: |
test -f "$RUNNER_TEMP/downloaded-reports/junit.xml"
test ! -e "$RUNNER_TEMP/downloaded-reports/private.txt"
test "$(find "$RUNNER_TEMP/downloaded-reports" -type f | wc -l)" -eq 1