Skip to content

Commit 1e4a688

Browse files
committed
up
1 parent 2d0350d commit 1e4a688

5 files changed

Lines changed: 74 additions & 24 deletions

File tree

.github/workflows/_ci-run-decision.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ name: CI Run Decision
77
# Returns ``is-full-run = 'true'`` for:
88
# - workflow_dispatch (manual run)
99
# - ciflow/* tag pushes (maintainer-forced full run)
10-
# - push events whose SHA is in the deterministic 25% sample
11-
# (last hex char in {0,4,8,c})
10+
# - push events at every 4th commit by depth from main's root
11+
# (deterministic 25% sample, hard cap of 4 commits between samples)
1212
#
1313
# Returns ``is-full-run = 'false'`` for:
1414
# - pull_request / pull_request_target (use path filter instead)
@@ -25,12 +25,23 @@ on:
2525
description: "'true' if this commit should run all CI jobs regardless of path filter; 'false' otherwise."
2626
value: ${{ jobs.decide.outputs.is-full-run }}
2727

28+
permissions:
29+
contents: read
30+
2831
jobs:
2932
decide:
3033
runs-on: ubuntu-latest
3134
outputs:
3235
is-full-run: ${{ steps.compute.outputs.is-full-run }}
3336
steps:
37+
# Full history needed to compute commit depth via `git rev-list --count`.
38+
# The depth-based sample (every 4th commit) needs the SHA to be reachable
39+
# from the repo root.
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
3445
- name: Compute is-full-run
3546
id: compute
3647
env:
@@ -54,12 +65,17 @@ jobs:
5465
;;
5566
esac
5667
57-
# Deterministic 25% sample on push: SHA's last hex char in {0,4,8,c}.
58-
# Keep in sync with the sample in viable-strict-gate.yml.
68+
# Depth-based 25% sample on push: every 4th commit (depth from
69+
# the repo root, mod 4 == 0). Hard guarantees:
70+
# - Exactly 25% sample rate (no statistical variance).
71+
# - At most 3 non-sampled commits between any two samples.
72+
# Re-runs of the same commit always have the same outcome.
5973
if [ "$IS_FULL" = "false" ] && [ "$EVENT_NAME" = "push" ]; then
60-
case "$SHA" in
61-
*0|*4|*8|*c) IS_FULL=true ;;
62-
esac
74+
DEPTH=$(git rev-list --count "$SHA")
75+
if [ $((DEPTH % 4)) -eq 0 ]; then
76+
IS_FULL=true
77+
fi
78+
echo "Depth: $DEPTH (depth %% 4 = $((DEPTH % 4)))"
6379
fi
6480
6581
echo "Event: $EVENT_NAME"

.github/workflows/mlx.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ concurrency:
2525
permissions: {}
2626

2727
jobs:
28+
# Emits is-full-run='true' for workflow_dispatch / ciflow tag /
29+
# sampled-push commits (every 4th main/release commit by depth).
30+
# Returns 'false' for pull_request events — PR jobs use the workflow-
31+
# level `paths:` filter (above) for path-based gating instead.
32+
run-decision:
33+
name: CI run decision
34+
uses: ./.github/workflows/_ci-run-decision.yml
35+
2836
test-mlx:
37+
needs: run-decision
38+
if: |
39+
github.event_name == 'pull_request' ||
40+
needs.run-decision.outputs.is-full-run == 'true'
2941
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
3042
with:
3143
default-packages: ""
@@ -93,6 +105,10 @@ jobs:
93105
echo "::endgroup::"
94106
95107
test-mlx-qwen35-moe:
108+
needs: run-decision
109+
if: |
110+
github.event_name == 'pull_request' ||
111+
needs.run-decision.outputs.is-full-run == 'true'
96112
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
97113
with:
98114
default-packages: ""
@@ -145,6 +161,10 @@ jobs:
145161
echo "::endgroup::"
146162
147163
backend-tester:
164+
needs: run-decision
165+
if: |
166+
github.event_name == 'pull_request' ||
167+
needs.run-decision.outputs.is-full-run == 'true'
148168
strategy:
149169
fail-fast: false
150170
matrix:
@@ -191,6 +211,10 @@ jobs:
191211
fi
192212
193213
test-mlx-parakeet:
214+
needs: run-decision
215+
if: |
216+
github.event_name == 'pull_request' ||
217+
needs.run-decision.outputs.is-full-run == 'true'
194218
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
195219
with:
196220
default-packages: ""
@@ -248,7 +272,10 @@ jobs:
248272
# Requires HuggingFace secrets — skip on fork PRs.
249273
# Maintainers can opt-in by applying the ciflow/mlx label, which
250274
# pushes a ciflow/mlx/<PR> tag that re-runs this workflow with secrets.
251-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
275+
needs: run-decision
276+
if: |
277+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
278+
(github.event_name == 'pull_request' || needs.run-decision.outputs.is-full-run == 'true')
252279
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
253280
secrets: inherit
254281
with:
@@ -309,7 +336,10 @@ jobs:
309336
test-mlx-voxtral-realtime:
310337
# Requires HuggingFace secrets — skip on fork PRs.
311338
# Maintainers can opt-in by applying the ciflow/mlx label.
312-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
339+
needs: run-decision
340+
if: |
341+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
342+
(github.event_name == 'pull_request' || needs.run-decision.outputs.is-full-run == 'true')
313343
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
314344
secrets: inherit
315345
with:
@@ -387,7 +417,10 @@ jobs:
387417
test-mlx-whisper:
388418
# Requires HuggingFace secrets — skip on fork PRs.
389419
# Maintainers can opt-in by applying the ciflow/mlx label.
390-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
420+
needs: run-decision
421+
if: |
422+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
423+
(github.event_name == 'pull_request' || needs.run-decision.outputs.is-full-run == 'true')
391424
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
392425
secrets: inherit
393426
with:
@@ -439,6 +472,10 @@ jobs:
439472
440473
441474
test-mlx-stories110m:
475+
needs: run-decision
476+
if: |
477+
github.event_name == 'pull_request' ||
478+
needs.run-decision.outputs.is-full-run == 'true'
442479
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
443480
with:
444481
default-packages: ""
@@ -505,7 +542,10 @@ jobs:
505542
test-mlx-llm:
506543
# Requires HuggingFace secrets — skip on fork PRs.
507544
# Maintainers can opt-in by applying the ciflow/mlx label.
508-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
545+
needs: run-decision
546+
if: |
547+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
548+
(github.event_name == 'pull_request' || needs.run-decision.outputs.is-full-run == 'true')
509549
strategy:
510550
fail-fast: false
511551
matrix:

.github/workflows/pull.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ jobs:
2121
name: Get changed files
2222
uses: ./.github/workflows/_get-changed-files.yml
2323

24-
# Emits is-full-run='true' for PR/dispatch/tag/sampled-push commits
25-
# (the ~25% of pushes that should run full CI) and 'false' otherwise.
26-
# Per-job `if:` checks this to bypass path filtering on full-run
27-
# commits while staying path-filtered on the 75% non-sampled pushes.
2824
run-decision:
2925
name: CI run decision
3026
uses: ./.github/workflows/_ci-run-decision.yml

.github/workflows/trunk.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,13 @@ jobs:
2525
name: Get changed files
2626
uses: ./.github/workflows/_get-changed-files.yml
2727

28-
# Emits is-full-run='true' for PR/dispatch/tag/sampled-push commits
29-
# (the ~25% of pushes that should run full CI) and 'false' otherwise.
30-
# Per-job `if:` checks this to bypass path filtering on full-run
31-
# commits while staying path-filtered on the 75% non-sampled pushes.
3228
run-decision:
3329
name: CI run decision
3430
uses: ./.github/workflows/_ci-run-decision.yml
3531

3632
test-models-macos-cpu:
3733
name: test-models-macos-cpu
3834
needs: run-decision
39-
# Path-filter-on-push (sampled): runs on every PR / dispatch /
40-
# ciflow tag, and on ~25% of pushes via _ci-run-decision.yml.
41-
# The viable-strict-gate workflow blocks viable/strict from
42-
# advancing on the 75% non-sampled pushes.
4335
if: |
4436
github.event_name == 'pull_request' ||
4537
needs.run-decision.outputs.is-full-run == 'true'
@@ -397,6 +389,10 @@ jobs:
397389
398390
test-llama-torchao-lowbit:
399391
name: test-llama-torchao-lowbit
392+
needs: run-decision
393+
if: |
394+
github.event_name == 'pull_request' ||
395+
needs.run-decision.outputs.is-full-run == 'true'
400396
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
401397
with:
402398
default-packages: ""

.github/workflows/viable-strict-gate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ on:
2525
tags:
2626
- ciflow/trunk/*
2727

28+
permissions: {}
29+
2830
jobs:
2931
run-decision:
3032
uses: ./.github/workflows/_ci-run-decision.yml
@@ -44,6 +46,6 @@ jobs:
4446
exit 0
4547
fi
4648
echo "::error::Non-full-run commit (path-filtered CI). viable/strict cannot advance from this commit."
47-
echo "Full CI runs on commits whose SHA ends in 0, 4, 8, or c (~25% of commits)."
49+
echo "Full CI runs on every 4th commit on main / release/* (depth %% 4 == 0)."
4850
echo "To force a full run on this commit, push a 'ciflow/trunk/${{ github.sha }}' tag."
4951
exit 1

0 commit comments

Comments
 (0)