From d5688e065509ccebb05729c497ff9cc8afcb0df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20David=20M=C3=BCller?= <57191390+t0mdavid-m@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:43:01 +0100 Subject: [PATCH 1/2] Tests: skip the image-format test in apps without the example upload page (#680) Claude-Session: https://claude.ai/code/session_01FkEGenxrb62G7LTE9LLm5Q Co-authored-by: Claude --- tests/test_insight_image_format.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_insight_image_format.py b/tests/test_insight_image_format.py index 895062f7..3a14d8b7 100644 --- a/tests/test_insight_image_format.py +++ b/tests/test_insight_image_format.py @@ -20,6 +20,12 @@ PAGE = str(ROOT / "content" / "file_upload.py") +# The example app's upload page. An app that replaced the example has no such +# page and gets this test through the template sync, so it is skipped there. +pytestmark = pytest.mark.skipif( + not Path(PAGE).exists(), reason="the example app's upload page is not part of this app" +) + @pytest.fixture def app(tmp_path): From ae36a45e69d613e70ac112bced72d042e16ba526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20David=20M=C3=BCller?= <57191390+t0mdavid-m@users.noreply.github.com> Date: Fri, 4 Dec 2026 15:53:08 +0100 Subject: [PATCH 2/2] Let a release's desktop build start again: grant the image build its pull-request read (#686) build-and-test.yml asks for pull-requests: read since the opt-in image check, and build-desktop-app.yaml calls it from publish-web-image without granting it, so GitHub refused to start every desktop build (startup_failure): no installers for v2.6.0 or the apps' releases. A test now checks that each call of a reusable workflow grants what it asks. Claude-Session: https://claude.ai/code/session_01FkEGenHCNd1NVUhPTRbZhz Co-authored-by: Claude --- .github/workflows/build-desktop-app.yaml | 3 ++ tests/test_reusable_workflow_permissions.py | 58 +++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/test_reusable_workflow_permissions.py diff --git a/.github/workflows/build-desktop-app.yaml b/.github/workflows/build-desktop-app.yaml index dcc49187..d8ecf0ab 100644 --- a/.github/workflows/build-desktop-app.yaml +++ b/.github/workflows/build-desktop-app.yaml @@ -568,8 +568,11 @@ jobs: publish-web-image: needs: release if: github.event_name == 'release' && !cancelled() && needs.release.result == 'success' + # Every permission a job of build-and-test.yml asks for has to be granted + # here, or GitHub refuses to start the whole run (startup_failure). permissions: contents: read packages: write + pull-requests: read uses: ./.github/workflows/build-and-test.yml secrets: inherit diff --git a/tests/test_reusable_workflow_permissions.py b/tests/test_reusable_workflow_permissions.py new file mode 100644 index 00000000..35d32288 --- /dev/null +++ b/tests/test_reusable_workflow_permissions.py @@ -0,0 +1,58 @@ +"""A job that calls a reusable workflow must grant every permission the called +workflow's jobs ask for. GitHub otherwise refuses to start the whole calling +run (startup_failure), which once kept a release's desktop installers from +being built at all.""" + +from pathlib import Path + +import pytest +import yaml + +WORKFLOWS = Path(".github/workflows") +LEVELS = {"none": 0, "read": 1, "write": 2} + + +def _load(path): + return yaml.safe_load(path.read_text(encoding="utf-8")) + + +def _perms(block): + if block is None: + return {} + if isinstance(block, str): # read-all / write-all + return {"*": block.split("-")[0]} + return dict(block) + + +def _calls(): + for path in sorted(WORKFLOWS.glob("*.y*ml")): + doc = _load(path) + top = _perms(doc.get("permissions")) + for name, job in (doc.get("jobs") or {}).items(): + uses = job.get("uses", "") + if uses.startswith("./.github/workflows/"): + granted = _perms(job["permissions"]) if "permissions" in job else top + yield path.name, name, Path(uses), granted + + +def _requested(called): + doc = _load(called) + wanted = dict(_perms(doc.get("permissions"))) + for job in (doc.get("jobs") or {}).values(): + for scope, level in _perms(job.get("permissions")).items(): + if LEVELS[level] > LEVELS.get(wanted.get(scope, "none"), 0): + wanted[scope] = level + return wanted + + +CALLS = list(_calls()) + + +@pytest.mark.parametrize("caller,job,called,granted", CALLS, ids=[f"{c}:{j}" for c, j, _, _ in CALLS]) +def test_caller_grants_what_the_called_workflow_needs(caller, job, called, granted): + missing = { + scope: level + for scope, level in _requested(called).items() + if LEVELS[level] > LEVELS.get(granted.get(scope, granted.get("*", "none")), 0) + } + assert not missing, f"{caller} job {job} calls {called.name} without granting {missing}"