Skip to content

Commit

Permalink
Add a meta "required-checks" job that succeeds if things are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Mar 19, 2024
1 parent abfd2d5 commit a935a0b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 16 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,28 @@ jobs:
- name: Run tests
run: poetry run pytest

# 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: [check]
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
if: (failure() || 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, check]
if: ${{ needs.changes.outputs.python == 'true' }} && github.event_name != 'merge_group'
# 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.python == 'true' && github.event_name != 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
64 changes: 49 additions & 15 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,39 @@ jobs:
- name: Build benchmarks with all features
run: cargo bench --verbose --no-run --workspace --all-features

tests:
# Run tests on Rust stable
tests-stable:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
name: tests (Rust stable)
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 'stable'
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- name: Build with no features
run: cargo test --verbose --workspace --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --workspace --no-default-features
- name: Build with all features
run: cargo test --verbose --workspace --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --workspace --all-features

# Run tests on other toolchains
tests-other:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
rust: ['1.75', stable, beta, nightly]
# workaround to ignore non-stable tests when running the merge queue checks
# see: https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6
isMerge:
- ${{ github.event_name == 'merge_group' }}
exclude:
- rust: '1.75'
isMerge: true
- rust: beta
isMerge: true
- rust: nightly
isMerge: true
rust: ['1.75', beta, nightly]
name: tests (Rust ${{ matrix.rust }})
steps:
- uses: actions/checkout@v4
Expand All @@ -114,9 +129,28 @@ 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: [check, tests-stable]
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
if: (failure() || 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, check]
if: ${{ needs.changes.outputs.rust == 'true' }} && github.event_name != 'merge_group'
needs: [changes, tests-stable, 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'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit a935a0b

Please sign in to comment.