From e4656ae75453fec7d12a6f6090759d125b5f7482 Mon Sep 17 00:00:00 2001 From: Ranieri Althoff Date: Mon, 20 Nov 2023 21:42:08 -0300 Subject: [PATCH] Add test coverage report to Codacy --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59df34a..bde6595 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,45 @@ jobs: - name: Lint run: npm run lint + coverage: + name: Report coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + cache: npm + node-version: 20 + + - name: Install dependencies + run: npm ci + env: + npm_config_debug: true + + - name: Run tests + run: node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info test.cjs + + - name: Install lcov + run: sudo apt install -yq lcov + + - name: Merge coverage reports + run: | + lcov --capture --directory . --no-external --output-file lcov-cpp.info + lcov --add-tracefile lcov-cpp.info --add-tracefile lcov.info --output-file lcov.info + lcov --remove lcov.info "*/node_modules/*" --output-file lcov.info + + - name: "Send to Codacy" + uses: codacy/codacy-coverage-reporter-action@v1 + with: + coverage-reports: lcov.info + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + test: strategy: matrix: