-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
117 lines (108 loc) · 4.44 KB
/
Copy pathaction.yml
File metadata and controls
117 lines (108 loc) · 4.44 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
name: "Parse CI Reports"
description: |
Parse CI reports (tests, linting, coverage) into GitHub summary and Markdown for PR comments.
This action parses various report formats from testing, linting, and coverage tools and generates:
- GitHub Step Summaries for workflow runs
- Markdown output suitable for pull request or issue comments
- GitHub Annotations for failed tests and linting issues
It supports multiple common report standards out of the box.
author: hoverkraft
branding:
icon: check-circle
color: blue
inputs:
report-paths:
description: |
Paths to report files (glob patterns supported, one per line or comma-separated).
Set to `auto:test`, `auto:coverage`, `auto:lint`, or `auto:all` for automatic detection.
Examples: `**/junit.xml`, `coverage/lcov.info`, `eslint-report.json`, `auto:all`, `auto:test,coverage/lcov.info`, `auto:test,auto:coverage`
required: false
default: "auto:all"
report-name:
description: |
Name to display in the summary (e.g., `Test Results`, `Coverage Report`).
default: "Report Summary"
include-passed:
description: |
Whether to include passed tests in the summary.
default: "false"
output-format:
description: |
Output format: comma-separated list of `summary`, `markdown`, `annotations`, or `all` for everything.
default: "all"
fail-on-error:
description: |
Whether to fail the action if any test failures are detected.
default: "false"
path-mapping:
description: |
Path mapping(s) to rewrite file paths in reports (format: "from_path:to_path").
Useful when tests/lints run in a different directory or container.
Multiple mappings can be provided separated by newlines or commas.
Examples:
- Single mapping: "/app/src:./src"
- Multiple mappings: "/app/src:./src,/app/tests:./tests"
- Multi-line: |
/app/src:./src
/app/tests:./tests
required: false
default: ""
working-directory:
description: |
Working directory where the action should operate.
Can be absolute or relative to the repository root.
required: false
default: "."
outputs:
markdown:
description: "Generated Markdown output for PR comments"
value: ${{ steps.parse-reports.outputs.markdown }}
summary:
description: "Generated summary output"
value: ${{ steps.parse-reports.outputs.summary }}
parsed-files:
description: "List of parsed report files (JSON array)"
value: ${{ steps.parse-reports.outputs.parsed-files }}
has-errors:
description: "Whether any errors were detected in the reports"
value: ${{ steps.parse-reports.outputs.has-errors }}
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@a10d5e32daef8e060c49fe617833fb0d53476f22 # 0.24.0
with:
working-directory: ${{ github.action_path }}
- name: Parse reports
id: parse-reports
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
NODE_PATH: ${{ github.action_path }}/node_modules
REPORT_PATHS: ${{ inputs.report-paths }}
REPORT_NAME: ${{ inputs.report-name }}
INCLUDE_PASSED: ${{ inputs.include-passed }}
OUTPUT_FORMAT: ${{ inputs.output-format }}
PATH_MAPPING: ${{ inputs.path-mapping }}
ACTION_PATH: ${{ github.action_path }}
WORKING_DIRECTORY: ${{ inputs.working-directory }}
with:
script: |
const path = require('path');
const { pathToFileURL } = require('url');
const actionModulePath = path.join(process.env.ACTION_PATH, 'src', 'index.js');
const { run } = await import(pathToFileURL(actionModulePath));
const inputs = {
workingDirectory: process.env.WORKING_DIRECTORY,
reportPaths: process.env.REPORT_PATHS,
reportName: process.env.REPORT_NAME,
includePassed: process.env.INCLUDE_PASSED === 'true',
outputFormat: process.env.OUTPUT_FORMAT,
pathMapping: process.env.PATH_MAPPING || null
};
await run({ core, glob, inputs });
- name: Fail if errors detected
if: inputs.fail-on-error == 'true' && steps.parse-reports.outputs.has-errors == 'true'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
core.setFailed('Test failures or errors detected in reports');