From 60ccf2f66d186b82a84f6b787844f845dd3109b6 Mon Sep 17 00:00:00 2001 From: Jakub Dobry Date: Thu, 18 Apr 2024 16:05:53 +0200 Subject: [PATCH] Fix coverage in CI (#4) * Add coverage reporters * Coverage no directory specify * Run pnpm test filter * Downgrade NodeJS to 18 * Exclude coverage folder in web * Run pnpm install * Revert "Run pnpm install" This reverts commit 8c631b452dc89def77b8636611a8eb1a6adb9c93. * Frozen lockfile * Set coverage type cobertura * Test pnpm install without cache * Test pnpm install without cache * Revert "Test pnpm install without cache" This reverts commit 42e31d1e9a8573d2acf354a296466f40fe0f8682. * Upload web coverage * Change to normal test * Revert "Change to normal test" This reverts commit 878f6365ee6472ec6342b01814369cce41ead474. * Try disabling test cache * Prod false, cache tests * Try pnpm 9 * Run tests serially * Revert "Try pnpm 9" This reverts commit cc6dbe67cbd38caf7d3ec5c64d26e6bf8869112b. * jest verbose * Revert "jest verbose" This reverts commit d0af7b0d75509d0ab6fa83d7cc5ae47e57acb8a3. * coverageProvider babel? --- .github/workflows/jest.yml | 15 +++++++++++---- .idea/grpcflair.iml | 1 + web/jest.config.js | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index 631db53..9c166af 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -17,7 +17,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 18 - uses: pnpm/action-setup@v3 name: Install pnpm @@ -39,15 +39,22 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: pnpm install + run: pnpm install --frozen-lockfile --prod false - name: Run Jest - run: cd web && pnpm test:ci + run: pnpm --filter web test:ci + + - name: Upload Web Coverage + uses: actions/upload-artifact@v3 + with: + name: coverage-web + path: web/coverage - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: - directory: web/coverage token: ${{ secrets.CODECOV_TOKEN }} slug: dobrac/grpcflair + verbose: true + files: ./web/coverage/cobertura-coverage.xml diff --git a/.idea/grpcflair.iml b/.idea/grpcflair.iml index b2dc32a..95a1784 100644 --- a/.idea/grpcflair.iml +++ b/.idea/grpcflair.iml @@ -8,6 +8,7 @@ + diff --git a/web/jest.config.js b/web/jest.config.js index b72cedd..f3cb767 100644 --- a/web/jest.config.js +++ b/web/jest.config.js @@ -21,7 +21,10 @@ const customJestConfig = { coveragePathIgnorePatterns: ["/node_modules/", "/tests/", "/src/contexts/"], // Indicates which provider should be used to instrument code for coverage - coverageProvider: "v8", + coverageProvider: "babel", + + // A list of reporter names that Jest uses when writing coverage reports + coverageReporters: ["json", "lcov", "text", "clover", "text", "cobertura"], // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module moduleNameMapper: {