Skip to content

Commit

Permalink
Use @reporters/github (#14)
Browse files Browse the repository at this point in the history
* use @reporters/github

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

---------

Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Feb 1, 2024
1 parent d61b54c commit 2ff28be
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 344 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,4 @@ jobs:
- name: Run tests
run: |
npm run unit -- --reporter spec --reporter md:report.md --reporter gh
- name: Upload report
shell: bash
if: success() || failure()
run: |
cat report.md >> "$GITHUB_STEP_SUMMARY"
npm run unit -- --reporter spec
55 changes: 1 addition & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,65 +100,12 @@ Note the use of `incremental: true`, which speed up compilation massively.

Here are the available reporters:

* `md`: creates a markdown table, useful for setting up a Summary in your GitHub Action
* `gh`: emits `::error` workflow commands for GitHub Actions to show inlined error. Enabled by default when running on GHA.
* `gh`: emits `::error` workflow commands for GitHub Actions to show inlined errors. Enabled by default when running on GHA.
* `tap`: outputs the test results in the TAP format.
* `spec`: outputs the test results in a human-readable format.
* `dot`: outputs the test results in a compact format, where each passing test is represented by a ., and each failing test is represented by a X.
* `junit`: outputs test results in a jUnit XML format

## GitHub Action Summary

The following will automatically show the summary of the test run in the summary page of GitHub Actions.

```yaml
name: ci

on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'

jobs:
test:
runs-on: ${{matrix.os}}

strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Run tests
run: |
npm run unit -- --reporter spec --reporter md:report.md
- name: Upload report
shell: bash
if: success() || failure()
run: |
cat report.md >> "$GITHUB_STEP_SUMMARY"
```

## License

MIT
5 changes: 2 additions & 3 deletions borp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { finished } from 'node:stream/promises'
import { join, relative } from 'node:path'
import posix from 'node:path/posix'
import runWithTypeScript from './lib/run.js'
import { MarkdownReporter, GithubWorkflowFailuresReporter } from './lib/reporters.js'
import githubReporter from '@reporters/github'
import { Report } from 'c8'
import os from 'node:os'
import { execa } from 'execa'
Expand Down Expand Up @@ -90,8 +90,7 @@ try {

const reporters = {
...Reporters,
md: new MarkdownReporter(config),
gh: new GithubWorkflowFailuresReporter(config),
gh: githubReporter,
/* eslint new-cap: "off" */
spec: new Reporters.spec()
}
Expand Down
108 changes: 0 additions & 108 deletions lib/reporters.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"typescript": "^5.3.2"
},
"dependencies": {
"@reporters/github": "^1.5.4",
"c8": "^9.0.0",
"execa": "^8.0.1",
"find-up": "^7.0.0",
Expand Down
172 changes: 0 additions & 172 deletions test/reporters.test.js

This file was deleted.

0 comments on commit 2ff28be

Please sign in to comment.