-
Notifications
You must be signed in to change notification settings - Fork 2
Add coverage CI job #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
douglaswinter
wants to merge
1
commit into
main
Choose a base branch
from
dw/coverage_ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: Coverage | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| coverage: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
| TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Required for turbo diff | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: "pnpm" | ||
| cache-dependency-path: "**/pnpm-lock.yaml" | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| # --- PR coverage (affected only) --- | ||
| - name: Run PR coverage | ||
| # the filter means 'projects changed since origin/main, inc dependents' | ||
| run: pnpm turbo coverage --filter=...[origin/main] --force --no-daemon | ||
|
|
||
| - name: Save PR coverage | ||
| run: | | ||
| mkdir pr-coverage | ||
| find . -name coverage-summary.json | while read file; do | ||
| project=$(dirname "$(dirname "$file")") | ||
| project=$(basename "$project") | ||
| cp "$file" "pr-coverage/$project.json" | ||
| done | ||
|
|
||
| - name: Capture PR ref | ||
| run: echo "PR_REF=${{ github.head_ref }}" >> $GITHUB_ENV | ||
|
|
||
| # --- baseline coverage --- | ||
| - name: Checkout main | ||
| run: git checkout origin/main | ||
|
|
||
| - name: Install dependencies (main) | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Run coverage (main affected) | ||
| # notice both times we --force turbo to ignore cache and execute tasks fresh | ||
| run: pnpm turbo coverage --filter=...[origin/$PR_REF] --force --no-daemon | ||
|
|
||
| - name: Save coverage (main affected) | ||
| run: | | ||
| mkdir base-coverage | ||
| find . -name coverage-summary.json | while read file; do | ||
| project=$(dirname "$(dirname "$file")") | ||
| project=$(basename "$project") | ||
| cp "$file" "base-coverage/$project.json" | ||
| done | ||
|
|
||
| # --- compare --- | ||
| - name: Compare coverage | ||
| # the script errors (exit code 1), causing this action to fail, | ||
| # if regression for any app or package is detected | ||
| run: node scripts/compare-coverage.mjs pr-coverage base-coverage | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this correctly, it will only run on pull requests that target main?
Does it need to be run on all pull requests instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct, you don't need to run it for a PR into something other than main... at some point you'll want that in main and then it will trigger (as in for this PR itself)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long does it take to run? If not long, can just add to all PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But 1) why? you can do whatever you want in your branch, I'm only interested at the point of merging to main; and 2) we could do it for all PRs, but we'd need to change the script to make it meaningful, which currently runs coverage on your change and then checks out main specifically to get a baseline coverage.