Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/scripts/verify-catalog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail

# Do not mount the runner's Docker client configuration into the build.
docker_host=$(docker context inspect --format '{{.Endpoints.docker.Host}}')
docker_config=$(mktemp -d "${RUNNER_TEMP:?}/ha-ui-docker.XXXXXX")
container="ha-ui-catalog-${GITHUB_RUN_ID:?}-${GITHUB_RUN_ATTEMPT:?}"
export DOCKER_HOST="$docker_host" DOCKER_CONFIG="$docker_config"
unset DOCKER_CONTEXT

cleanup() {
docker rm --force "$container" >/dev/null 2>&1 || true
rm -rf -- "$docker_config"
}
trap cleanup EXIT

docker run --rm --init --interactive --name "$container" --platform linux/arm64 \
--shm-size 1g \
--mount "type=bind,source=$(pwd -P),target=/workspace" \
--workdir /workspace \
--env CI=1 --env STORYBOOK_DISABLE_TELEMETRY=1 \
--env npm_config_store_dir=/tmp/ha-ui-pnpm-store \
--env "HA_UI_PACKED_EXPECTED_REVISION=${HA_UI_PACKED_EXPECTED_REVISION:-}" \
"${HA_UI_PLAYWRIGHT_IMAGE:?}" bash -euo pipefail <<'LINUX'
HA_UI_NODE_VERSION=$(tr -d '\r\n' < .node-version)
package_manager=$(node --print 'require("./package.json").packageManager')
HA_UI_PNPM_VERSION=${package_manager#pnpm@}
export HA_UI_NODE_VERSION HA_UI_PNPM_VERSION

npm exec --yes --package="node@$HA_UI_NODE_VERSION" --package="$package_manager" -c '
set -eu
test "$(node --version)" = "v$HA_UI_NODE_VERSION"
test "$(pnpm --version)" = "$HA_UI_PNPM_VERSION"
pnpm install --frozen-lockfile --ignore-scripts
pnpm check
pnpm test
if [ -n "$HA_UI_PACKED_EXPECTED_REVISION" ]; then
pnpm build
fi
GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.directory GIT_CONFIG_VALUE_0=/workspace pnpm test:package
pnpm test:ssr
pnpm storybook:build
pnpm test:engines
pnpm test:storybook
'
LINUX
48 changes: 11 additions & 37 deletions .github/workflows/ci_check.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,35 @@
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: ['**']
env:
STORYBOOK_DISABLE_TELEMETRY: "1"
permissions:
contents: read
jobs:
quality:
name: CI Check
runs-on: ubuntu-latest
Comment thread
vypbot marked this conversation as resolved.
Resolved
container:
image: mcr.microsoft.com/playwright:v1.64.1-noble@sha256:2f05f8a734509a7b3f26a912639488ee08f58a7b292d14d62271bcff9038768f
options: --ipc=host
runs-on:
group: vypdev
labels: [self-hosted, macOS, ARM64]
env:
npm_config_store_dir: /tmp/ha-ui-pnpm-store
# Linux ARM64 manifest from the Playwright 1.64.1 Noble index.
HA_UI_PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright@sha256:f609973e8fd93f38a5ddfd706a65805294247dae8d81b2541c0afe2787746197
# The catalog has its own phase deadlines; this job also verifies packages and SSR.
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Validate the catalog and bind packed consumers to the checked commit
shell: bash
env:
HA_UI_PACKED_EXPECTED_REVISION: ${{ github.sha }}
run: bash .github/scripts/verify-catalog.sh
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
run_install: false
cache: false
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm check
- run: pnpm test
- run: pnpm build
- name: Verify packed consumers and candidate provenance
env:
HA_UI_PACKED_EXPECTED_REVISION: ${{ github.sha }}
run: |
export GIT_CONFIG_COUNT=1
export GIT_CONFIG_KEY_0=safe.directory
export GIT_CONFIG_VALUE_0="$(pwd -P)"
pnpm test:package
- run: pnpm test:ssr
- run: pnpm storybook:build
- name: Run the browser engine matrix
shell: bash
run: |
test "$HOME" = /github/home
original_owner=$(stat -c '%u:%g' /github/home)
trap 'chown -- "$original_owner" /github/home' EXIT
chown -- "$(id -u):$(id -g)" /github/home
pnpm test:engines
- run: pnpm test:storybook
# Read the original catalog SDK at the reviewed revision; never rewrite it.
- name: Read the original specification SDK
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/npm_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ permissions:

jobs:
candidate:
runs-on: ubuntu-latest
runs-on:
group: vypdev
labels: [self-hosted, codex, Linux]
timeout-minutes: 5
permissions:
actions: read
Expand Down
34 changes: 7 additions & 27 deletions .github/workflows/storybook_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,21 @@ concurrency:
jobs:
build:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.64.1-noble@sha256:2f05f8a734509a7b3f26a912639488ee08f58a7b292d14d62271bcff9038768f
options: --ipc=host
runs-on:
group: vypdev
labels: [self-hosted, macOS, ARM64]
env:
npm_config_store_dir: /tmp/ha-ui-pnpm-store
# Linux ARM64 manifest from the same Playwright 1.64.1 Noble index as CI.
HA_UI_PLAYWRIGHT_IMAGE: mcr.microsoft.com/playwright@sha256:f609973e8fd93f38a5ddfd706a65805294247dae8d81b2541c0afe2787746197
# The published catalog runs the same browser gates as CI.
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
run_install: false
cache: false
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm check
- run: pnpm test
- run: pnpm test:package
- run: pnpm test:ssr
- run: pnpm storybook:build
- name: Run the browser engine matrix
- name: Build and verify Storybook in Linux
shell: bash
run: |
test "$HOME" = /github/home
original_owner=$(stat -c '%u:%g' /github/home)
trap 'chown -- "$original_owner" /github/home' EXIT
chown -- "$(id -u):$(id -g)" /github/home
pnpm test:engines
- run: pnpm test:storybook
run: bash .github/scripts/verify-catalog.sh
- uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
with:
path: build/storybook
Expand Down
2 changes: 1 addition & 1 deletion docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Disabled defaults to false. Labels and links retain their original values; snaps
Invalid/extra fields, conflicting selection and unsafe or credential-bearing links raise the bounded
NavigationInputError with code invalid_navigation. This validates data, not authorization or rendering.

CI Check runs for each PR head with no path filter. Current gates are strict types, all implemented
CI Check runs for each branch push to this repository with no path filter. Current gates are strict types, all implemented
tests, independent source-inventory coverage, architecture/CI contracts, compiled declarations, real Chromium component behavior, actual reproducible packed consumption with
a DOM-free contract and a compiled browser client, and the original pinned Copilot catalog validator.
The packed browser fixture exercises real links, panel slots, keyboard, live Spanish labels/theme,
Expand Down
13 changes: 9 additions & 4 deletions docs/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,24 @@ shared fixes. No additional browser engine, owner HA installation or human accep

## Delivery

Every PR update runs `CI Check`, including strict types, full coverage, compiled package consumers,
static catalog build and the static browser gate. Its retained artifact includes `build/storybook/`,
Every branch push to this repository runs `CI Check`, including strict types, full coverage, compiled package consumers,
the static catalog build and the static browser gate. An internal pull request shows CI for its pushed head.
Bring the head up to date with the target branch before merging. Its retained artifact includes `build/storybook/`,
coverage and browser evidence. This makes a candidate reviewable before merge. The separate Pages
workflow builds and rechecks trusted `master` before upload; only its deployment job receives Pages
write and OIDC permission. It never executes PR code with deployment permissions.

Fork workflows require maintainer approval in GitHub.
CI and the Pages build use Apple Silicon runners in the organization's `vypdev` group.
Each runs the Linux build in a job-specific Docker container and keeps the
runner's Docker credentials outside the container. The Pages deployment job uses
a GitHub-hosted runner for OIDC publication.

Both validation jobs use the [official Playwright Noble image](https://playwright.dev/docs/docker)
pinned by digest to the version in the lockfile. The image supplies Chromium, Firefox, WebKit and
their system libraries. Each job still installs the project's exact Node and pnpm toolchain and
uses the frozen dependency lock. The workspace and offline package fixtures share a
container-local pnpm store even when their directories are on different mounts.
The browser matrix temporarily matches the isolated job home ownership to the
container user for Firefox and restores its owner when the step exits.

The intended public destination is the repository Pages subpath `/ha-ui/`. Public hosting is pending
until the complete feature can merge and Pages is enabled for Actions. The existence of a workflow
Expand Down
67 changes: 37 additions & 30 deletions tests/architecture.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,24 @@ test('every actual core module respects the dependency boundary', () => {
if (dependency.startsWith('.')) expect(relative(resolve('packages/core/src'), resolve(dirname(file), dependency)).startsWith('..')).toBe(false);
}
});
test('CI Check runs for every PR update with frozen tools and all implemented quality gates', () => {
test('CI Check runs on branch pushes with frozen tools and all implemented quality gates', () => {
const workflow = parse(readFileSync('.github/workflows/ci_check.yml', 'utf8'));
expect(workflow.name).toBe('CI Check');
expect(workflow.on.pull_request.types).toEqual(expect.arrayContaining(['opened','reopened','synchronize','ready_for_review','converted_to_draft']));
expect(workflow.on.pull_request.paths).toBeUndefined();
expect(workflow.on).toEqual({push: {branches: ['**']}});
const job = workflow.jobs.quality;
expect(job.name).toBe('CI Check'); expect(job.if).toBeUndefined();
expect(job.name).toBe('CI Check');
expect(job['runs-on']).toEqual({group: 'vypdev', labels: ['self-hosted', 'macOS', 'ARM64']});
expect(job['continue-on-error']).toBeUndefined();
expect(job.steps.every(step => step['continue-on-error'] === undefined)).toBe(true);
const playwright = JSON.parse(readFileSync('package.json', 'utf8')).devDependencies.playwright;
const [image, digest] = job.container.image.split('@');
expect(image).toBe(`mcr.microsoft.com/playwright:v${playwright}-noble`);
expect(digest).toMatch(/^sha256:[a-f0-9]{64}$/u);
expect(job.container.options).toBe('--ipc=host');
expect(job.env.npm_config_store_dir).toBe('/tmp/ha-ui-pnpm-store');
const commands = job.steps.flatMap(step => step.run?.split('\n') ?? []);
expect(commands.some(command => command.startsWith('pnpm exec playwright install'))).toBe(false);
for (const command of ['pnpm install --frozen-lockfile --ignore-scripts', 'pnpm check', 'pnpm test', 'pnpm build', 'pnpm test:package','pnpm test:ssr','pnpm storybook:build','pnpm test:storybook','pnpm test:engines']) expect(commands).toContain(command);
const packed = job.steps.find(step => step.name === 'Verify packed consumers and candidate provenance');
const packed = job.steps.find(step => step.run === 'bash .github/scripts/verify-catalog.sh');
expect(packed.env.HA_UI_PACKED_EXPECTED_REVISION).toBe('${{ github.sha }}');
expect(packed.run.trim().split('\n')).toEqual([
'export GIT_CONFIG_COUNT=1',
'export GIT_CONFIG_KEY_0=safe.directory',
'export GIT_CONFIG_VALUE_0="$(pwd -P)"',
'pnpm test:package',
]);
expect(commands.indexOf('pnpm test:engines')).toBeLessThan(commands.indexOf('pnpm test:storybook'));
const engines = job.steps.find(step => step.name === 'Run the browser engine matrix');
expect(engines.shell).toBe('bash');
expect(engines.run).toContain('test "$HOME" = /github/home');
expect(engines.run).toContain('trap \'chown -- "$original_owner" /github/home\' EXIT');
const verify = readFileSync('.github/scripts/verify-catalog.sh', 'utf8');
expect(verify).toContain('--env "HA_UI_PACKED_EXPECTED_REVISION=${HA_UI_PACKED_EXPECTED_REVISION:-}"');
expect(verify).toContain('if [ -n "$HA_UI_PACKED_EXPECTED_REVISION" ]; then');
expect(verify).toContain('GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.directory GIT_CONFIG_VALUE_0=/workspace pnpm test:package');
expect(verify).toContain('pnpm build');
expect(verify.indexOf('pnpm test:engines')).toBeLessThan(verify.indexOf('pnpm test:storybook'));
const sdk = job.steps.find(step => step.with?.repository === 'vypdev/copilot');
expect(sdk.with.ref).toBe('3e7ceea08e6131360e026937d1c0cc1b120472e0');
expect(sdk.with['persist-credentials']).toBe(false);
Expand Down Expand Up @@ -177,13 +164,33 @@ test('Pages builds only the trusted default branch and grants write permissions
const build=workflow.jobs.build,deploy=workflow.jobs.deploy;
expect(build.if).toBe("github.ref == 'refs/heads/master'");expect(build.permissions).toBeUndefined();
const quality = parse(readFileSync('.github/workflows/ci_check.yml', 'utf8')).jobs.quality;
expect(build.container).toEqual(quality.container);
expect(build.env.npm_config_store_dir).toBe(quality.env.npm_config_store_dir);
expect(build.container).toBeUndefined();
expect(build.env.HA_UI_PLAYWRIGHT_IMAGE).toBe('mcr.microsoft.com/playwright@sha256:f609973e8fd93f38a5ddfd706a65805294247dae8d81b2541c0afe2787746197');
expect(quality.env.HA_UI_PLAYWRIGHT_IMAGE).toBe(build.env.HA_UI_PLAYWRIGHT_IMAGE);
expect(deploy.container).toBeUndefined();
expect(build.steps.some(step => step.run?.startsWith('pnpm exec playwright install'))).toBe(false);
expect(build.steps.find(step=>step.name==='Run the browser engine matrix'))
.toEqual(quality.steps.find(step=>step.name==='Run the browser engine matrix'));
for(const command of ['pnpm install --frozen-lockfile --ignore-scripts','pnpm check','pnpm test','pnpm test:package','pnpm test:ssr','pnpm storybook:build','pnpm test:storybook','pnpm test:engines'])expect(build.steps.flatMap(step=>step.run?.split('\n')??[])).toContain(command);
expect(build.steps.some(step => step.run === 'bash .github/scripts/verify-catalog.sh')).toBe(true);
const verify = readFileSync('.github/scripts/verify-catalog.sh', 'utf8');
expect(verify).toContain('--platform linux/arm64');
expect(verify).toContain('--env npm_config_store_dir=/tmp/ha-ui-pnpm-store');
expect(verify).not.toContain('playwright install');
for (const command of ['pnpm install --frozen-lockfile --ignore-scripts', 'pnpm check', 'pnpm test',
'pnpm test:package', 'pnpm test:ssr', 'pnpm storybook:build', 'pnpm test:storybook', 'pnpm test:engines']) {
expect(verify.split('\n').some(line => line.trimEnd().endsWith(' '+command))).toBe(true);
}
expect(deploy.needs).toBe('build');expect(deploy.permissions).toEqual({pages:'write','id-token':'write'});
expect(deploy.environment.name).toBe('github-pages');expect(workflow.concurrency['cancel-in-progress']).toBe(false);
});

test('publication preparation uses organization runners and OIDC jobs use GitHub runners', () => {
const pages = parse(readFileSync('.github/workflows/storybook_pages.yml', 'utf8'));
const npm = parse(readFileSync('.github/workflows/npm_release.yml', 'utf8'));
expect(pages.jobs.build['runs-on']).toEqual({group: 'vypdev', labels: ['self-hosted', 'macOS', 'ARM64']});
expect(npm.jobs.candidate['runs-on']).toEqual({group: 'vypdev', labels: ['self-hosted', 'codex', 'Linux']});
for (const job of [pages.jobs.build, npm.jobs.candidate]) {
expect(job.permissions?.['id-token']).toBeUndefined();
}
for (const job of [pages.jobs.deploy, npm.jobs.publish]) {
expect(job['runs-on']).toBe('ubuntu-latest');
expect(job.permissions['id-token']).toBe('write');
}
});
Loading