mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Enable automated scheduled nightly builds and Stage 2 signer dispatch (#17423)
This commit is contained in:
1 parent
73c03ddbd0
commit
77eccdff0c
4 files changed
+29
-23
No files matched your search
@@ -286,7 +286,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,8 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
dispatch:
|
||||
# SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification.
|
||||
if: >-
|
||||
false && github.repository == 'storytold/photocraft' &&
|
||||
github.repository == 'storytold/photocraft' &&
|
||||
github.event_name == 'workflow_run'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
name: PhotoCraft 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).
|
||||
# Automated scheduled nightly builds at 05:00 UTC plus manual runs by the reviewed manual actors.
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
|
||||
@@ -444,17 +444,14 @@ class TrustedSourcePreparation(unittest.TestCase):
|
||||
"details_url", "issue_types", "accepted_conditions", "required_conditions", "debt"})
|
||||
self.assertTrue(all(value is None for value in candidate["sonar"].values()), "real identity/debt is unresolved")
|
||||
|
||||
def test_scheduled_dispatch_transport_remains_explicitly_off(self):
|
||||
for name in ("nightly-dispatch.yml",):
|
||||
source = (ROOT / ".github/workflows" / name).read_text()
|
||||
jobs = source.split("\njobs:\n", 1)[1]
|
||||
headers = re.findall(r"(?m)^ (?![\s#])[^\n]+", jobs)
|
||||
conditions = job_conditions(jobs)
|
||||
with self.subTest(workflow=name):
|
||||
self.assertTrue(headers)
|
||||
self.assertEqual(len(conditions), len(headers), "every job needs a literal-off condition")
|
||||
for _, expression in conditions:
|
||||
self.assertTrue(literal_off(expression), "nightly activation requires reviewed test update")
|
||||
def test_scheduled_dispatch_watches_producer_on_main(self):
|
||||
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
producer_name = re.findall(r"(?m)^name: (.+)$", producer)
|
||||
self.assertEqual(len(producer_name), 1)
|
||||
source = DISPATCHER.read_text()
|
||||
self.assertIn(f" workflows: [{producer_name[0]}]\n", source)
|
||||
self.assertIn(" types: [completed]\n", source)
|
||||
self.assertIn(" branches: [main]\n", source)
|
||||
|
||||
def test_one_producer_and_one_signer_job_carry_every_platform(self):
|
||||
for name, job in (("nightly.yml", "unsigned"), ("nightly-sign.yml", "release")):
|
||||
@@ -496,7 +493,9 @@ class TrustedSourcePreparation(unittest.TestCase):
|
||||
(_, expression), = job_conditions(jobs)
|
||||
self.assertTrue(expression.endswith("|| true"))
|
||||
self.assertFalse(literal_off(expression))
|
||||
for name, workflow in (("nightly.yml", "nightly.yml"), ("nightly-sign.yml", "nightly-sign.yml")):
|
||||
for name, workflow in (("nightly.yml", "nightly.yml"),
|
||||
("nightly-dispatch.yml", "nightly-dispatch.yml"),
|
||||
("nightly-sign.yml", "nightly-sign.yml")):
|
||||
source = (ROOT / ".github/workflows" / workflow).read_text()
|
||||
expected = NightlyEnabledCallers.GUARDS[name]
|
||||
guard = re.search(r"(?m)^ if: >-\n(?: [^\n]*\n)+", source)[0]
|
||||
@@ -514,16 +513,19 @@ class TrustedSourcePreparation(unittest.TestCase):
|
||||
self.assertTrue(literal_off("${{ false }}"))
|
||||
self.assertTrue(literal_off("false && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')"))
|
||||
|
||||
def test_no_nightly_schedule_is_registered(self):
|
||||
for name, event in (("nightly.yml", "workflow_dispatch"),
|
||||
("nightly-dispatch.yml", "workflow_run"),
|
||||
("nightly-sign.yml", "workflow_dispatch")):
|
||||
def test_nightly_workflow_triggers_and_schedule(self):
|
||||
for name, expected in (("nightly.yml", [" schedule:", " workflow_dispatch:"]),
|
||||
("nightly-dispatch.yml", [" workflow_run:"]),
|
||||
("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")
|
||||
self.assertEqual(triggers, expected, "schedule/activation needs explicit review")
|
||||
if name == "nightly.yml":
|
||||
crons = re.findall(r"(?m)^ - cron: '([^']+)'$", events)
|
||||
self.assertEqual(crons, ["0 5 * * *"], "nightly schedule must run once daily at 05:00 UTC")
|
||||
|
||||
def test_signer_serialization_contract_is_enforced(self):
|
||||
assert_nightly_serialization((ROOT / ".github/workflows/nightly-sign.yml").read_text())
|
||||
@@ -641,6 +643,7 @@ class NightlyEnabledCallers(unittest.TestCase):
|
||||
"nightly.yml": "github.repository == 'storytold/photocraft' && github.ref == 'refs/heads/main' && "
|
||||
"github.ref_type == 'branch' && (github.event_name == 'schedule' || "
|
||||
"github.event_name == 'workflow_dispatch')",
|
||||
"nightly-dispatch.yml": "github.repository == 'storytold/photocraft' && github.event_name == 'workflow_run'",
|
||||
"nightly-sign.yml": "github.repository == 'storytold/photocraft' && github.event_name == 'workflow_dispatch' && "
|
||||
"github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'",
|
||||
}
|
||||
@@ -659,7 +662,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]"],
|
||||
"scheduled dispatch runs as github-actions[bot]")
|
||||
|
||||
def test_an_actor_outside_the_release_managers_is_refused(self):
|
||||
source = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
|
||||
Reference in new issue
Block a user