Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hays0503 committed Sep 4, 2024
2 parents 3608c43 + 9ffc303 commit b5833c5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@ on:
- main
jobs:
coverage:
runs-on: self-hosted
runs-on: hays-linux
steps:
- uses: actions/checkout@v3
- uses: ArtiomTr/jest-coverage-report-action@v2
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Install dependencies
run: npm install

- name: Run tests
run: npx jest --coverage --coverageReporters json-summary

- name: Jest Coverage Comment
uses: MishaKav/jest-coverage-comment@main
43 changes: 43 additions & 0 deletions .github/workflows/update-coverage-in-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Coverage in README
on:
workflow_dispatch:
push:
paths-ignore:
- '**/*.md'
- '**/*.yml'
- '.github/**'
- 'data/**'
- 'dist/**'

jobs:
update-coverage-in-readme:
name: Update Coverage in README
runs-on: hays-linux
steps:

- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Jest Coverage Comment
if: github.ref == 'refs/heads/main'
id: coverageComment
uses: MishaKav/jest-coverage-comment@main
with:
hide-summary: true
coverage-summary-path: ./coverage/coverage-summary.json

- name: Update README with Coverage HTML
if: github.ref == 'refs/heads/main'
run: |
sed -i '/<!-- Jest Coverage Comment:Begin -->/,/<!-- Jest Coverage Comment:End -->/c\<!-- Jest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.summaryHtml }}\n<!-- Jest Coverage Comment:End -->' ./README.md
- name: Commit & Push changes in README
if: github.ref == 'refs/heads/main'
uses: actions-js/push@master
with:
message: Update coverage in README
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config: Config = {
coverageProvider: "v8",
coverageThreshold: {
global: {
lines: 80,
lines: 70,
},
},
collectCoverage: true,
Expand Down

0 comments on commit b5833c5

Please sign in to comment.