From 6ae37633d7f7c77676290a6b74cd48547308b4d3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 4 Aug 2026 07:49:13 +0200 Subject: [PATCH] Validate completed app_config migration --- .../workflows/agent-migrate-app-config.yml | 131 ++++++++---------- 1 file changed, 57 insertions(+), 74 deletions(-) diff --git a/.github/workflows/agent-migrate-app-config.yml b/.github/workflows/agent-migrate-app-config.yml index 2ea09bf4e1..d390d5a241 100644 --- a/.github/workflows/agent-migrate-app-config.yml +++ b/.github/workflows/agent-migrate-app-config.yml @@ -1,5 +1,5 @@ --- -name: Migrate add-on config map names +name: Validate add-on config map migration on: pull_request: @@ -7,10 +7,10 @@ on: - agent/support-app-config-linter permissions: - contents: write + contents: read jobs: - migrate: + validate: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest steps: @@ -21,92 +21,75 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} fetch-depth: 0 - - name: Replace legacy map names + - name: Validate repository migration shell: bash run: | set -euo pipefail - python3 - <<'PY' - from __future__ import annotations - - import subprocess - from pathlib import Path - - LEGACY = b"addon_config" - CURRENT = b"app_config" - HELPER = Path(".github/workflows/agent-migrate-app-config.yml") - CHANGELOG_NOTE = "- Migrate legacy add-on configuration map names to current app configuration terminology.\n" - - - def tracked_paths() -> list[Path]: - output = subprocess.check_output(["git", "ls-files", "-z"]) - return [Path(value.decode()) for value in output.split(b"\0") if value] - - - paths = tracked_paths() - affected_addons: set[str] = set() - for path in paths: - if len(path.parts) != 2 or path.name not in { - "config.json", - "config.yaml", - "config.yml", - }: - continue - if path.is_symlink() or not path.is_file(): - continue - if LEGACY in path.read_bytes(): - affected_addons.add(path.parts[0]) - - if not affected_addons: - raise SystemExit("No add-on manifests containing addon_config were found") - - for addon in sorted(affected_addons): - changelog = Path(addon) / "CHANGELOG.md" - if not changelog.is_file(): - raise SystemExit(f"Missing required changelog: {changelog}") - text = changelog.read_text(encoding="utf-8") - if CHANGELOG_NOTE.strip() not in text: - changelog.write_text(CHANGELOG_NOTE + text, encoding="utf-8") - - replaced_files: list[Path] = [] - for path in paths: - if path == HELPER or path.is_symlink() or not path.is_file(): - continue - data = path.read_bytes() - if LEGACY not in data or b"\0" in data: - continue - path.write_bytes(data.replace(LEGACY, CURRENT)) - replaced_files.append(path) - - print(f"Affected add-ons: {len(affected_addons)}") - print(f"Files with terminology replacements: {len(replaced_files)}") - print("Affected add-ons:") - for addon in sorted(affected_addons): - print(f"- {addon}") - PY - - git diff --check + git diff --check "${{ github.event.pull_request.base.sha }}...HEAD" if git grep -n addon_config -- ':!.github/workflows/agent-migrate-app-config.yml'; then - echo "Legacy addon_config references remain outside the temporary migration workflow" >&2 + echo "Legacy map-name references remain outside the temporary validation workflow" >&2 exit 1 fi - changed_configs=$(git diff --name-only -- '*config.json' '*config.yaml' '*config.yml' | wc -l) + changed_configs=$(git diff --name-only "${{ github.event.pull_request.base.sha }}...HEAD" -- '*config.json' '*config.yaml' '*config.yml' | wc -l) + changed_changelogs=$(git diff --name-only "${{ github.event.pull_request.base.sha }}...HEAD" -- '*/CHANGELOG.md' | wc -l) if [ "$changed_configs" -eq 0 ]; then echo "No add-on manifests changed" >&2 exit 1 fi - echo "Changed manifests: $changed_configs" + if [ "$changed_changelogs" -lt "$changed_configs" ]; then + echo "Fewer changelogs than changed manifests: $changed_changelogs < $changed_configs" >&2 + exit 1 + fi - - name: Commit migration + echo "Changed manifests: $changed_configs" + echo "Changed changelogs: $changed_changelogs" + + - name: Run compatibility normalizer unit tests + run: python3 .github/scripts/test_prepare_addon_lint_config.py + + - name: Create current-schema linter fixtures shell: bash run: | set -euo pipefail + mkdir -p .tmp-addon-linter-short .tmp-addon-linter-long - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add -u - git diff --cached --check - git commit -m "Migrate legacy addon_config maps to app_config" - git push origin HEAD:${{ github.event.pull_request.head.ref }} + cat > .tmp-addon-linter-short/config.yaml <<'SHORT_FIXTURE' + --- + name: App Config Short Form Fixture + version: "1.0.0" + slug: app_config_short_fixture + description: Validates current Home Assistant short-form app map names + arch: + - amd64 + map: + - app_config:rw + - all_app_configs:ro + SHORT_FIXTURE + + cat > .tmp-addon-linter-long/config.yaml <<'LONG_FIXTURE' + --- + name: App Config Long Form Fixture + version: "1.0.0" + slug: app_config_long_fixture + description: Validates current Home Assistant long-form app map names + arch: + - amd64 + map: + - type: app_config + read_only: false + - type: all_app_configs + read_only: true + LONG_FIXTURE + + - name: Verify short-form current map names through upstream linter + uses: ./.github/actions/addon-linter + with: + path: ./.tmp-addon-linter-short + + - name: Verify long-form current map names through upstream linter + uses: ./.github/actions/addon-linter + with: + path: ./.tmp-addon-linter-long