From dbb285ad4b347c2c3f5ce3230b4b24d8a5d05208 Mon Sep 17 00:00:00 2001 From: Stanislav Mishchyshyn Date: Fri, 11 Aug 2023 12:25:35 +0300 Subject: [PATCH] ci: NPF-2894 add code coverage report --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++-- .prettierignore | 1 + ilc/nyc.config.js | 2 +- registry/.nycrc.json | 7 +------ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6238c1ee..34654af8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: - '**' tags-ignore: - '**' + pull_request: + branches: + - '**' jobs: build_ilc: @@ -46,12 +49,29 @@ jobs: run: docker run namecheap/ilc_tmp:$SHA npm run test:ci - name: Run server-side tests coverage - run: docker run --volume /artifacts/ilc/.test_output/server:/temporary namecheap/ilc_tmp:$SHA bash -c "npm run test:coverage && mv .nyc_output/* /temporary" + run: docker run --volume $(pwd)/artifacts/ilc/.test_output/server:/temporary namecheap/ilc_tmp:$SHA bash -c "npm run test:coverage && mv .nyc_output/* /temporary" - uses: actions/upload-artifact@v2 with: name: server-side-tests-artifacts - path: /artifacts/ilc/.test_output/server/ + path: artifacts/ilc/.test_output/server/ + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: artifacts/**/cobertura-coverage.xml + badge: true + format: markdown + indicators: true + output: both + thresholds: '80 95' + + - 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: Build the Docker image to test client-side run: | diff --git a/.prettierignore b/.prettierignore index df025e88..619c5292 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ # Ignore artifacts: ilc/public +.nyc_output diff --git a/ilc/nyc.config.js b/ilc/nyc.config.js index 313f9fd8..f7ea9345 100644 --- a/ilc/nyc.config.js +++ b/ilc/nyc.config.js @@ -2,7 +2,7 @@ const path = require('path'); module.exports = { all: true, - reporter: ['html', 'text'], + reporter: ['html', 'text', 'cobertura', 'json-summary'], 'check-coverage': true, branches: 0, diff --git a/registry/.nycrc.json b/registry/.nycrc.json index 97f54ded..64988638 100644 --- a/registry/.nycrc.json +++ b/registry/.nycrc.json @@ -4,10 +4,5 @@ "check-coverage": true, "lines": 90, "per-file": true, - "exclude": [ - "**/*.spec.ts", - "config", - "build", - "node_modules" - ] + "exclude": ["**/*.spec.ts", "config", "build", "node_modules"] }