From 1acc8033ac418d5dc77facee755169dce767c0d1 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Wed, 1 May 2024 19:24:32 -0400 Subject: [PATCH] reporting coverage and test results Signed-off-by: Piotr Karpala --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 4 +++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32b34fc..8e461c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,10 @@ on: permissions: contents: read + statuses: write + issues: read checks: write + pull-requests: write jobs: test-javascript: @@ -45,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 diff --git a/.gitignore b/.gitignore index a8e79bf..d43814e 100644 --- a/.gitignore +++ b/.gitignore @@ -101,4 +101,6 @@ __tests__/runner/* .idea .vscode *.code-workspace -.reports + +# Ignore test results +.reports \ No newline at end of file