Skip to content

Commit db0be5c

Browse files
authored
feat(ci-lint): gate requires init, perf, release-verify and publish jobs when selected (#26)
The template's round-4 follow-up adds a from-zero init job ([ci-test-init]), and round 5 adds perf, release-verify and publish jobs. required_jobs now names them when the plan selects the matching suite or publish mode, so CI OK cannot go green without them.
1 parent e9f39ab commit db0be5c

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎ci_lint/plan.py‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ def to_json_dict(self) -> dict[str, object]:
125125
}
126126

127127

128-
def _required_job_ids(needs_platform_lanes: bool, dylint_targets: tuple[str, ...]) -> tuple[str, ...]:
128+
def _required_job_ids(
129+
needs_platform_lanes: bool,
130+
dylint_targets: tuple[str, ...],
131+
suites: tuple[str, ...] = (),
132+
publish: str = "none",
133+
) -> tuple[str, ...]:
129134
"""The job `id:`s (`needs:` keys) `ci-lint gate` requires to have
130135
`result == "success"` (round-2A brief, part 2d; amended by the
131136
orchestrator's round-2A amendment 1). This is the one place that
@@ -140,6 +145,17 @@ def _required_job_ids(needs_platform_lanes: bool, dylint_targets: tuple[str, ...
140145
platform); GitHub aggregates every matrix leg into a single
141146
`needs.<id>.result`, so one id each covers the whole matrix.
142147
148+
- "init" when the `init` suite is selected -- the from-zero job
149+
(no cache restore, template instantiation), which must run in its
150+
own job because it may not share any restored cache.
151+
- "perf" when the `perf` suite is selected (its job must succeed even
152+
when the suite is non-gating; gating only decides whether a
153+
regression fails it).
154+
- "release-verify" when publish is "rehearsal" or "mock" -- the
155+
staged-artifact completeness check (`ci_lint release verify`).
156+
- "publish" when publish is "mock" -- the top-level OIDC mock
157+
publisher (PyPI cannot trust a reusable workflow, warehouse#11096).
158+
143159
"ci-ok" (the gate job itself) is never in this list -- a job cannot
144160
require its own result.
145161
"""
@@ -150,6 +166,14 @@ def _required_job_ids(needs_platform_lanes: bool, dylint_targets: tuple[str, ...
150166
if needs_platform_lanes:
151167
jobs.append("platform-build")
152168
jobs.append("platform-run")
169+
if "init" in suites:
170+
jobs.append("init")
171+
if "perf" in suites:
172+
jobs.append("perf")
173+
if publish in ("rehearsal", "mock"):
174+
jobs.append("release-verify")
175+
if publish == "mock":
176+
jobs.append("publish")
153177
return tuple(jobs)
154178

155179

@@ -456,7 +480,7 @@ def compute_plan(
456480
mergeable=mergeable,
457481
digest=digest,
458482
reasons=tuple(reasons),
459-
required_jobs=_required_job_ids(needs_platform_lanes, dylint_targets),
483+
required_jobs=_required_job_ids(needs_platform_lanes, dylint_targets, final_suites, publish),
460484
needs_platform_lanes=needs_platform_lanes,
461485
dispatch_sha=dispatch_sha,
462486
platform_lanes=platform_lanes,

‎ci_lint/tests/test_plan.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,28 @@ def test_to_json_dict_carries_the_new_fields(self) -> None:
254254

255255
if __name__ == "__main__":
256256
unittest.main()
257+
258+
259+
class RequiredJobsForSuitesAndPublishTest(unittest.TestCase):
260+
"""Round-4 follow-up: the gate must also require the from-zero `init`
261+
job, the `perf` job, and the release jobs when the plan selects them."""
262+
263+
def test_suite_and_publish_jobs(self) -> None:
264+
from ci_lint.plan import _required_job_ids
265+
266+
base = ("precheck", "fast", "dylint")
267+
self.assertEqual(_required_job_ids(False, ("t",), ("smoke", "unit"), "none"), base)
268+
self.assertEqual(
269+
_required_job_ids(False, ("t",), ("init", "smoke", "unit"), "none"), base + ("init",)
270+
)
271+
self.assertEqual(
272+
_required_job_ids(False, ("t",), ("perf", "unit"), "none"), base + ("perf",)
273+
)
274+
self.assertEqual(
275+
_required_job_ids(True, ("t",), ("unit",), "rehearsal"),
276+
base + ("platform-build", "platform-run", "release-verify"),
277+
)
278+
self.assertEqual(
279+
_required_job_ids(True, ("t",), ("unit",), "mock"),
280+
base + ("platform-build", "platform-run", "release-verify", "publish"),
281+
)

‎docs/ci-toml.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ defined; the template's `ci.yml` must name its jobs to match:
666666
| `dylint` | when `dylint_targets` is non-empty | the one Linux Dylint job (all declared targets) |
667667
| `platform-build` | when `needs_platform_lanes` | the Linux cross-build matrix job -- GitHub aggregates every matrix leg into one `needs.platform-build.result` |
668668
| `platform-run` | when `needs_platform_lanes` | the native-runner execute matrix job -- same aggregation |
669+
| `init` | when the `init` suite is selected | the from-zero job: no cache restore, template instantiation, precheck + build + smoke of the generated repo |
670+
| `perf` | when the `perf` suite is selected | the perf job; it must succeed even when the suite is non-gating (gating only decides whether a regression fails it) |
671+
| `release-verify` | when `publish` is `rehearsal` or `mock` | staged-artifact completeness (`ci-lint release verify`) |
672+
| `publish` | when `publish` is `mock` | the top-level OIDC mock publisher (PyPI can't trust a reusable workflow, warehouse#11096) |
669673

670674
`ci-ok` (the gate job itself) is **never** in `required_jobs` -- a job
671675
cannot require its own result.

0 commit comments

Comments
 (0)