Skip to content
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

ci: Fix Test workflow concurrency for code coverage #41061

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ on:
pull_request:
push:
branches: [ 'trunk', '*/branch-*' ]

concurrency:
group: tests-${{ github.event_name }}-${{ github.ref }}
# Trunk runs need to not be cancelled for concurrency, mainly for code coverage. Everything else can be.
group: tests-${{ github.event_name }}-${{ github.ref }}-${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && github.run_id || '' }}
cancel-in-progress: true

env:
Expand Down Expand Up @@ -54,7 +56,7 @@ jobs:

# Note matrix-job outputs are kind of weird. Last-to-run job that sets a non-empty value wins.
outputs:
did-coverage: ${{ ( steps.process-coverage.conclusion == 'success' && steps.upload-artifacts.conclusion == 'success' ) && 'true' || '' }}
did-coverage: ${{ ( steps.run-tests.conclusion != 'cancelled' && steps.process-coverage.conclusion == 'success' && steps.upload-artifacts.conclusion == 'success' ) && 'true' || '' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even try to run process-coverage if run-tests is cancelled? 🤔 Though I guess if it runs that's an easy way to determine if coverage was enabled and I'm not sure if matrix.script == 'test-coverage' is accessible here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For manual analysis, it probably doesn't hurt to save whatever coverage data we did manage to generate. But, particularly for trunk runs, it'll throw things off if that partial data gets uploaded.

The check here is now threefold: (1) we finished running the actual tests, (2) we successfully processed the coverage data, and (3) we successfully uploaded the artifact. If 2 or 3 is false, the upload job won't even be able to run successfully because there will be no data. If 1 is false, it's partial data that we don't want to upload.


steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -118,6 +120,7 @@ jobs:
run: .github/files/setup-wordpress-env.sh

- name: Run project tests
id: run-tests
env:
FORCE_PACKAGE_TESTS: ${{ matrix.force-package-tests && 'true' || 'false' }}
CHANGED: ${{ steps.changed.outputs.projects }}
Expand Down
Loading