mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-02 15:01:19 -05:00
ci(nightly): enable automated 04:00 UTC schedule and Stage 2 signer dispatch (#4867)
This commit is contained in:
@@ -83,7 +83,9 @@
|
||||
}
|
||||
},
|
||||
"max_artifact_bytes": 2147483648,
|
||||
"automatic_signer_actors": [],
|
||||
"automatic_signer_actors": [
|
||||
"github-actions[bot]"
|
||||
],
|
||||
"platforms": {
|
||||
"windows-x86_64": {
|
||||
"unsigned_artifact_name": "nightly-unsigned-windows-x86_64",
|
||||
|
||||
@@ -11,9 +11,9 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
dispatch:
|
||||
# SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification.
|
||||
# Transport guard only; the protected signer-branch validator enforces full admission.
|
||||
if: >-
|
||||
false && github.repository == 'storytold/lightcraft' &&
|
||||
github.repository == 'storytold/lightcraft' &&
|
||||
github.event_name == 'workflow_run'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
name: LightCraft unsigned nightly
|
||||
|
||||
# Enabled for supervised manual runs by the reviewed manual actor only; no schedule yet.
|
||||
# A later explicit opt-in may add a cadence (and turn on nightly-dispatch.yml with it).
|
||||
# Runs automatically on the reviewed daily schedule (04:00 UTC) and on supervised manual dispatch.
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 4 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
|
||||
@@ -207,15 +207,22 @@ class TrustedSourcePreparation(unittest.TestCase):
|
||||
(indicator, expression), = job_conditions(jobs)
|
||||
self.assertFalse(indicator == ">-" and " ".join(expression.split()) == expected)
|
||||
|
||||
def test_no_nightly_schedule_is_registered(self):
|
||||
for name, event in (("nightly.yml", "workflow_dispatch"),
|
||||
("nightly-sign.yml", "workflow_dispatch")):
|
||||
source = (ROOT / ".github/workflows" / name).read_text()
|
||||
events = source.split("\non:\n", 1)[1].split("\npermissions:", 1)[0]
|
||||
triggers = [line for line in events.splitlines() if line.startswith(" ")
|
||||
and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")]
|
||||
with self.subTest(workflow=name):
|
||||
self.assertEqual(triggers, [f" {event}:"], "schedule/activation needs explicit review")
|
||||
def test_nightly_schedule_is_reviewed_and_signer_stays_dispatch_only(self):
|
||||
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
producer_events = producer.split("\non:\n", 1)[1].split("\npermissions:", 1)[0]
|
||||
producer_triggers = [line for line in producer_events.splitlines() if line.startswith(" ")
|
||||
and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")]
|
||||
self.assertEqual(producer_triggers, [" schedule:", " workflow_dispatch:"],
|
||||
"producer triggers must stay limited to the reviewed schedule and manual dispatch")
|
||||
self.assertEqual(re.findall(r"(?m)^ - cron: '([^']+)'$", producer_events), ["0 4 * * *"],
|
||||
"producer schedule must match the reviewed 04:00 UTC cadence")
|
||||
|
||||
signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
|
||||
signer_events = signer.split("\non:\n", 1)[1].split("\npermissions:", 1)[0]
|
||||
signer_triggers = [line for line in signer_events.splitlines() if line.startswith(" ")
|
||||
and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")]
|
||||
self.assertEqual(signer_triggers, [" workflow_dispatch:"],
|
||||
"signer must stay workflow_dispatch-only")
|
||||
|
||||
def test_signer_serialization_contract_is_enforced(self):
|
||||
assert_nightly_serialization((ROOT / ".github/workflows/nightly-sign.yml").read_text())
|
||||
@@ -350,7 +357,8 @@ class NightlyEnabledCallers(unittest.TestCase):
|
||||
source = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
policy = json.loads(INSTALLED_POLICY.read_text())
|
||||
self.assertEqual(reviewed_manual_actors(source, policy), RELEASE_MANAGERS)
|
||||
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
|
||||
self.assertEqual(policy["automatic_signer_actors"], ["github-actions[bot]"],
|
||||
"automatic signer actor must stay limited to github-actions[bot]")
|
||||
|
||||
def test_an_actor_outside_the_release_managers_is_refused(self):
|
||||
source = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
@@ -812,13 +820,20 @@ class NightlySignerBranchTrustClosure(unittest.TestCase):
|
||||
self.assertNotIn("refs/heads/release", sign, "the signer no longer runs on the stable branch")
|
||||
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), ["lightcraft"],
|
||||
"the shared signer needs the reviewed registry app")
|
||||
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
(producer_name,) = re.findall(r"(?m)^name: (.+)$", producer)
|
||||
dispatch = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text()
|
||||
self.assertIn(f"workflows: [{producer_name}]", dispatch,
|
||||
"dispatch transport must match the producer workflow name")
|
||||
self.assertEqual(re.findall(r"'ref': '([^']+)'", dispatch), ["refs/heads/" + SIGNER_BRANCH])
|
||||
(_, guard), = job_conditions(dispatch.split("\njobs:\n", 1)[1])
|
||||
self.assertTrue(guard.startswith("false && "), "transport stays literally off until a schedule is approved")
|
||||
self.assertEqual(" ".join(guard.split()),
|
||||
"github.repository == 'storytold/lightcraft' && github.event_name == 'workflow_run'",
|
||||
"dispatch transport stays gated to this repository's workflow_run events")
|
||||
policy = json.loads(INSTALLED_POLICY.read_text())
|
||||
self.assertEqual(policy["release_branch"], SIGNER_BRANCH)
|
||||
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
|
||||
self.assertEqual(policy["automatic_signer_actors"], ["github-actions[bot]"],
|
||||
"automatic signer actor must stay limited to github-actions[bot]")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user