Skip to content

Commit

Permalink
ci: Reduce rust coverage report delay (#1370)
Browse files Browse the repository at this point in the history
CI was running tests on `{MSRV, beta, nightly}` first, and only then
running tests with coverage instrumentation on nightly.

Since those tests are not on the critical path for the required checks,
we can run the nightly tests directly with instrumentation on the first
pass, shaving ~2mins from the commit-to-codecov report delay.

I'm only doing this for rust, as the python tests _are_ in the required
checks sets and we don't want to slow down those.

drive-by: The python tests job had the same name as the linting job.

---------

Co-authored-by: Douglas Wilson <[email protected]>
  • Loading branch information
aborgna-q and doug-q authored Jul 30, 2024
1 parent b7a39b9 commit 5ee2e04
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
test:
needs: [changes, build_binary]
if: ${{ needs.changes.outputs.python == 'true' }}
name: check python ${{ matrix.python-version }}
name: test python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
Expand Down
65 changes: 34 additions & 31 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ jobs:
strategy:
fail-fast: true
matrix:
rust: ['1.75', beta, 'nightly']
# Stable is covered by `tests-stable-no-features` and `tests-stable-all-features`
# Nightly is covered by `tests-nightly-coverage`
rust: ['1.75', beta]
name: tests (Rust ${{ matrix.rust }})
steps:
- uses: actions/checkout@v4
Expand All @@ -143,37 +145,12 @@ jobs:
- name: Tests with all features
run: cargo test --verbose --workspace --all-features

# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
required-checks:
name: Required checks 🦀
needs: [changes, check, tests-stable-no-features, tests-stable-all-features]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
# This condition should simply be `if: failure() || cancelled()`,
# but there seems to be a bug in the github workflow runner.
#
# See https://github.com/orgs/community/discussions/80788
if: |
needs.changes.result == 'failure' || needs.changes.result == 'cancelled' ||
needs.check.result == 'failure' || needs.check.result == 'cancelled' ||
needs.tests-stable-no-features.result == 'failure' || needs.tests-stable-no-features.result == 'cancelled' ||
needs.tests-stable-all-features.result == 'failure' || needs.tests-stable-all-features.result == 'cancelled'
run: |
echo "Required checks failed"
echo "Please check the logs for more information"
exit 1
- name: Pass if required checks passed
run: |
echo "All required checks passed"
coverage:
needs: [changes, tests-stable-no-features, tests-stable-all-features, tests-other, check]
# Run only if there are changes in the relevant files and the check job passed or was skipped
if: always() && !failure() && !cancelled() && needs.changes.outputs.rust == 'true' && github.event_name != 'merge_group'
tests-nightly-coverage:
needs: changes
# Run only if there are changes in the relevant files
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
name: tests (Rust nightly, coverage)
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
Expand All @@ -198,3 +175,29 @@ jobs:
name: rust
flags: rust
token: ${{ secrets.CODECOV_TOKEN }}

# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
required-checks:
name: Required checks 🦀
needs: [changes, check, tests-stable-no-features, tests-stable-all-features]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
# This condition should simply be `if: failure() || cancelled()`,
# but there seems to be a bug in the github workflow runner.
#
# See https://github.com/orgs/community/discussions/80788
if: |
needs.changes.result == 'failure' || needs.changes.result == 'cancelled' ||
needs.check.result == 'failure' || needs.check.result == 'cancelled' ||
needs.tests-stable-no-features.result == 'failure' || needs.tests-stable-no-features.result == 'cancelled' ||
needs.tests-stable-all-features.result == 'failure' || needs.tests-stable-all-features.result == 'cancelled'
run: |
echo "Required checks failed"
echo "Please check the logs for more information"
exit 1
- name: Pass if required checks passed
run: |
echo "All required checks passed"

0 comments on commit 5ee2e04

Please sign in to comment.