From dd23935b358ee0da25d45452d7df4f083f2a4cd1 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Mon, 11 Dec 2023 13:57:40 -0500 Subject: [PATCH] Use LCOV combined coverage --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c41dad..26b5206 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,3 +40,25 @@ jobs: - run: npm test - run: npm run test:ts if: (matrix.node-version != '12.x' && matrix.node-version != '14.x' && matrix.node-version != '16.10.0') + - name: Archive code coverage results + if: success() + uses: actions/upload-artifact@v3 + with: + name: coverage_${{ matrix.os }}_${{ matrix.node-version}} + if-no-files-found: ignore + path: coverage/lcov.info + + coverage: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download reports' artifacts + uses: actions/download-artifact@v3 + with: + path: downloaded_artifacts + - name: Install lcov + run: sudo apt install -y lcov + - name: Combine all coverage data + run: find . -type f -name '*.info' -printf '-a\0%f\0' | xargs -J % -0 -- lcov % -o all_lcov.info + - name: Report + run: lcov --summary all_lcov.info --fail-under-lines 90 diff --git a/package.json b/package.json index 9e125fd..83eaab6 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Intercept imports in Node.js", "main": "index.js", "scripts": { - "test": "c8 --check-coverage --lines 85 imhotap --runner 'node test/runtest' --files test/{hook,low-level,other,get-esm-exports}/*", - "test:ts": "c8 imhotap --runner 'node test/runtest' --files test/typescript/*.test.mts", + "test": "c8 --reporter lcov --check-coverage --lines 85 imhotap --runner 'node test/runtest' --files test/{hook,low-level,other,get-esm-exports}/*", + "test:ts": "c8 --reporter lcov imhotap --runner 'node test/runtest' --files test/typescript/*.test.mts", "coverage": "c8 --reporter html imhotap --runner 'node test/runtest' --files test/{hook,low-level,other,get-esm-exports}/* && echo '\nNow open coverage/index.html\n'" }, "repository": {