Skip to content

Commit

Permalink
Merge branch 'dorny:main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Xu committed Mar 3, 2024
2 parents d545618 + eaa763f commit 0b7d35f
Show file tree
Hide file tree
Showing 46 changed files with 39,111 additions and 19,388 deletions.
25 changes: 2 additions & 23 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"import/no-named-as-default": "off",
"no-shadow": "off",
"no-unused-vars": "off",
"prefer-template": "off",
Expand Down Expand Up @@ -60,29 +61,7 @@
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`

// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default

// use <root>/path/to/folder/tsconfig.json
"project": "path/to/folder",

// Multiple tsconfigs (Useful for monorepos)

// use a glob pattern
"project": "packages/*/tsconfig.json",

// use an array
"project": [
"packages/module-a/tsconfig.json",
"packages/module-b/tsconfig.json"
],

// use an array of glob patterns
"project": [
"packages/*/tsconfig.json",
"other-packages/*/tsconfig.json"
]
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: 'dorny,dharmendrasha,j-catania'
---

## Describe the bug
A clear and concise description of what the bug is.

## To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

## Expected behavior
A clear and concise description of what you expected to happen.

## Screenshots
If applicable, add screenshots to help explain your problem.

## Additional context
Add any other context about the problem here.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Feature Request
about: Suggest a feature
title: ''
labels: 'enhancement'
assignees: 'dorny,dharmendrasha,j-catania'
---

## Describe

## Proposed solution

## Alternatives considered
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
53 changes: 53 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install dependencies
run: npm ci

- name: Rebuild the dist/ directory
run: |
npm run build
npm run package
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: node --version
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run build
- run: npm run format-check
Expand All @@ -23,15 +25,7 @@ jobs:

- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-results
path: __tests__/__results__/*.xml

- name: Create test report
uses: ./
if: success() || failure()
with:
name: JEST Tests
path: __tests__/__results__/*.xml
reporter: jest-junit
22 changes: 22 additions & 0 deletions .github/workflows/manual-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Manual run

on:
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run build
- run: npm test

- name: Create test report
uses: ./
if: success() || failure()
with:
name: JEST Tests
path: __tests__/__results__/*.xml
reporter: jest-junit
2 changes: 1 addition & 1 deletion .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Workflow test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ./
with:
artifact: test-results
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ lib/**/*

# Project specific
__tests__/__results__

.idea
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.19.0
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Changelog

## 1.8.0
* Add `SwiftXunitParser` class based on `JavaJunitParser` for `swift-xunit` reporter https://github.com/dorny/test-reporter/pull/317
* Use NodeJS 18 LTS as default runtime https://github.com/dorny/test-reporter/pull/332
* Escape `<>` characters in suite name https://github.com/dorny/test-reporter/pull/236
* Update actions runtime to Node20 https://github.com/dorny/test-reporter/pull/315
* Update check title and remove icon https://github.com/dorny/test-reporter/pull/144

## 1.7.0
* Fix #199: Use ✅ instead of ✔️ for better cross platform look by @petrdvorak in https://github.com/dorny/test-reporter/pull/200
* Verify content of dist/ folder matches build output by @dorny in https://github.com/dorny/test-reporter/pull/207
* Gracefully handle empty nested testsuite elements for JUnit. by @rvdlaarschot in https://github.com/dorny/test-reporter/pull/193
* Gracefully handle empty failure tags by @haudren-woven in https://github.com/dorny/test-reporter/pull/213
* Fix #208 - java-junit: show annotations on PR changed files by @atsu85 in https://github.com/dorny/test-reporter/pull/209
* Only report failure if fail-on-error is set by @trond-snekvik in https://github.com/dorny/test-reporter/pull/214
* Improve clarity on configuring for forkable repos by @abelbraaksma in https://github.com/dorny/test-reporter/pull/211
* Suppress "Processing test results from" log by @vasanthdharmaraj in https://github.com/dorny/test-reporter/pull/179
* Skip listing of files if error parsing is disabled by @dorny in https://github.com/dorny/test-reporter/pull/216
* Correct typo in docs by @tangowithfoxtrot in https://github.com/dorny/test-reporter/pull/254
* update dependencies by @j-catania in https://github.com/dorny/test-reporter/pull/269
* Add permissions to example yml files by @TurnrDev in https://github.com/dorny/test-reporter/pull/263
* add feature fail-on-empty by @gdams in https://github.com/dorny/test-reporter/pull/243
* Add dependabot configuration by @yeikel in https://github.com/dorny/test-reporter/pull/228
* Bump ws from 7.3.1 to 7.5.9 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/265
* Bump actions/checkout from 2 to 4 by @dependabot in https://github.com/dorny/test-reporter/pull/279
* Add new output for url url html by @luisito666 in https://github.com/dorny/test-reporter/pull/242
* Update README.md by @IanMoroney in https://github.com/dorny/test-reporter/pull/158
* Update jest-Junit part of Readme by @ryancasburn-KAI in https://github.com/dorny/test-reporter/pull/176
* fix: default-valued fields are not mandatory by @TomerFi in https://github.com/dorny/test-reporter/pull/172
* Bump ansi-regex from 4.1.0 to 4.1.1 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/278
* Bump decode-uri-component from 0.2.0 to 0.2.2 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/276
* Bump minimist from 1.2.5 to 1.2.8 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/275
* Bump qs from 6.5.2 to 6.5.3 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/272
* Bump json5 from 2.1.3 to 2.2.3 in /reports/jest by @dependabot in https://github.com/dorny/test-reporter/pull/271
* Bump ansi-regex from 3.0.0 to 3.0.1 in /reports/mocha by @dependabot in https://github.com/dorny/test-reporter/pull/270
* declare 'url' and 'url_html' as action outputs by @micha-one in https://github.com/dorny/test-reporter/pull/287
* Avoid split on undefined by @cazou in https://github.com/dorny/test-reporter/pull/258

## v1.6.0
- [Update to node16 + recent versions of core and exec packages](https://github.com/dorny/test-reporter/pull/203)
- [Update all dependencies to latest versions](https://github.com/dorny/test-reporter/pull/186)
Expand Down
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This [Github Action](https://github.com/features/actions) displays test results
- Flutter / [test](https://pub.dev/packages/test)
- Java / [JUnit](https://junit.org/)
- JavaScript / [JEST](https://jestjs.io/) / [Mocha](https://mochajs.org/)
- Swift / xUnit

For more information see [Supported formats](#supported-formats) section.

Expand All @@ -33,12 +34,16 @@ If that's fine for you, using this action is as simple as:
on:
pull_request:
push:
permissions:
contents: read
actions: read
checks: write
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout the repo
- uses: actions/checkout@v3 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)

Expand All @@ -58,6 +63,8 @@ To workaround this security restriction, it's required to use two separate workf
1. `CI` runs in the context of the PR head branch with the read-only token. It executes the tests and uploads test results as a build artifact
2. `Test Report` runs in the context of the repository main branch with read/write token. It will download test results and create reports

The second workflow will only run after it has been merged into your default branch (typically `main` or `master`), it won't run in a PR unless after the workflow file is part of that branch.

**PR head branch:** *.github/workflows/ci.yml*
```yaml
name: 'CI'
Expand All @@ -67,10 +74,10 @@ jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout the repo
- uses: actions/checkout@v3 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)
- uses: actions/upload-artifact@v2 # upload test results
- uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
Expand All @@ -84,6 +91,10 @@ on:
workflows: ['CI'] # runs after CI workflow
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -114,7 +125,7 @@ jobs:
# Name of the Check Run which will be created
name: ''
# Coma separated list of paths to test results
# Comma-separated list of paths to test results
# Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
# All matched result files must be of the same format
path: ''
Expand Down Expand Up @@ -161,6 +172,9 @@ jobs:
# Set action as failed if test report contains any failed test
fail-on-error: 'true'
# Set this action as failed if no test results were found
fail-on-empty: 'true'
# Relative path under $GITHUB_WORKSPACE where the repository was checked out.
working-directory: ''
Expand All @@ -177,6 +191,8 @@ jobs:
| failed | Count of failed tests |
| skipped | Count of skipped tests |
| time | Test execution time [ms] |
| url | Check run URL |
| url_html | Check run URL HTML |

## Supported formats

Expand Down Expand Up @@ -261,14 +277,14 @@ Some heuristic was necessary to figure out the mapping between the line in the s
</details>

<details>
<summary>jest-Junit</summary>
<summary>jest-junit</summary>

[JEST](https://jestjs.io/) testing framework support requires the usage of [jest-Junit](https://github.com/jest-community/jest-Junit) reporter.
[JEST](https://jestjs.io/) testing framework support requires the usage of [jest-junit](https://github.com/jest-community/jest-junit) reporter.
It will create test results in Junit XML format which can be then processed by this action.
You can use the following example configuration in `package.json`:
```json
"scripts": {
"test": "jest --ci --reporters=default --reporters=jest-Junit"
"test": "jest --ci --reporters=default --reporters=jest-junit"
},
"devDependencies": {
"jest": "^26.5.3",
Expand Down Expand Up @@ -307,13 +323,19 @@ Mocha, unfortunately, doesn't have the option to store `json` output directly to
There is a work in progress to fix it: [mocha#4607](https://github.com/mochajs/mocha/pull/4607)
</details>

<details>
<summary>swift-xunit (Experimental)</summary>

Support for Swift test results in xUnit format is experimental - should work but it was not extensively tested.
</details>

## GitHub limitations

Unfortunately, there are some known issues and limitations caused by GitHub API:

- Test report (i.e. Check Run summary) is markdown text. No custom styling or HTML is possible.
- Maximum report size is 65535 bytes. Input parameters `list-suites` and `list-tests` will be automatically adjusted if max size is exceeded.
- Test report can't reference any additional files (e.g. screenshots). You can use `actions/upload-artifact@v2` to upload them and inspect them manually.
- Test report can't reference any additional files (e.g. screenshots). You can use `actions/upload-artifact@v3` to upload them and inspect them manually.
- Check Runs are created for specific commit SHA. It's not possible to specify under which workflow test report should belong if more
workflows are running for the same SHA. Thanks to this GitHub "feature" it's possible your test report will appear in an unexpected place in GitHub UI.
For more information, see [#67](https://github.com/dorny/test-reporter/issues/67).
Expand Down
Loading

0 comments on commit 0b7d35f

Please sign in to comment.