From 5a9c543d77b6399c9f382752161d135a5bfc0e6b Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 01:00:47 +0100 Subject: [PATCH 1/7] ci: prepare Domus validation for self-hosted runners --- .github/workflows/ci_check.yml | 146 ++++++++++++++++++++--------- docs/development.md | 14 ++- tests/browser/image_bridge.py | 2 + tests/containers/test_app_image.py | 5 +- tests/python/test_ci_contract.py | 82 +++++++++++----- 5 files changed, 176 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index ff2e0485..d9e4a72c 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -14,7 +14,9 @@ permissions: jobs: python: name: Python tooling - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -43,7 +45,9 @@ jobs: backend: name: Backend application - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -72,7 +76,9 @@ jobs: node: name: Node architecture policy - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -100,7 +106,9 @@ jobs: frontend_toolchain: name: Frontend toolchain - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 15 env: CI: "1" @@ -122,8 +130,8 @@ jobs: - run: pnpm check:frontend-toolchain - run: pnpm test:frontend-toolchain - run: pnpm build:frontend-toolchain - - run: pnpm test:frontend-browser - - run: pnpm test:frontend-guards + - run: flock -w 600 /tmp/domus-ci-toolchain-browser.lock pnpm test:frontend-browser + - run: flock -w 600 /tmp/domus-ci-toolchain-browser.lock pnpm test:frontend-guards - name: Retain distinct framework fixture outputs and coverage if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -140,7 +148,9 @@ jobs: frontend: name: Frontend application - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 15 env: CI: "1" @@ -168,9 +178,9 @@ jobs: - run: pnpm build:frontend - run: uv build --package domus-server --wheel - run: uv run pytest tests/packaging --no-cov - - run: pnpm test:frontend-entry + - run: flock -w 600 /tmp/domus-ci-entry-browser.lock pnpm test:frontend-entry - run: pnpm build:frontend-catalog - - run: pnpm test:frontend-catalog + - run: flock -w 600 /tmp/domus-ci-catalog-browser.lock pnpm test:frontend-catalog - name: Retain distinct application coverage if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -188,7 +198,9 @@ jobs: architecture: name: Python architecture contracts - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -205,7 +217,9 @@ jobs: documentation: name: Local documentation links - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -224,12 +238,23 @@ jobs: fail-fast: false matrix: include: - - runner: ubuntu-latest - arch: amd64 - - runner: ubuntu-24.04-arm - arch: aarch64 - runs-on: ${{ matrix.runner }} - timeout-minutes: 20 + - arch: amd64 + platform: linux/amd64 + machine: x86_64 + core_digest: sha256:21935614df6d9f24f680a1ef749f0570d2d6b7936c606c0a44253ae875865c04 + - arch: aarch64 + platform: linux/arm64 + machine: aarch64 + core_digest: sha256:5881590fca108a6e6b5eb9fff1718baeddda9d6dd5b52d1594e3386fe33b4d66 + runs-on: + group: vypdev + labels: [self-hosted, macOS, ARM64] + env: + DOCKER_DEFAULT_PLATFORM: ${{ matrix.platform }} + DOMUS_IMAGE_PREFIX: domus-ci-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.arch }} + # Platform manifests from the immutable Core 2026.10.4 index. + DOMUS_HA_CORE_IMAGE: ghcr.io/home-assistant/home-assistant@${{ matrix.core_digest }} + timeout-minutes: 45 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -239,25 +264,44 @@ jobs: version: "0.11.29" enable-cache: false - run: uv sync --frozen + - name: Prepare this job's Docker client and verify image execution + shell: bash + env: + DOMUS_EXPECTED_MACHINE: ${{ matrix.machine }} + run: | + set -euo pipefail + docker_host=$(docker context inspect --format '{{.Endpoints.docker.Host}}') + docker_config=$(mktemp -d "$RUNNER_TEMP/domus-docker.XXXXXX") + { + printf 'DOCKER_HOST=%s\n' "$docker_host" + printf 'DOCKER_CONFIG=%s\n' "$docker_config" + printf 'DOCKER_CONTEXT=\n' + printf 'DOMUS_CI_DOCKER_CONFIG=%s\n' "$docker_config" + } >> "$GITHUB_ENV" + export DOCKER_HOST="$docker_host" DOCKER_CONFIG="$docker_config" + unset DOCKER_CONTEXT + docker pull "$DOMUS_HA_CORE_IMAGE" + machine=$(docker run --rm --network none --entrypoint uname "$DOMUS_HA_CORE_IMAGE" -m) + test "$machine" = "$DOMUS_EXPECTED_MACHINE" - name: Build the installed immutable Edge.5 image for schema-7 compatibility - run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t domus-app-edge5 tests/fixtures/edge5-app + run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge5" tests/fixtures/edge5-app - name: Build the actual reviewed Edge preview installed by the Supervisor - run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t domus-app-edge addon-edge + run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge" addon-edge - name: Build the immutable published schema-8 image for profile migration compatibility run: >- docker build --build-arg BUILD_ARCH=${{ matrix.arch }} - -t domus-app-schema8 tests/fixtures/schema8-app + -t "$DOMUS_IMAGE_PREFIX:schema8" tests/fixtures/schema8-app - name: Build the immutable compatible schema-9 rollback application run: >- docker build --build-arg BUILD_ARCH=${{ matrix.arch }} - -t domus-app-schema9 tests/fixtures/schema9-app + -t "$DOMUS_IMAGE_PREFIX:schema9" tests/fixtures/schema9-app - name: Build the exact checked-out source and frontend run: >- docker build --file tests/fixtures/current-app/Dockerfile --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg DOMUS_SOURCE_COMMIT=${{ github.sha }} --build-arg BUILD_VERSION=ci-current - -t domus-app-ci . + -t "$DOMUS_IMAGE_PREFIX:current" . - name: Check out the original schema-14 application uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -271,33 +315,30 @@ jobs: --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg DOMUS_SOURCE_COMMIT=449dc04c17a9c41d949d74cd341bf1e943a2fba9 --build-arg BUILD_VERSION=ci-schema14 - -t domus-app-schema14 . + -t "$DOMUS_IMAGE_PREFIX:schema14" . - name: Build the immutable previous image for upgrade and downgrade checks run: >- docker build --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg BUILD_VERSION=0.0.0-edge.2 --build-arg DOMUS_SOURCE_COMMIT=d013cf2c8b932d0e00f5858053cbc0e663d5eee1 --build-arg DOMUS_SOURCE_SHA256=fa58d457bef8a863a1943b4e6ba5c9513da8d3baa8b0a033bdcbe7bf11b09c6c - -t domus-app-previous tests/fixtures/edge3-app + -t "$DOMUS_IMAGE_PREFIX:previous" tests/fixtures/edge3-app - name: Build the installed immutable Edge.3 image for actual upgrade acceptance run: >- docker build --build-arg BUILD_ARCH=${{ matrix.arch }} - -t domus-app-installed tests/fixtures/edge3-app - - name: Pull the immutable Core reference for native calendar acceptance - run: >- - docker pull ghcr.io/home-assistant/home-assistant:2026.10.4@sha256:23f4dfbb69ce76315dbc4de7915504f1c2dcecd7ca2648113a493a385972e133 + -t "$DOMUS_IMAGE_PREFIX:installed" tests/fixtures/edge3-app - name: Verify the real image, listener and cleanup env: - DOMUS_TEST_IMAGE: domus-app-ci + DOMUS_TEST_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:current DOMUS_CALENDAR_COVERAGE_OUT: coverage-ha-calendar.json DOMUS_TEST_SOURCE_COMMIT: ${{ github.sha }} - DOMUS_PREVIOUS_IMAGE: domus-app-previous - DOMUS_UPGRADE_IMAGE: domus-app-installed - DOMUS_SCHEMA7_IMAGE: domus-app-edge5 - DOMUS_EDGE_IMAGE: domus-app-edge - DOMUS_SCHEMA8_IMAGE: domus-app-schema8 - DOMUS_SCHEMA9_IMAGE: domus-app-schema9 - DOMUS_SCHEMA14_IMAGE: domus-app-schema14 + DOMUS_PREVIOUS_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:previous + DOMUS_UPGRADE_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:installed + DOMUS_SCHEMA7_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:edge5 + DOMUS_EDGE_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:edge + DOMUS_SCHEMA8_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:schema8 + DOMUS_SCHEMA9_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:schema9 + DOMUS_SCHEMA14_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:schema14 run: uv run pytest tests/containers --no-cov - name: Retain native calendar coverage uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -318,11 +359,11 @@ jobs: - run: pnpm --filter @domus/frontend exec playwright install chromium - name: Execute household workflows in the actual isolated image from Chromium env: - DOMUS_BROWSER_IMAGE: domus-app-ci + DOMUS_BROWSER_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:current DOMUS_TEST_SOURCE_COMMIT: ${{ github.sha }} DOMUS_TEST_ARCH: ${{ matrix.arch }} run: >- - pnpm --filter @domus/frontend exec playwright test + lockf -k -t 600 /tmp/domus-ci-entry-browser.lock pnpm --filter @domus/frontend exec playwright test -c playwright.entry.config.ts tests/e2e/administration.spec.ts tests/e2e/tasks.spec.ts tests/e2e/workspace-navigation.spec.ts - name: Require all fifty-four actual-image household journeys run: >- @@ -343,15 +384,36 @@ jobs: - name: Require no surviving image browser fixtures if: ${{ always() }} - run: >- - uv run python -c "import subprocess; - assert not subprocess.check_output('docker ps --all --quiet --filter label=domus.browser-fixture=true'.split()).strip()" + run: | + survivors=$(docker ps --all --quiet --filter "label=domus.browser-fixture.image=$DOMUS_IMAGE_PREFIX:current") + if [ -n "$survivors" ]; then + printf '%s\n' "$survivors" | while IFS= read -r id; do docker rm --force "$id"; done + echo "An image browser fixture survived its test" >&2 + exit 1 + fi + - name: Remove this job's image tags + if: ${{ always() }} + run: | + for name in current edge edge5 schema8 schema9 schema14 previous installed; do + image="$DOMUS_IMAGE_PREFIX:$name" + if docker image inspect "$image" >/dev/null 2>&1; then + docker image rm "$image" + fi + done + - name: Remove this job's Docker client configuration + if: ${{ always() }} + run: | + if [ -n "${DOMUS_CI_DOCKER_CONFIG:-}" ]; then + rm -rf -- "$DOMUS_CI_DOCKER_CONFIG" + fi aggregate: name: CI Check if: ${{ always() }} needs: [python, backend, node, frontend_toolchain, frontend, architecture, documentation, containers] - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 10 env: DOMUS_CI_RESULTS: ${{ toJSON(needs) }} diff --git a/docs/development.md b/docs/development.md index 5d303b7e..faa52a86 100644 --- a/docs/development.md +++ b/docs/development.md @@ -109,8 +109,12 @@ conditions hiding applicable suites. Actions are pinned to immutable commits and The final CI Check job always evaluates all seven required job results, including the container matrix. Missing, malformed, unexpected, failed, skipped, cancelled or pending results prevent success. -Every required job must explicitly succeed. The container job builds and tests the exact Supervisor -app folder on native amd64 and aarch64 runners; it never publishes images or installs into live HA. +Every required job must explicitly succeed. CI uses the organization's `vypdev` runner group. +The container matrix uses the Apple Silicon runner's Linux Docker engine. It executes ARM64 +images natively and amd64 images through the runner's x86-64 emulation. Before building the +exact Supervisor app folder, each matrix job verifies execution of its architecture. +Image tags and the Docker client directory belong to the job. Browser suites lock their +loopback fixture ports when runs share a host. CI never installs into live HA. The workflow uses read-only repository permissions, does not persist checkout credentials and does not publish artifacts to a release or deploy. Coverage reports are retained for seven days under the checked SHA. @@ -257,9 +261,9 @@ pnpm test:frontend-browser pnpm test:frontend-guards ``` -CI downloads the lockfile-pinned Chromium and uses the shared libraries on the GitHub-hosted Ubuntu -runners. The browser suites launch Chromium in every job that installs it. On other Linux hosts, -install the system dependencies required by Playwright before running the browser tests. Local +CI downloads the lockfile-pinned Chromium and uses the shared libraries provided by the Linux +self-hosted runners. Install Playwright's system dependencies on those runners before admitting +browser jobs. The browser suites launch Chromium in every job that installs it. Local environments also need Python 3 for the disposable static Storybook server. Browser and component tests use loopback fixtures and may require permission to open sockets. Ports 56171 and 56172 are fixture-only, refuse existing listeners and are managed by Playwright. Run browser and guard diff --git a/tests/browser/image_bridge.py b/tests/browser/image_bridge.py index 7ae46f56..77df6448 100644 --- a/tests/browser/image_bridge.py +++ b/tests/browser/image_bridge.py @@ -106,6 +106,8 @@ def start(self): "65532:65532", "--label", "domus.browser-fixture=true", + "--label", + f"domus.browser-fixture.image={self.image}", "--entrypoint", "/app/.venv/bin/python", data["Id"], diff --git a/tests/containers/test_app_image.py b/tests/containers/test_app_image.py index 1b653e6a..271d8450 100644 --- a/tests/containers/test_app_image.py +++ b/tests/containers/test_app_image.py @@ -649,9 +649,10 @@ def test_packaged_process_death_blocks_start_and_resumes_the_exact_transition( stopped(name) -_CORE_IMAGE = ( +_CORE_IMAGE = os.environ.get( + "DOMUS_HA_CORE_IMAGE", "ghcr.io/home-assistant/home-assistant:2026.10.4" - "@sha256:23f4dfbb69ce76315dbc4de7915504f1c2dcecd7ca2648113a493a385972e133" + "@sha256:23f4dfbb69ce76315dbc4de7915504f1c2dcecd7ca2648113a493a385972e133", ) diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index b6f80ac6..6e7e4e8b 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -43,33 +43,58 @@ def test_required_jobs_always_reach_a_fail_closed_aggregate() -> None: assert aggregate["env"]["DOMUS_CI_RESULTS"] == "${{ toJSON(needs) }}" for name in REQUIRED_JOBS: assert "if" not in jobs[name], f"{name} must not skip applicable PR updates" + for name, job in jobs.items(): + if name != "containers": + assert job["runs-on"] == { + "group": "vypdev", + "labels": ["self-hosted", "codex", "Linux"], + } -def test_native_app_images_are_built_and_exercised_on_both_cpu_families() -> None: +def test_linux_app_images_are_built_and_exercised_on_both_cpu_families() -> None: jobs = workflow()["jobs"] container = jobs["containers"] assert container["strategy"]["fail-fast"] == "false" - assert container["strategy"]["matrix"]["include"] == [ - {"runner": "ubuntu-latest", "arch": "amd64"}, - {"runner": "ubuntu-24.04-arm", "arch": "aarch64"}, + platforms = container["strategy"]["matrix"]["include"] + assert [(row["arch"], row["platform"], row["machine"]) for row in platforms] == [ + ("amd64", "linux/amd64", "x86_64"), + ("aarch64", "linux/arm64", "aarch64"), ] - assert container["runs-on"] == "${{ matrix.runner }}" + assert all(re.fullmatch(r"sha256:[a-f0-9]{64}", row["core_digest"]) for row in platforms) + assert len({row["core_digest"] for row in platforms}) == 2 + assert container["runs-on"] == { + "group": "vypdev", + "labels": ["self-hosted", "macOS", "ARM64"], + } + assert container["env"]["DOCKER_DEFAULT_PLATFORM"] == "${{ matrix.platform }}" + assert container["env"]["DOMUS_HA_CORE_IMAGE"] == ( + "ghcr.io/home-assistant/home-assistant@${{ matrix.core_digest }}" + ) + assert container["env"]["DOMUS_IMAGE_PREFIX"] == ( + "domus-ci-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.arch }}" + ) commands = [step["run"] for step in container["steps"] if "run" in step] + assert any( + 'docker pull "$DOMUS_HA_CORE_IMAGE"' in command + and '--entrypoint uname "$DOMUS_HA_CORE_IMAGE" -m' in command + and 'test "$machine" = "$DOMUS_EXPECTED_MACHINE"' in command + for command in commands + ) assert ( "docker build --build-arg BUILD_ARCH=${{ matrix.arch }}" - " -t domus-app-edge5 tests/fixtures/edge5-app" in commands + ' -t "$DOMUS_IMAGE_PREFIX:edge5" tests/fixtures/edge5-app' in commands ) assert any( "docker build --file tests/fixtures/current-app/Dockerfile" in command and "--build-arg BUILD_ARCH=${{ matrix.arch }}" in command and "--build-arg DOMUS_SOURCE_COMMIT=${{ github.sha }}" in command and "--build-arg BUILD_VERSION=ci-current" in command - and command.rstrip().endswith("-t domus-app-ci .") + and command.rstrip().endswith('-t "$DOMUS_IMAGE_PREFIX:current" .') for command in commands ) assert any( "docker build --build-arg BUILD_ARCH=${{ matrix.arch }}" in command - and command.rstrip().endswith("-t domus-app-edge addon-edge") + and command.rstrip().endswith('-t "$DOMUS_IMAGE_PREFIX:edge" addon-edge') for command in commands ) assert "uv run pytest tests/containers --no-cov" in commands @@ -78,7 +103,7 @@ def test_native_app_images_are_built_and_exercised_on_both_cpu_families() -> Non and "DOMUS_SOURCE_SHA256=fa58d457bef8a863a1943b4e6ba5c9513da8d3baa8b0a033bdcbe7bf11b09c6c" in command and "BUILD_VERSION=0.0.0-edge.2" in command - and "-t domus-app-previous tests/fixtures/edge3-app" in command + and '-t "$DOMUS_IMAGE_PREFIX:previous" tests/fixtures/edge3-app' in command for command in commands ) verification = next( @@ -86,13 +111,16 @@ def test_native_app_images_are_built_and_exercised_on_both_cpu_families() -> Non for step in container["steps"] if step.get("run") == "uv run pytest tests/containers --no-cov" ) - assert verification["env"]["DOMUS_PREVIOUS_IMAGE"] == "domus-app-previous" - assert verification["env"]["DOMUS_UPGRADE_IMAGE"] == "domus-app-installed" - assert verification["env"]["DOMUS_TEST_IMAGE"] == "domus-app-ci" + assert verification["env"]["DOMUS_PREVIOUS_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:previous" + assert verification["env"]["DOMUS_UPGRADE_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:installed" + assert verification["env"]["DOMUS_TEST_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:current" assert verification["env"]["DOMUS_TEST_SOURCE_COMMIT"] == "${{ github.sha }}" - assert verification["env"]["DOMUS_SCHEMA7_IMAGE"] == "domus-app-edge5" - assert verification["env"]["DOMUS_EDGE_IMAGE"] == "domus-app-edge" - assert any("-t domus-app-installed tests/fixtures/edge3-app" in command for command in commands) + assert verification["env"]["DOMUS_SCHEMA7_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:edge5" + assert verification["env"]["DOMUS_EDGE_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:edge" + assert any( + '-t "$DOMUS_IMAGE_PREFIX:installed" tests/fixtures/edge3-app' in command + for command in commands + ) assert "containers" in jobs["aggregate"]["needs"] @@ -174,9 +202,9 @@ def test_product_frontend_has_its_own_required_chromium_coverage_gate() -> None: "pnpm build:frontend", "uv build --package domus-server --wheel", "uv run pytest tests/packaging --no-cov", - "pnpm test:frontend-entry", + "flock -w 600 /tmp/domus-ci-entry-browser.lock pnpm test:frontend-entry", "pnpm build:frontend-catalog", - "pnpm test:frontend-catalog", + "flock -w 600 /tmp/domus-ci-catalog-browser.lock pnpm test:frontend-catalog", ] assert "frontend" in REQUIRED_JOBS assert "frontend" in jobs["aggregate"]["needs"] @@ -221,8 +249,8 @@ def test_frontend_toolchain_requires_actual_execution_and_separate_artifacts() - "pnpm check:frontend-toolchain", "pnpm test:frontend-toolchain", "pnpm build:frontend-toolchain", - "pnpm test:frontend-browser", - "pnpm test:frontend-guards", + "flock -w 600 /tmp/domus-ci-toolchain-browser.lock pnpm test:frontend-browser", + "flock -w 600 /tmp/domus-ci-toolchain-browser.lock pnpm test:frontend-guards", ] artifact = next(step for step in job["steps"] if "path" in step.get("with", {})) assert artifact["if"] == "${{ always() }}" @@ -272,7 +300,7 @@ def test_both_cpu_images_run_all_actual_household_browser_journeys() -> None: == "Execute household workflows in the actual isolated image from Chromium" ) assert actual["env"] == { - "DOMUS_BROWSER_IMAGE": "domus-app-ci", + "DOMUS_BROWSER_IMAGE": "${{ env.DOMUS_IMAGE_PREFIX }}:current", "DOMUS_TEST_SOURCE_COMMIT": "${{ github.sha }}", "DOMUS_TEST_ARCH": "${{ matrix.arch }}", } @@ -280,6 +308,7 @@ def test_both_cpu_images_run_all_actual_household_browser_journeys() -> None: "playwright.entry.config.ts tests/e2e/administration.spec.ts tests/e2e/tasks.spec.ts" " tests/e2e/workspace-navigation.spec.ts" in actual["run"] ) + assert actual["run"].startswith("lockf -k -t 600 /tmp/domus-ci-entry-browser.lock ") assert "--grep" not in actual["run"] assert "--pass-with-no-tests" not in actual["run"] commands = [step["run"] for step in steps if "run" in step] @@ -295,9 +324,14 @@ def test_both_cpu_images_run_all_actual_household_browser_journeys() -> None: cleanup = next( step for step in steps if step.get("name") == "Require no surviving image browser fixtures" ) - assert "docker ps --all --quiet --filter label=domus.browser-fixture=true" in cleanup["run"] - assert "assert not" in cleanup["run"] and "check_output" in cleanup["run"] + assert "domus.browser-fixture.image=$DOMUS_IMAGE_PREFIX:current" in cleanup["run"] + assert 'docker rm --force "$id"' in cleanup["run"] + assert "exit 1" in cleanup["run"] assert steps.index(cleanup) > steps.index(audit) + images = next(step for step in steps if step.get("name") == "Remove this job's image tags") + assert images["if"] == "${{ always() }}" + assert 'image="$DOMUS_IMAGE_PREFIX:$name"' in images["run"] + assert 'docker image rm "$image"' in images["run"] def test_both_cpu_images_require_the_immutable_schema9_application_rollback_pair() -> None: @@ -315,13 +349,13 @@ def test_both_cpu_images_require_the_immutable_schema9_application_rollback_pair "matrix.arch", "}}", "-t", - "domus-app-schema9", + '"$DOMUS_IMAGE_PREFIX:schema9"', "tests/fixtures/schema9-app", ] verify = next( step for step in steps if step.get("run") == "uv run pytest tests/containers --no-cov" ) - assert verify["env"]["DOMUS_SCHEMA9_IMAGE"] == "domus-app-schema9" + assert verify["env"]["DOMUS_SCHEMA9_IMAGE"] == "${{ env.DOMUS_IMAGE_PREFIX }}:schema9" assert steps.index(build) < steps.index(verify) fixture = (ROOT / "tests/fixtures/schema9-app/Dockerfile").read_text() assert "DOMUS_SOURCE_COMMIT=87d726fa5a6a8cbcb56e0b911d15cc5b8a96a470" in fixture From 60118c39833394de749a4420e41816a917ccceb4 Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 09:27:44 +0100 Subject: [PATCH 2/7] ci: restrict Domus validation to internal pull requests --- .github/workflows/ci_check.yml | 10 +++++++++- docs/development.md | 7 ++++--- tests/python/test_ci_contract.py | 11 +++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index d9e4a72c..be8db987 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -14,6 +14,7 @@ permissions: jobs: python: name: Python tooling + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -45,6 +46,7 @@ jobs: backend: name: Backend application + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -76,6 +78,7 @@ jobs: node: name: Node architecture policy + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -106,6 +109,7 @@ jobs: frontend_toolchain: name: Frontend toolchain + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -148,6 +152,7 @@ jobs: frontend: name: Frontend application + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -198,6 +203,7 @@ jobs: architecture: name: Python architecture contracts + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -217,6 +223,7 @@ jobs: documentation: name: Local documentation links + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -234,6 +241,7 @@ jobs: containers: name: App container (${{ matrix.arch }}) + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} strategy: fail-fast: false matrix: @@ -409,7 +417,7 @@ jobs: aggregate: name: CI Check - if: ${{ always() }} + if: ${{ always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} needs: [python, backend, node, frontend_toolchain, frontend, architecture, documentation, containers] runs-on: group: vypdev diff --git a/docs/development.md b/docs/development.md index faa52a86..ef60a9e9 100644 --- a/docs/development.md +++ b/docs/development.md @@ -103,9 +103,10 @@ See the primary [dependency-cruiser API](https://github.com/sverweij/dependency- The project-owned .github/workflows/ci_check.yml runs Python tooling, the separate backend suite, Node policy, real frontend framework execution, Python architecture -contracts and local documentation links for every PR update, including drafts and documentation changes. -It also runs on develop/master pushes and merge-queue validation. There are no path filters or job -conditions hiding applicable suites. Actions are pinned to immutable commits and installs use lockfiles. +contracts and local documentation links for PR updates from branches in this repository, including drafts +and documentation changes. It also runs on develop/master pushes and merge-queue validation. +Fork workflows require maintainer approval in GitHub. The CI jobs restrict execution to same-repository PRs. +Actions are pinned to immutable commits and installs use lockfiles. The final CI Check job always evaluates all seven required job results, including the container matrix. Missing, malformed, unexpected, failed, skipped, cancelled or pending results prevent success. diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index 6e7e4e8b..54211e8a 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -1,4 +1,4 @@ -"""Enforce the every-PR workflow contract and immutable installed resources.""" +"""Enforce the internal PR workflow contract and immutable installed resources.""" import ast import hashlib @@ -15,6 +15,10 @@ ROOT = Path(__file__).resolve().parents[2] WORKFLOW = ROOT / ".github/workflows/ci_check.yml" PROTECTED = ROOT / "tests/contracts/copilot-resource-hashes.json" +INTERNAL_EVENT = ( + "github.event_name != 'pull_request' || " + "github.event.pull_request.head.repo.full_name == github.repository" +) def workflow() -> dict: @@ -39,10 +43,10 @@ def test_required_jobs_always_reach_a_fail_closed_aggregate() -> None: aggregate = jobs["aggregate"] assert aggregate["name"] == "CI Check" assert set(aggregate["needs"]) == set(REQUIRED_JOBS) - assert aggregate["if"] == "${{ always() }}" + assert aggregate["if"] == "${{ always() && (" + INTERNAL_EVENT + ") }}" assert aggregate["env"]["DOMUS_CI_RESULTS"] == "${{ toJSON(needs) }}" for name in REQUIRED_JOBS: - assert "if" not in jobs[name], f"{name} must not skip applicable PR updates" + assert jobs[name]["if"] == "${{ " + INTERNAL_EVENT + " }}" for name, job in jobs.items(): if name != "containers": assert job["runs-on"] == { @@ -189,7 +193,6 @@ def test_new_runtime_sources_require_an_explicit_coverage_scope() -> None: def test_product_frontend_has_its_own_required_chromium_coverage_gate() -> None: jobs = workflow()["jobs"] job = jobs["frontend"] - assert "if" not in job assert "continue-on-error" not in job assert all("continue-on-error" not in step for step in job["steps"]) commands = [step["run"] for step in job["steps"] if "run" in step] From 1e67ac7a68648a89d77cd172105a2f52a3538d46 Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 09:34:34 +0100 Subject: [PATCH 3/7] ci: isolate Buildx state for both Domus architectures --- .github/workflows/ci_check.yml | 39 ++++++++++++++++++++++++-------- docs/development.md | 2 +- tests/python/test_ci_contract.py | 13 ++++++++--- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index be8db987..7e254f78 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -279,7 +279,11 @@ jobs: run: | set -euo pipefail docker_host=$(docker context inspect --format '{{.Endpoints.docker.Host}}') + buildx_plugin=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "buildx"}}{{.Path}}{{end}}{{end}}') + test -x "$buildx_plugin" docker_config=$(mktemp -d "$RUNNER_TEMP/domus-docker.XXXXXX") + mkdir "$docker_config/cli-plugins" + ln -s "$buildx_plugin" "$docker_config/cli-plugins/docker-buildx" { printf 'DOCKER_HOST=%s\n' "$docker_host" printf 'DOCKER_CONFIG=%s\n' "$docker_config" @@ -291,21 +295,29 @@ jobs: docker pull "$DOMUS_HA_CORE_IMAGE" machine=$(docker run --rm --network none --entrypoint uname "$DOMUS_HA_CORE_IMAGE" -m) test "$machine" = "$DOMUS_EXPECTED_MACHINE" + docker buildx create --name "$DOMUS_IMAGE_PREFIX" --driver docker-container --use - name: Build the installed immutable Edge.5 image for schema-7 compatibility - run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge5" tests/fixtures/edge5-app + run: >- + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge5" tests/fixtures/edge5-app - name: Build the actual reviewed Edge preview installed by the Supervisor - run: docker build --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge" addon-edge + run: >- + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:edge" addon-edge - name: Build the immutable published schema-8 image for profile migration compatibility run: >- - docker build --build-arg BUILD_ARCH=${{ matrix.arch }} + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:schema8" tests/fixtures/schema8-app - name: Build the immutable compatible schema-9 rollback application run: >- - docker build --build-arg BUILD_ARCH=${{ matrix.arch }} + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:schema9" tests/fixtures/schema9-app - name: Build the exact checked-out source and frontend run: >- - docker build --file tests/fixtures/current-app/Dockerfile + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --file tests/fixtures/current-app/Dockerfile --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg DOMUS_SOURCE_COMMIT=${{ github.sha }} --build-arg BUILD_VERSION=ci-current @@ -319,21 +331,24 @@ jobs: - name: Build the immutable schema-14 application working-directory: previous-category-source run: >- - docker build --file tests/fixtures/current-app/Dockerfile + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --file tests/fixtures/current-app/Dockerfile --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg DOMUS_SOURCE_COMMIT=449dc04c17a9c41d949d74cd341bf1e943a2fba9 --build-arg BUILD_VERSION=ci-schema14 -t "$DOMUS_IMAGE_PREFIX:schema14" . - name: Build the immutable previous image for upgrade and downgrade checks run: >- - docker build --build-arg BUILD_ARCH=${{ matrix.arch }} + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} --build-arg BUILD_VERSION=0.0.0-edge.2 --build-arg DOMUS_SOURCE_COMMIT=d013cf2c8b932d0e00f5858053cbc0e663d5eee1 --build-arg DOMUS_SOURCE_SHA256=fa58d457bef8a863a1943b4e6ba5c9513da8d3baa8b0a033bdcbe7bf11b09c6c -t "$DOMUS_IMAGE_PREFIX:previous" tests/fixtures/edge3-app - name: Build the installed immutable Edge.3 image for actual upgrade acceptance run: >- - docker build --build-arg BUILD_ARCH=${{ matrix.arch }} + docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM" + --build-arg BUILD_ARCH=${{ matrix.arch }} -t "$DOMUS_IMAGE_PREFIX:installed" tests/fixtures/edge3-app - name: Verify the real image, listener and cleanup env: @@ -408,11 +423,15 @@ jobs: docker image rm "$image" fi done - - name: Remove this job's Docker client configuration + - name: Remove this job's builder and Docker client configuration if: ${{ always() }} + shell: bash run: | if [ -n "${DOMUS_CI_DOCKER_CONFIG:-}" ]; then - rm -rf -- "$DOMUS_CI_DOCKER_CONFIG" + trap 'rm -rf -- "$DOMUS_CI_DOCKER_CONFIG"' EXIT + if docker buildx inspect "$DOMUS_IMAGE_PREFIX" >/dev/null 2>&1; then + docker buildx rm "$DOMUS_IMAGE_PREFIX" + fi fi aggregate: diff --git a/docs/development.md b/docs/development.md index ef60a9e9..62f48370 100644 --- a/docs/development.md +++ b/docs/development.md @@ -114,7 +114,7 @@ Every required job must explicitly succeed. CI uses the organization's `vypdev` The container matrix uses the Apple Silicon runner's Linux Docker engine. It executes ARM64 images natively and amd64 images through the runner's x86-64 emulation. Before building the exact Supervisor app folder, each matrix job verifies execution of its architecture. -Image tags and the Docker client directory belong to the job. Browser suites lock their +Image tags, the Buildx builder and the Docker client directory belong to the job. Browser suites lock their loopback fixture ports when runs share a host. CI never installs into live HA. The workflow uses read-only repository permissions, does not persist checkout credentials and does not publish artifacts to a release or deploy. Coverage reports are retained for seven days under the checked SHA. diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index 54211e8a..ae7e83d6 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -82,14 +82,17 @@ def test_linux_app_images_are_built_and_exercised_on_both_cpu_families() -> None 'docker pull "$DOMUS_HA_CORE_IMAGE"' in command and '--entrypoint uname "$DOMUS_HA_CORE_IMAGE" -m' in command and 'test "$machine" = "$DOMUS_EXPECTED_MACHINE"' in command + and 'docker buildx create --name "$DOMUS_IMAGE_PREFIX" --driver docker-container --use' + in command for command in commands ) + build = 'docker buildx build --load --platform "$DOCKER_DEFAULT_PLATFORM"' assert ( - "docker build --build-arg BUILD_ARCH=${{ matrix.arch }}" + build + " --build-arg BUILD_ARCH=${{ matrix.arch }}" ' -t "$DOMUS_IMAGE_PREFIX:edge5" tests/fixtures/edge5-app' in commands ) assert any( - "docker build --file tests/fixtures/current-app/Dockerfile" in command + f"{build} --file tests/fixtures/current-app/Dockerfile" in command and "--build-arg BUILD_ARCH=${{ matrix.arch }}" in command and "--build-arg DOMUS_SOURCE_COMMIT=${{ github.sha }}" in command and "--build-arg BUILD_VERSION=ci-current" in command @@ -97,7 +100,7 @@ def test_linux_app_images_are_built_and_exercised_on_both_cpu_families() -> None for command in commands ) assert any( - "docker build --build-arg BUILD_ARCH=${{ matrix.arch }}" in command + (build + " --build-arg BUILD_ARCH=${{ matrix.arch }}") in command and command.rstrip().endswith('-t "$DOMUS_IMAGE_PREFIX:edge" addon-edge') for command in commands ) @@ -346,7 +349,11 @@ def test_both_cpu_images_require_the_immutable_schema9_application_rollback_pair ) assert build["run"].split() == [ "docker", + "buildx", "build", + "--load", + "--platform", + '"$DOCKER_DEFAULT_PLATFORM"', "--build-arg", "BUILD_ARCH=${{", "matrix.arch", From 27ffe957d4c74cce3141503d572b1eb01c73e76a Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 09:44:52 +0100 Subject: [PATCH 4/7] ci: run self-hosted validation on repository branch pushes --- .github/workflows/ci_check.yml | 16 ++-------------- docs/development.md | 8 ++++---- tests/python/test_ci_contract.py | 19 ++++--------------- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index 7e254f78..2d4b19bf 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -1,12 +1,8 @@ name: CI Check on: - pull_request: - types: [opened, reopened, synchronize, ready_for_review, converted_to_draft] push: - branches: [develop, master] - merge_group: - types: [checks_requested] + branches: ['**'] permissions: contents: read @@ -14,7 +10,6 @@ permissions: jobs: python: name: Python tooling - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -46,7 +41,6 @@ jobs: backend: name: Backend application - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -78,7 +72,6 @@ jobs: node: name: Node architecture policy - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -109,7 +102,6 @@ jobs: frontend_toolchain: name: Frontend toolchain - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -152,7 +144,6 @@ jobs: frontend: name: Frontend application - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -203,7 +194,6 @@ jobs: architecture: name: Python architecture contracts - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -223,7 +213,6 @@ jobs: documentation: name: Local documentation links - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} runs-on: group: vypdev labels: [self-hosted, codex, Linux] @@ -241,7 +230,6 @@ jobs: containers: name: App container (${{ matrix.arch }}) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} strategy: fail-fast: false matrix: @@ -436,7 +424,7 @@ jobs: aggregate: name: CI Check - if: ${{ always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} + if: ${{ always() }} needs: [python, backend, node, frontend_toolchain, frontend, architecture, documentation, containers] runs-on: group: vypdev diff --git a/docs/development.md b/docs/development.md index 62f48370..c831ac33 100644 --- a/docs/development.md +++ b/docs/development.md @@ -103,12 +103,12 @@ See the primary [dependency-cruiser API](https://github.com/sverweij/dependency- The project-owned .github/workflows/ci_check.yml runs Python tooling, the separate backend suite, Node policy, real frontend framework execution, Python architecture -contracts and local documentation links for PR updates from branches in this repository, including drafts -and documentation changes. It also runs on develop/master pushes and merge-queue validation. -Fork workflows require maintainer approval in GitHub. The CI jobs restrict execution to same-repository PRs. +contracts and local documentation links for every branch push to this repository, including documentation changes. +An internal pull request shows CI for its pushed head. Bring the head up to date with the target branch before merging. +Fork workflows require maintainer approval in GitHub. Actions are pinned to immutable commits and installs use lockfiles. -The final CI Check job always evaluates all seven required job results, including the container matrix. +The final CI Check job always evaluates the eight required job results, including the container matrix. Missing, malformed, unexpected, failed, skipped, cancelled or pending results prevent success. Every required job must explicitly succeed. CI uses the organization's `vypdev` runner group. The container matrix uses the Apple Silicon runner's Linux Docker engine. It executes ARM64 diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index ae7e83d6..dd0f48b7 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -1,4 +1,4 @@ -"""Enforce the internal PR workflow contract and immutable installed resources.""" +"""Enforce the branch CI workflow contract and immutable installed resources.""" import ast import hashlib @@ -15,25 +15,16 @@ ROOT = Path(__file__).resolve().parents[2] WORKFLOW = ROOT / ".github/workflows/ci_check.yml" PROTECTED = ROOT / "tests/contracts/copilot-resource-hashes.json" -INTERNAL_EVENT = ( - "github.event_name != 'pull_request' || " - "github.event.pull_request.head.repo.full_name == github.repository" -) def workflow() -> dict: return yaml.load(WORKFLOW.read_text(encoding="utf-8"), Loader=yaml.BaseLoader) -def test_every_pr_update_and_merge_queue_run_without_path_filters() -> None: +def test_ci_runs_on_every_branch_push_without_accepting_pr_events() -> None: config = workflow() assert config["name"] == "CI Check" - assert {"opened", "reopened", "synchronize", "ready_for_review", "converted_to_draft"} <= set( - config["on"]["pull_request"]["types"] - ) - assert set(config["on"]["pull_request"]) == {"types"} - assert config["on"]["merge_group"]["types"] == ["checks_requested"] - assert set(config["on"]["push"]["branches"]) == {"develop", "master"} + assert config["on"] == {"push": {"branches": ["**"]}} def test_required_jobs_always_reach_a_fail_closed_aggregate() -> None: @@ -43,10 +34,8 @@ def test_required_jobs_always_reach_a_fail_closed_aggregate() -> None: aggregate = jobs["aggregate"] assert aggregate["name"] == "CI Check" assert set(aggregate["needs"]) == set(REQUIRED_JOBS) - assert aggregate["if"] == "${{ always() && (" + INTERNAL_EVENT + ") }}" + assert aggregate["if"] == "${{ always() }}" assert aggregate["env"]["DOMUS_CI_RESULTS"] == "${{ toJSON(needs) }}" - for name in REQUIRED_JOBS: - assert jobs[name]["if"] == "${{ " + INTERNAL_EVENT + " }}" for name, job in jobs.items(): if name != "containers": assert job["runs-on"] == { From 2db76c573e537f7230826a740c05ece6c43c1a95 Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 11:28:43 +0100 Subject: [PATCH 5/7] ci: use exact action release versions --- .github/workflows/ci_check.yml | 64 ++++++++++++++++---------------- docs/development.md | 2 +- tests/python/test_ci_contract.py | 4 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index 2d4b19bf..593d2fa9 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -15,10 +15,10 @@ jobs: labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -30,7 +30,7 @@ jobs: run: uv run pytest tests/python --cov=domus_tooling --cov-branch --cov-report=term-missing --cov-report=json:coverage-python.json --cov-report=xml:coverage-python.xml - name: Retain tooling coverage if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: python-tooling-coverage-${{ github.sha }} path: | @@ -46,10 +46,10 @@ jobs: labels: [self-hosted, codex, Linux] timeout-minutes: 15 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -61,7 +61,7 @@ jobs: run: uv run domus-check backend-coverage --report coverage-backend.json - name: Retain backend coverage if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: backend-coverage-${{ github.sha }} path: | @@ -77,14 +77,14 @@ jobs: labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - uses: actions/setup-node@v7.1.0 with: node-version-file: .node-version package-manager-cache: false - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: pnpm/action-setup@v6.1.0 with: run_install: false cache: false @@ -93,7 +93,7 @@ jobs: - run: pnpm test - name: Retain policy coverage if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: node-policy-coverage-${{ github.sha }} path: coverage/ @@ -110,14 +110,14 @@ jobs: CI: "1" STORYBOOK_DISABLE_TELEMETRY: "1" steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - uses: actions/setup-node@v7.1.0 with: node-version-file: .node-version package-manager-cache: false - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: pnpm/action-setup@v6.1.0 with: run_install: false cache: false @@ -130,7 +130,7 @@ jobs: - run: flock -w 600 /tmp/domus-ci-toolchain-browser.lock pnpm test:frontend-guards - name: Retain distinct framework fixture outputs and coverage if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: frontend-toolchain-${{ github.sha }} path: | @@ -151,18 +151,18 @@ jobs: env: CI: "1" steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - uses: actions/setup-node@v7.1.0 with: node-version-file: .node-version package-manager-cache: false - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: pnpm/action-setup@v6.1.0 with: run_install: false cache: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -179,7 +179,7 @@ jobs: - run: flock -w 600 /tmp/domus-ci-catalog-browser.lock pnpm test:frontend-catalog - name: Retain distinct application coverage if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: frontend-application-${{ github.sha }} include-hidden-files: true @@ -199,10 +199,10 @@ jobs: labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -218,10 +218,10 @@ jobs: labels: [self-hosted, codex, Linux] timeout-minutes: 10 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -252,10 +252,10 @@ jobs: DOMUS_HA_CORE_IMAGE: ghcr.io/home-assistant/home-assistant@${{ matrix.core_digest }} timeout-minutes: 45 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false @@ -311,7 +311,7 @@ jobs: --build-arg BUILD_VERSION=ci-current -t "$DOMUS_IMAGE_PREFIX:current" . - name: Check out the original schema-14 application - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: ref: 449dc04c17a9c41d949d74cd341bf1e943a2fba9 path: previous-category-source @@ -352,17 +352,17 @@ jobs: DOMUS_SCHEMA14_IMAGE: ${{ env.DOMUS_IMAGE_PREFIX }}:schema14 run: uv run pytest tests/containers --no-cov - name: Retain native calendar coverage - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: native-calendar-coverage-${{ matrix.arch }}-${{ github.sha }} path: coverage-ha-calendar.json if-no-files-found: error retention-days: 7 - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - uses: actions/setup-node@v7.1.0 with: node-version-file: .node-version package-manager-cache: false - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: pnpm/action-setup@v6.1.0 with: run_install: false cache: false @@ -385,7 +385,7 @@ jobs: - name: Retain actual-image browser evidence if: ${{ always() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + uses: actions/upload-artifact@v7.0.2 with: name: image-browser-${{ matrix.arch }}-${{ github.sha }} path: frontend/test-results/ @@ -433,10 +433,10 @@ jobs: env: DOMUS_CI_RESULTS: ${{ toJSON(needs) }} steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + - uses: astral-sh/setup-uv@v10.3.3 with: version: "0.11.29" enable-cache: false diff --git a/docs/development.md b/docs/development.md index c831ac33..da85724f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -106,7 +106,7 @@ Node policy, real frontend framework execution, Python architecture contracts and local documentation links for every branch push to this repository, including documentation changes. An internal pull request shows CI for its pushed head. Bring the head up to date with the target branch before merging. Fork workflows require maintainer approval in GitHub. -Actions are pinned to immutable commits and installs use lockfiles. +Workflow steps reference complete action release versions and installs use lockfiles. The final CI Check job always evaluates the eight required job results, including the container matrix. Missing, malformed, unexpected, failed, skipped, cancelled or pending results prevent success. diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index dd0f48b7..435fcb8b 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -120,14 +120,14 @@ def test_linux_app_images_are_built_and_exercised_on_both_cpu_families() -> None assert "containers" in jobs["aggregate"]["needs"] -def test_ci_is_read_only_with_immutable_actions_and_locked_installs() -> None: +def test_ci_is_read_only_with_exact_action_versions_and_locked_installs() -> None: config = workflow() assert config["permissions"] == {"contents": "read"} for job in config["jobs"].values(): assert "permissions" not in job for step in job["steps"]: if "uses" in step: - assert re.fullmatch(r"[\w/-]+@[a-f0-9]{40}", step["uses"]) + assert re.fullmatch(r"[\w/-]+@v[0-9]+\.[0-9]+\.[0-9]+", step["uses"]) if step.get("uses", "").startswith("actions/checkout@"): assert step["with"]["persist-credentials"] == "false" source = WORKFLOW.read_text(encoding="utf-8") From bafb7e4b49edf0c2ffe9edeed1468daa2fac44fd Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 11:45:42 +0100 Subject: [PATCH 6/7] ci: lock the commits behind action release tags --- .github/workflows/actions.lock | 37 ++++++++++++++++++++++++++++++++ docs/development.md | 4 +++- tests/python/test_ci_contract.py | 6 ++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/actions.lock diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 00000000..6a001da1 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,37 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/ci_check.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-node@v7.1.0' + - 'actions/upload-artifact@v7.0.2' + - 'astral-sh/setup-uv@v10.3.3' + - 'pnpm/action-setup@v6.1.0' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/setup-node@v7.1.0': + ref: 'v7.1.0' + commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1' + owner_id: 44036562 + repo_id: 189476904 + 'actions/upload-artifact@v7.0.2': + ref: 'v7.0.2' + commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9' + owner_id: 44036562 + repo_id: 192625955 + 'astral-sh/setup-uv@v10.3.3': + ref: 'v10.3.3' + commit: 'sha1-68559e99cc807c1eb7e9238fd43a15bba460eec2' + owner_id: 115962839 + repo_id: 846733598 + 'pnpm/action-setup@v6.1.0': + ref: 'v6.1.0' + commit: 'sha1-ea17c68df8912ef543352723c149a84f56e3d413' + owner_id: 21320719 + repo_id: 262289747 diff --git a/docs/development.md b/docs/development.md index da85724f..3f169b12 100644 --- a/docs/development.md +++ b/docs/development.md @@ -106,7 +106,9 @@ Node policy, real frontend framework execution, Python architecture contracts and local documentation links for every branch push to this repository, including documentation changes. An internal pull request shows CI for its pushed head. Bring the head up to date with the target branch before merging. Fork workflows require maintainer approval in GitHub. -Workflow steps reference complete action release versions and installs use lockfiles. +Workflow steps reference complete action release versions. GitHub runs the commits recorded in +`.github/workflows/actions.lock`. Run `gh actions-lock .github/workflows/ci_check.yml` after updating +an action version. Package installs use their lockfiles. The final CI Check job always evaluates the eight required job results, including the container matrix. Missing, malformed, unexpected, failed, skipped, cancelled or pending results prevent success. diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index 435fcb8b..d44cfe71 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -122,14 +122,20 @@ def test_linux_app_images_are_built_and_exercised_on_both_cpu_families() -> None def test_ci_is_read_only_with_exact_action_versions_and_locked_installs() -> None: config = workflow() + lock = yaml.safe_load(WORKFLOW.with_name("actions.lock").read_text(encoding="utf-8")) + refs = set() assert config["permissions"] == {"contents": "read"} for job in config["jobs"].values(): assert "permissions" not in job for step in job["steps"]: if "uses" in step: assert re.fullmatch(r"[\w/-]+@v[0-9]+\.[0-9]+\.[0-9]+", step["uses"]) + refs.add(step["uses"]) if step.get("uses", "").startswith("actions/checkout@"): assert step["with"]["persist-credentials"] == "false" + assert refs == set(lock["workflows"][WORKFLOW.relative_to(ROOT).as_posix()]) + for ref in refs: + assert re.fullmatch(r"sha1-[a-f0-9]{40}", lock["dependencies"][ref]["commit"]) source = WORKFLOW.read_text(encoding="utf-8") assert "uv sync --frozen" in source assert "pnpm install --frozen-lockfile" in source From c6a69588674d72e30300f2ca98518799ddcae1e3 Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 12:57:34 +0100 Subject: [PATCH 7/7] ci: isolate pnpm installations on shared runners --- .github/workflows/ci_check.yml | 4 ++++ docs/development.md | 3 ++- tests/python/test_ci_contract.py | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index 593d2fa9..5f0e3721 100644 --- a/.github/workflows/ci_check.yml +++ b/.github/workflows/ci_check.yml @@ -86,6 +86,7 @@ jobs: package-manager-cache: false - uses: pnpm/action-setup@v6.1.0 with: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile @@ -119,6 +120,7 @@ jobs: package-manager-cache: false - uses: pnpm/action-setup@v6.1.0 with: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile @@ -160,6 +162,7 @@ jobs: package-manager-cache: false - uses: pnpm/action-setup@v6.1.0 with: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - uses: astral-sh/setup-uv@v10.3.3 @@ -364,6 +367,7 @@ jobs: package-manager-cache: false - uses: pnpm/action-setup@v6.1.0 with: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile diff --git a/docs/development.md b/docs/development.md index 3f169b12..9cba83be 100644 --- a/docs/development.md +++ b/docs/development.md @@ -116,7 +116,8 @@ Every required job must explicitly succeed. CI uses the organization's `vypdev` The container matrix uses the Apple Silicon runner's Linux Docker engine. It executes ARM64 images natively and amd64 images through the runner's x86-64 emulation. Before building the exact Supervisor app folder, each matrix job verifies execution of its architecture. -Image tags, the Buildx builder and the Docker client directory belong to the job. Browser suites lock their +Each job installs pnpm into its own temporary directory. Image tags, the Buildx builder and the +Docker client directory also belong to the job. Browser suites lock their loopback fixture ports when runs share a host. CI never installs into live HA. The workflow uses read-only repository permissions, does not persist checkout credentials and does not publish artifacts to a release or deploy. Coverage reports are retained for seven days under the checked SHA. diff --git a/tests/python/test_ci_contract.py b/tests/python/test_ci_contract.py index d44cfe71..2fc7a28b 100644 --- a/tests/python/test_ci_contract.py +++ b/tests/python/test_ci_contract.py @@ -133,6 +133,11 @@ def test_ci_is_read_only_with_exact_action_versions_and_locked_installs() -> Non refs.add(step["uses"]) if step.get("uses", "").startswith("actions/checkout@"): assert step["with"]["persist-credentials"] == "false" + if step.get("uses", "").startswith("pnpm/action-setup@"): + assert step["with"]["dest"] == ( + "${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-" + "${{ github.run_attempt }}-${{ github.job }}" + ) assert refs == set(lock["workflows"][WORKFLOW.relative_to(ROOT).as_posix()]) for ref in refs: assert re.fullmatch(r"sha1-[a-f0-9]{40}", lock["dependencies"][ref]["commit"])