Skip to content

Commit 497aa26

Browse files
authored
Merge pull request phoenix-actions#5 from phoenix-actions/feature/output-enhancements
Feature/output enhancements
2 parents 2a042c6 + 68912a3 commit 497aa26

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

.github/workflows/dirty-laundry.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919

2020
- name: Create mochawesome report
2121
uses: ./
22+
id: test-report
2223
if: success() || failure()
2324
with:
2425
name: Mochawesome Tests

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,48 @@ jobs:
4444

4545
- name: Test Report
4646
uses: phoenix-actions/test-reporting@v3
47+
id: test-report # Set ID reference for step
4748
if: success() || failure() # run this step even if previous step failed
4849
with:
4950
name: JEST Tests # Name of the check run which will be created
5051
path: reports/jest-*.xml # Path to test results
5152
reporter: jest-junit # Format of test results
5253
```
5354
55+
## Action Outputs
56+
57+
A list of the possible action outputs are listed below.
58+
59+
* runHtmlUrl
60+
61+
In case you want to extract and read an output from the action, see the below example code:
62+
```yaml
63+
on:
64+
pull_request:
65+
push:
66+
jobs:
67+
build-test:
68+
name: Build & Test
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v2 # checkout the repo
72+
- run: npm ci # install packages
73+
- run: npm test # run tests (configured to use jest-junit reporter)
74+
75+
- name: Test Report
76+
uses: phoenix-actions/test-reporting@v3
77+
id: test-report # Set ID reference for step
78+
if: success() || failure() # run this step even if previous step failed
79+
with:
80+
name: JEST Tests # Name of the check run which will be created
81+
path: reports/jest-*.xml # Path to test results
82+
reporter: jest-junit # Format of test results
83+
84+
- name: Read output variables
85+
run: |
86+
echo "url is ${{ steps.test-report.outputs.runHtmlUrl }}"
87+
```
88+
5489
## Recommended setup for public repositories
5590
5691
Workflows triggered by pull requests from forked repositories are executed with read-only token and therefore can't create check runs.
@@ -89,6 +124,7 @@ jobs:
89124
runs-on: ubuntu-latest
90125
steps:
91126
- uses: phoenix-actions/test-reporting@v3
127+
id: test-report # Set ID reference for step
92128
with:
93129
artifact: test-results # artifact name
94130
name: JEST Tests # Name of the check run which will be created

dist/index.js

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {MochawesomeJsonParser} from './parsers/mochawesome-json/mochawesome-json
1919

2020
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
2121
import {getCheckRunContext} from './utils/github-utils'
22+
import {Outputs} from './utils/constants'
2223

2324
async function main(): Promise<void> {
2425
try {
@@ -197,6 +198,8 @@ class TestReporter {
197198
core.info(`Check run URL: ${resp.data.url}`)
198199
core.info(`Check run HTML: ${resp.data.html_url}`)
199200

201+
core.setOutput(Outputs.runHtmlUrl, `${resp.data.html_url}`)
202+
200203
return results
201204
}
202205

src/utils/constants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum Outputs {
2+
runHtmlUrl = 'runHtmlUrl'
3+
}

0 commit comments

Comments
 (0)