Skip to content

Commit

Permalink
Merge pull request #5 from phoenix-actions/feature/output-enhancements
Browse files Browse the repository at this point in the history
Feature/output enhancements
  • Loading branch information
IanMoroney authored Feb 23, 2022
2 parents 2a042c6 + 68912a3 commit 497aa26
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/dirty-laundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:

- name: Create mochawesome report
uses: ./
id: test-report
if: success() || failure()
with:
name: Mochawesome Tests
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,48 @@ jobs:

- name: Test Report
uses: phoenix-actions/test-reporting@v3
id: test-report # Set ID reference for step
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results
```
## Action Outputs
A list of the possible action outputs are listed below.
* runHtmlUrl
In case you want to extract and read an output from the action, see the below example code:
```yaml
on:
pull_request:
push:
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)

- name: Test Report
uses: phoenix-actions/test-reporting@v3
id: test-report # Set ID reference for step
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results

- name: Read output variables
run: |
echo "url is ${{ steps.test-report.outputs.runHtmlUrl }}"
```
## Recommended setup for public repositories
Workflows triggered by pull requests from forked repositories are executed with read-only token and therefore can't create check runs.
Expand Down Expand Up @@ -89,6 +124,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: phoenix-actions/test-reporting@v3
id: test-report # Set ID reference for step
with:
artifact: test-results # artifact name
name: JEST Tests # Name of the check run which will be created
Expand Down
17 changes: 17 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {MochawesomeJsonParser} from './parsers/mochawesome-json/mochawesome-json

import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
import {getCheckRunContext} from './utils/github-utils'
import {Outputs} from './utils/constants'

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

core.setOutput(Outputs.runHtmlUrl, `${resp.data.html_url}`)

return results
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum Outputs {
runHtmlUrl = 'runHtmlUrl'
}

0 comments on commit 497aa26

Please sign in to comment.