Skip to content

Add a prek hook to keep scheduled workflows skipping in forks - #76267

Merged
potiuk merged 2 commits into
apache:mainfrom
justinpakzad:feature/add-prek-hook-for-scheduled-wf-guard
Nov 15, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
justinpakzad:feature/add-prek-hook-for-scheduled-wf-guard

Conversation

@justinpakzad

Copy link
Copy Markdown
Contributor

#76243 Added a guard to skip scheduled workflows in forks that enable Actions. This is a follow up PR that adds a prek hook to ensure any new scheduled workflows get the same guard. A job passes when its own if: has the apache/airflow guard, or when it needs a job that passes it and doesn't override the skip with always(), cancelled() or failure().

Couple of notes worth mentioning - The ci-amd.yml and ci-arm.yml files exempt since they need to run in forks on push, and their check-run-needed step already skips scheduled runs there. The check is textual so it catches a missing guard, but a guard ORed with something thats true in forks (like github.event_name == 'schedule' || ...) would still pass. None of the current workflows do that anyway and I don't think it's worth the additional complexity of trying to account for that.

Example (I modified some of the files locally to intentionally fail it):
Screenshot 2026-11-01 at 20 09 07

Was generative AI tooling used to co-author this PR?
  • Yes (Claude Opus 5.5)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@github-actions github-actions Bot added fork ci required Gated by AIP-120: CI must pass in the contributor's fork. Managed by the fork CI reconciler. need workflow approval labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Your CI change needs a maintainer. CI for this pull request runs in your fork, and the workflow runs it starts in apache/airflow are approved automatically while they only run the fork CI gate. This pull request changes files that define what CI runs:

  • .pre-commit-config.yaml
  • dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
  • scripts/ci/prek/check_scheduled_workflows_skip_forks.py

Such a change can make project CI run on the project's runners, so its workflow runs in apache/airflow wait for a maintainer to review the change and approve them. CI in your fork is not affected, and its result stays visible on this pull request. Pull requests from contributors run their CI in the contributor's own fork. GitHub Actions is free and has no minute limit on public forks, while the CI capacity of the Apache Software Foundation is shared by every ASF project and is finite.


This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated.

@github-actions github-actions Bot added the needs project ci Green fork CI, but CI files changed: a maintainer reviews and adds use project ci. label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Project CI in use. A maintainer added the use project ci label, so CI for this pull request runs in apache/airflow. It starts on the next push, or when a maintainer closes and reopens this pull request.


This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated.

@github-actions
github-actions Bot marked this pull request as draft November 2, 2026 02:24
@justinpakzad
justinpakzad force-pushed the feature/add-prek-hook-for-scheduled-wf-guard branch from 9435bf2 to 76cc488 Compare November 2, 2026 21:44
@github-actions github-actions Bot added needs project ci Green fork CI, but CI files changed: a maintainer reviews and adds use project ci. and removed needs project ci Green fork CI, but CI files changed: a maintainer reviews and adds use project ci. labels Nov 2, 2026
@github-actions
github-actions Bot marked this pull request as ready for review November 3, 2026 19:20
justinpakzad and others added 2 commits November 15, 2026 13:48
A job whose condition uses a status function such as `!cancelled()` still
skips in forks when the condition also requires a guarded job it needs to
have succeeded, as `trigger-upgrade-check` in
mirror-hardened-base-images.yml does, so the check no longer reports it.
The docstring also no longer says ci-arm.yml runs in forks on push.

Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the feature/add-prek-hook-for-scheduled-wf-guard branch from 76cc488 to a2530df Compare November 15, 2026 04:51
@potiuk potiuk added the use project ci Committer override: run project CI for a PR that fork CI would otherwise gate. label Nov 15, 2026
@github-actions github-actions Bot removed the needs project ci Green fork CI, but CI files changed: a maintainer reviews and adds use project ci. label Nov 15, 2026
@github-actions github-actions Bot removed the fork ci required Gated by AIP-120: CI must pass in the contributor's fork. Managed by the fork CI reconciler. label Nov 15, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks - the rules for needs: and status functions match how GitHub skips jobs. I rebased the branch on main and pushed a fixup (a2530df) instead of asking for another round:

  • Rebased on main: the branch was 389 commits behind, and main has since gained a scheduled job (trigger-upgrade-check in mirror-hardened-base-images.yml, from #76225) that the hook reported although it skips in forks: its condition starts with !cancelled() but also requires the guarded build-info to succeed.
  • scripts/ci/prek/check_scheduled_workflows_skip_forks.py: a job whose condition uses always(), cancelled() or failure() now passes when the condition also requires a covered job it needs to succeed (needs.<job>.result == 'success'). The hook passes on every workflow on current main.
  • scripts/tests/ci/prek/test_check_scheduled_workflows_skip_forks.py: three cases for that shape - a required covered parent, a required uncovered parent, and a required job the job does not need.
  • The module docstring no longer says ci-arm.yml runs in forks on push: it has only schedule and workflow_dispatch, and both exempt workflows rely on check-run-needed to skip scheduled runs in forks.

As the change touches CI files, I also added use project ci so project CI verifies it.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

@potiuk
potiuk enabled auto-merge (squash) November 15, 2026 04:58
@justinpakzad

Copy link
Copy Markdown
Contributor Author

Thanks - the rules for needs: and status functions match how GitHub skips jobs. I rebased the branch on main and pushed a fixup (a2530df) instead of asking for another round:

  • Rebased on main: the branch was 389 commits behind, and main has since gained a scheduled job (trigger-upgrade-check in mirror-hardened-base-images.yml, from Build CI and release images on pinned OS-dependencies images #76225) that the hook reported although it skips in forks: its condition starts with !cancelled() but also requires the guarded build-info to succeed.
  • scripts/ci/prek/check_scheduled_workflows_skip_forks.py: a job whose condition uses always(), cancelled() or failure() now passes when the condition also requires a covered job it needs to succeed (needs.<job>.result == 'success'). The hook passes on every workflow on current main.
  • scripts/tests/ci/prek/test_check_scheduled_workflows_skip_forks.py: three cases for that shape - a required covered parent, a required uncovered parent, and a required job the job does not need.
  • The module docstring no longer says ci-arm.yml runs in forks on push: it has only schedule and workflow_dispatch, and both exempt workflows rely on check-run-needed to skip scheduled runs in forks.

As the change touches CI files, I also added use project ci so project CI verifies it.

Appreciate the review as always. Thanks for pushing the fixup as well!

@potiuk
potiuk merged commit 71f6e9b into apache:main Nov 15, 2026
76 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

potiuk added a commit that referenced this pull request Nov 15, 2026
…orks (#76267) (#77104)

* Add a prek hook to keep scheduled workflows skipping in forks

* Accept a scheduled job that requires a guarded job to succeed

A job whose condition uses a status function such as `!cancelled()` still
skips in forks when the condition also requires a guarded job it needs to
have succeeded, as `trigger-upgrade-check` in
mirror-hardened-base-images.yml does, so the check no longer reports it.
The docstring also no longer says ci-arm.yml runs in forks on push.

Generated-by: Claude Opus 5

---------
(cherry picked from commit 71f6e9b)

Co-authored-by: Justin Pakzad <114518232+justinpakzad@users.noreply.github.com>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
potiuk added a commit that referenced this pull request Nov 15, 2026
* [v3-4-test] Sync fork CI changes from main

Several fork CI changes merged to main since the last sync never reached
v3-4-test, and the fork CI monitor reads the gate configuration of a pull
request's base branch, so pull requests to v3-4-test were still closed
after 7 days and missed ten pilot participants. The fork CI modules, their
tests, the design document and its diagrams, the monitor workflow, the
gate configuration checks and the contributor documentation now match
main, taking in #75814, #75696, #76272, #76316, #76327, #76510, #76538,
#76677, #76681, #76835, #76836, #76837, #76839, #76841, #76866, #76267 and
#77100.

The pilot participants new to this branch join at 2026-11-16 00:00 UTC
rather than at their main dates, as the gate configuration check requires
a future instant for an entry that is new on the base branch.

Generated-by: Claude Opus 5

* [v3-4-test] Say the fork CI monitor runs every 5 minutes in the CI tasks doc

The sentence changed with #76836 on main and was missed by the sync.

Generated-by: Claude Opus 5

* [v3-4-test] Bring the fork CI GitHub client tests in line with main

The tests for the smaller job listing pages (#76327) were missed by the
sync; the client code they cover is already in it.

Generated-by: Claude Opus 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-4-test Backport to v3-4-test use project ci Committer override: run project CI for a PR that fork CI would otherwise gate.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants