Skip to content

Commit

Permalink
chore: tests and coverage (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
karpikpl authored May 1, 2024
1 parent 8aaf1ce commit 1228658
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:

permissions:
contents: read
statuses: write
issues: read
checks: write
pull-requests: write

jobs:
test-typescript:
Expand Down Expand Up @@ -44,6 +48,49 @@ jobs:
id: npm-ci-test
run: npm run ci-test

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Test Results JS
files: |
.reports/**/*.xml
- uses: actions/upload-artifact@v4
with:
name: js-results
path: |
reports/*
coverage/*
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ./coverage/*.xml
badge: true
format: markdown
output: both

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Add Coverage Summary
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
// read summary file
var summary = fs.readFileSync('code-coverage-results.md', 'utf8');
await core.summary
.addHeading('JS Code Coverage Summary')
.addRaw(summary)
.write()
test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ __tests__/runner/*
.idea
.vscode
*.code-workspace

# Ignore test results
.reports
34 changes: 34 additions & 0 deletions package-lock.json

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

24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,28 @@
"coverageReporters": [
"json-summary",
"text",
"lcov"
"lcov",
"cobertura",
"text-summary"
],
"reporters": [
"default",
[
"jest-junit",
{
"outputDirectory": ".reports",
"outputName": "report.xml",
"includeConsoleOutput": false,
"noStackTrace": true
}
],
[
"github-actions",
{
"silent": false
}
],
"summary"
],
"collectCoverage": true,
"collectCoverageFrom": [
Expand All @@ -83,6 +104,7 @@
"eslint-plugin-jsonc": "^2.15.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"make-coverage-badge": "^1.2.0",
"prettier": "^3.2.5",
"prettier-eslint": "^16.3.0",
Expand Down

0 comments on commit 1228658

Please sign in to comment.