From 0e8fee63e6168447e35e44687e3257666a1df1ac Mon Sep 17 00:00:00 2001 From: Douglas Winter Date: Fri, 8 May 2026 11:12:18 +0000 Subject: [PATCH] Fix coverage job for new projects The existing job does the following: 1. Figure out which projects are affected since BASE 2. At HEAD, run coverage for those projects and save report 3. At BASE, run coverage on the same projects and save report 4. Give both outputs to comparison script But for new projects, step 3 will fail because those projects do not exist yet. In this change we filter out affected projects not in the workspace be- fore step 3. --- .github/workflows/coverage.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4ece5ea..5d6db72 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -82,16 +82,38 @@ jobs: if: env.has_affected == 'true' run: pnpm install --frozen-lockfile + - name: Filter out affected packages not in base + if: env.has_affected == 'true' + run: | + pnpm m ls --depth -1 --json > workspace.json + + node -e " + const fs = require('fs'); + + const affected = fs.readFileSync('affected.txt', 'utf-8').split('\n'); + const workspace = JSON.parse(fs.readFileSync('workspace.json')); + const availableProjects = new Set(workspace.map(project => project.name)); + + const filtered = affected.filter(project => availableProjects.has(project)); + + console.log('Filtered affected projects:', filtered); + + fs.writeFileSync('affected.filtered.txt', filtered.join('\n')); + " + + if [ ! -s affected.filtered.txt ]; then + echo "No affected projects" + echo "has_affected=false" >> $GITHUB_ENV + else + echo "has_affected=true" >> $GITHUB_ENV + fi + - name: Run coverage (main affected) if: env.has_affected == 'true' # notice both times we --force turbo to ignore cache and execute tasks fresh run: | - while read project; do - name=$(echo "$project" | sed 's/@atlas\///') - if [ -f "apps/$name/package.json" ] || [ -f "packages/$name/package.json" ]; then - pnpm turbo run coverage --filter=$project --force --no-daemon - fi - done < affected.txt + FILTERS=$(awk '{print "--filter="$0}' affected.filtered.txt | xargs) + pnpm turbo run coverage $FILTERS --force --no-daemon - name: Save coverage (main affected) if: env.has_affected == 'true'