Skip to content

Commit cae018a

Browse files
authored
ci: stop running CI twice on internal PRs (dfinity#3804)
Since dfinity#3782 added a `pull_request` trigger, every commit on an internal PR branch fires **both** `push` and `pull_request`, running every CI job twice. This PR scopes the `push` trigger so PR branches fire only `pull_request`, eliminating the duplicate runs. ## Changes - [canister-tests.yml](.github/workflows/canister-tests.yml): `push` → `branches: [main]` + `tags: ['release-*']` - [frontend-checks.yml](.github/workflows/frontend-checks.yml): `push` → `branches: [main]` - [rust.yml](.github/workflows/rust.yml): `push` → `branches: [main]` ## When each trigger fires after this change | Scenario | `push` | `pull_request` | |---|---|---| | Push to internal PR branch | — | ✓ | | Push to fork PR branch | — | ✓ | | Merge to `main` | ✓ | — | | Push release tag (`release-*`) | ✓ (canister-tests only) | — | Release flow, main-branch post-merge CI, and fork PR CI are preserved. ## Caveat — auto-commit formatting The `cargo-fmt` auto-commit in `rust.yml` and the `Commit type interfaces` step in `frontend-checks.yml` were previously gated on `push` to non-`main` branches. Since `push` no longer fires on feature branches, these steps are now inert. The conditions have been tightened so they cannot spuriously fire on tag pushes. Re-enabling them for same-repo PRs is possible but requires adjusting the `checkout` ref and token handling, which is out of scope here — please run `cargo fmt` / `npm run generate` locally until that follow-up lands.
1 parent 711ccd8 commit cae018a

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/canister-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ name: Canister tests
55

66
on:
77
push:
8+
branches: [main]
9+
tags: ['release-*']
810
pull_request:
11+
merge_group:
912

1013
jobs:
1114
#####################

.github/workflows/frontend-checks.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Frontend checks and lints
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
7+
merge_group:
68

79
jobs:
810
frontend-checks:
@@ -38,9 +40,9 @@ jobs:
3840
done < <(jq <src/frontend/src/flows/dappsExplorer/dapps.json -cMr '.[] | .logo' )
3941
- name: Commit type interfaces
4042
uses: EndBug/add-and-commit@v9
41-
# We don't want to commit automatic changes to main, and we can't
42-
# push to fork PRs (read-only token).
43-
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
43+
# Push only fires on `main` now, so this is inert. Preserved for
44+
# reference; re-enable by gating on a suitable event.
45+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main' }}
4446
with:
4547
add: |
4648
src/frontend/generated

.github/workflows/rust.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: Rust
33

44
on:
55
push:
6+
branches: [main]
67
pull_request:
8+
merge_group:
79

810
jobs:
911
cargo-fmt:
@@ -29,9 +31,9 @@ jobs:
2931
3032
- name: Commit Formatting changes
3133
uses: EndBug/add-and-commit@v9
32-
# We don't want to commit formatting changes to main, and we can't
33-
# push to fork PRs (read-only token).
34-
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
34+
# Push only fires on `main` and release tags now, so this is inert.
35+
# Preserved for reference; re-enable by gating on a suitable event.
36+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main' }}
3537
with:
3638
add: "**/*.rs"
3739
default_author: github_actions

0 commit comments

Comments
 (0)