From 235f39717e53c5bbff976e519e4472f1511aa3b7 Mon Sep 17 00:00:00 2001 From: ryanrosello-og Date: Sun, 11 Aug 2024 11:29:42 +1000 Subject: [PATCH] add pw coverage report to gh --- .github/workflows/playwright.yml | 56 ++++++++++++++++++++++++++++++++ vite.config.mts | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6738f109c..d53d5f739 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -213,6 +213,7 @@ jobs: env: CI: true token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} + GENERATE_PLAYWRIGHT_COVERAGE: true - name: send to axiom if: always() shell: bash @@ -232,6 +233,13 @@ jobs: path: playwright-report/ retention-days: 30 overwrite: true + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-coverage-ubuntu-${{ matrix.shardIndex }}-${{ github.sha }} + path: .nyc_output/ + retention-days: 30 + overwrite: true playwright-macos: timeout-minutes: 30 @@ -367,6 +375,7 @@ jobs: env: CI: true token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} + GENERATE_PLAYWRIGHT_COVERAGE: true - uses: actions/upload-artifact@v4 if: ${{ always() }} with: @@ -381,3 +390,50 @@ jobs: path: playwright-report/ retention-days: 30 overwrite: true + - uses: actions/upload-artifact@v4 + if: ${{ always() }} + with: + name: playwright-coverage-macos-${{ matrix.shardIndex }}-${{ github.sha }} + path: .nyc_output/ + retention-days: 30 + overwrite: true + + + # only run this job after all shards above have completed + # TBC: do we want to separate coverage reports by OS? + # the Job below combines both chrome and webkit coverage reports + merge-coverage-reports: + # Merge reports after playwright-tests, even if some shards have failed + if: ${{ !cancelled() }} + needs: [playwright-ubuntu, playwright-macos] + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + - uses: KittyCAD/action-install-cli@main + - name: Install dependencies + run: yarn + + - name: Download coverage reports from GitHub Actions Artifacts + uses: actions/download-artifact@v4 + with: + path: .all_coverage_reports + pattern: playwright-coverage* + merge-multiple: true + + - name: Merge all coverage reports from all shards into a single json report + run: npx nyc merge .all_coverage_reports ./.nyc_output/coverage.json + + - name: Generate HTML coverage report + run: npx nyc report --reporter=html || true + + - name: Upload Convertage HTML report + uses: actions/upload-artifact@v4 + with: + name: coverage-report-${{ github.sha }} + path: coverage + retention-days: 14 diff --git a/vite.config.mts b/vite.config.mts index 5e67bfcef..22c2920f8 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -62,7 +62,7 @@ const config = defineConfig({ '@kittycad/codemirror-lsp-client': '/packages/codemirror-lsp-client/src', }, }, - plugins: [react(), viteTsconfigPaths(), eslint(), version(), lezer(), ...(process.env.USE_BABEL_PLUGIN_ISTANBUL + plugins: [react(), viteTsconfigPaths(), eslint(), version(), lezer(), ...(process.env.GENERATE_PLAYWRIGHT_COVERAGE ? [ IstanbulPlugin({ include: "src/*",