diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 85fa67d..4f7547b 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -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 diff --git a/.github/workflows/update-coverage-in-readme.yml b/.github/workflows/update-coverage-in-readme.yml new file mode 100644 index 0000000..f470485 --- /dev/null +++ b/.github/workflows/update-coverage-in-readme.yml @@ -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 '//,//c\\n\${{ steps.coverageComment.outputs.summaryHtml }}\n' ./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 }} diff --git a/README.md b/README.md index c403366..81081d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/jest.config.ts b/jest.config.ts index 887789f..3f1a58f 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -23,7 +23,7 @@ const config: Config = { coverageProvider: "v8", coverageThreshold: { global: { - lines: 80, + lines: 70, }, }, collectCoverage: true,