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/.github/workflows/ci_check.yml b/.github/workflows/ci_check.yml index ff2e0485..5f0e3721 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,13 +10,15 @@ 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 + - 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 @@ -32,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: | @@ -43,13 +41,15 @@ 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 + - 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: | @@ -72,18 +72,21 @@ 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 + - 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: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile @@ -91,7 +94,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/ @@ -100,21 +103,24 @@ 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" 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: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile @@ -122,11 +128,11 @@ 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 + uses: actions/upload-artifact@v7.0.2 with: name: frontend-toolchain-${{ github.sha }} path: | @@ -140,23 +146,26 @@ jobs: frontend: name: Frontend application - runs-on: ubuntu-latest + runs-on: + group: vypdev + labels: [self-hosted, codex, Linux] timeout-minutes: 15 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: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} 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 @@ -168,12 +177,12 @@ 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 + uses: actions/upload-artifact@v7.0.2 with: name: frontend-application-${{ github.sha }} include-hidden-files: true @@ -188,13 +197,15 @@ 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 + - 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 @@ -205,13 +216,15 @@ 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 + - 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 @@ -224,42 +237,84 @@ 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 + - 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 - 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}}') + 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" + 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" + 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-app-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-app-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 }} - -t domus-app-schema8 tests/fixtures/schema8-app + 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 }} - -t domus-app-schema9 tests/fixtures/schema9-app + 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 - -t domus-app-ci . + -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 @@ -267,62 +322,63 @@ 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-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 }} + 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-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 + 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: - 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 + 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: + dest: ${{ runner.temp }}/domus-pnpm-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} run_install: false cache: false - run: pnpm install --frozen-lockfile - 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: >- @@ -333,7 +389,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/ @@ -343,23 +399,48 @@ 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 builder and Docker client configuration + if: ${{ always() }} + shell: bash + run: | + if [ -n "${DOMUS_CI_DOCKER_CONFIG:-}" ]; then + 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: 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) }} 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 5d303b7e..9cba83be 100644 --- a/docs/development.md +++ b/docs/development.md @@ -103,14 +103,22 @@ 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. - -The final CI Check job always evaluates all seven required job results, including the container matrix. +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. 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. -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. +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. @@ -257,9 +265,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..2fc7a28b 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 branch CI workflow contract and immutable installed resources.""" import ast import hashlib @@ -21,15 +21,10 @@ 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: @@ -41,35 +36,61 @@ def test_required_jobs_always_reach_a_fail_closed_aggregate() -> None: assert set(aggregate["needs"]) == set(REQUIRED_JOBS) assert aggregate["if"] == "${{ always() }}" 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 + 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 }}" - " -t domus-app-edge5 tests/fixtures/edge5-app" in commands + 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 - 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") + (build + " --build-arg BUILD_ARCH=${{ matrix.arch }}") in command + 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 +99,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,26 +107,40 @@ 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"] -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() + 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/-]+@[a-f0-9]{40}", step["uses"]) + 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" + 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"]) source = WORKFLOW.read_text(encoding="utf-8") assert "uv sync --frozen" in source assert "pnpm install --frozen-lockfile" in source @@ -161,7 +196,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] @@ -174,9 +208,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 +255,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 +306,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 +314,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 +330,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: @@ -309,19 +349,23 @@ 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", "}}", "-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