Skip to content

Commit

Permalink
use dorny/paths-filter action
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Mar 18, 2024
1 parent 9ef775f commit 2ec0f2b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 80 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/ci-py-skip.yml

This file was deleted.

39 changes: 27 additions & 12 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,40 @@ on:
pull_request:
branches:
- main
paths:
- 'quantinuum-hugr-py/**'
- 'pyproject.toml'
- '!**/*.md'
merge_group:
types: [checks_requested]
workflow_dispatch: {}

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: "--cfg=ci_run"
MIRIFLAGS: '-Zmiri-permissive-provenance' # Required due to warnings in bitvec 1.0.1
CI: true # insta snapshots behave differently on ci
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
# Check if changes were made to the relevant files.
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
python: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.python }}
steps:
# For pull requests it's not necessary to checkout the code
- if: github.ref_name != github.event.repository.default_branch
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
python:
- 'quantinuum-hugr-py/**'
- 'pyproject.toml'
- '!**/*.md'
check:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}

name: check python
runs-on: ubuntu-latest

Expand Down Expand Up @@ -61,8 +76,8 @@ jobs:
run: poetry run pytest

coverage:
if: github.event_name != 'merge_group'
needs: check
needs: [changes, check]
if: ${{ needs.changes.outputs.python == 'true' }} && github.event_name != 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/ci-rs-skip.yml

This file was deleted.

39 changes: 31 additions & 8 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ on:
pull_request:
branches:
- main
paths:
- 'quantinuum-hugr/**'
- 'specification/schema/**'
- 'Cargo.toml'
- '!**/*.md'
merge_group:
types: [checks_requested]
workflow_dispatch: {}
Expand All @@ -26,7 +21,32 @@ env:
RUSTC_WRAPPER: "sccache"

jobs:
# Check if changes were made to the relevant files.
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
rust: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.rust }}
steps:
# For pull requests it's not necessary to checkout the code
- if: github.ref_name != github.event.repository.default_branch
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
rust:
- 'quantinuum-hugr/**'
- 'specification/schema/**'
- 'Cargo.toml'
- '!**/*.md'
check:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -45,7 +65,8 @@ jobs:
RUSTDOCFLAGS: "-Dwarnings"

benches:
if: github.event_name != 'merge_group'
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }} && github.event_name != 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -58,6 +79,8 @@ jobs:
run: cargo bench --verbose --no-run --workspace --all-features

tests:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -93,8 +116,8 @@ jobs:
run: cargo test --verbose --workspace --all-features

coverage:
if: github.event_name != 'merge_group'
needs: [tests, check]
needs: [changes, tests, check]
if: ${{ 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 2ec0f2b

Please sign in to comment.