From 651bcdd44c811b6ca240bb9e6a6b2d1d3caf044a Mon Sep 17 00:00:00 2001 From: ivanmilevtues Date: Thu, 15 Oct 2026 03:54:03 +0200 Subject: [PATCH] fix: read sync artifact manifest from Core's infra package Amp-Thread-ID: https://ampcode.com/threads/T-01a13d0d-fbe1-76fa-8fad-21c3940a2399 Co-authored-by: Amp --- .github/workflows/test.yml | 11 +++++++++++ scripts/action/install-sync.sh | 4 ++-- tests/test_action_sync.py | 11 +++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 280e3be..a8d6efd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,6 +42,17 @@ jobs: python -m pip install --disable-pip-version-check "$requirement" - name: Check the provider table against the installed release run: python -m unittest tests.test_provider_table_drift -v + - name: Install sync artifacts with the installed CodeBoarding release + shell: bash + env: + ACTION_PATH: ${{ github.workspace }} + ANALYSIS_DIR: ${{ runner.temp }}/sync-analysis + CHECKOUT_DIR: ${{ runner.temp }}/sync-checkout + run: | + mkdir -p "$ANALYSIS_DIR" "$CHECKOUT_DIR" + printf '{"components": []}\n' > "$ANALYSIS_DIR/analysis.json" + scripts/action/install-sync.sh + cmp "$ANALYSIS_DIR/analysis.json" "$CHECKOUT_DIR/.codeboarding/analysis.json" - name: Render with the installed CodeBoarding release run: >- python scripts/diff_to_mermaid.py diff --git a/scripts/action/install-sync.sh b/scripts/action/install-sync.sh index 90cca50..89b8074 100755 --- a/scripts/action/install-sync.sh +++ b/scripts/action/install-sync.sh @@ -7,9 +7,9 @@ fail() { echo "::error::$1" >&2; echo "failure_reason=$1" >> "${GITHUB_OUTPUT:-/ output="$CHECKOUT_DIR/.codeboarding" mkdir -p "$output" # Core exposes one canonical manifest. Read from the action's directory, never the -# analyzed repository's, which may have a constants.py of its own. +# analyzed repository's, which may have an infra package of its own. manifest="$(cd "$ACTION_PATH" && python3 - <<'PY' -from constants import ANALYSIS_FILENAME, PERSISTED_ANALYSIS_ARTIFACT_FILENAMES as artifacts +from infra.constants import ANALYSIS_FILENAME, PERSISTED_ANALYSIS_ARTIFACT_FILENAMES as artifacts print(ANALYSIS_FILENAME) print(*artifacts, sep="\n") PY diff --git a/tests/test_action_sync.py b/tests/test_action_sync.py index 0aab1e2..872036d 100644 --- a/tests/test_action_sync.py +++ b/tests/test_action_sync.py @@ -16,8 +16,10 @@ def write_core(path: Path) -> None: - """The part of Core's constants.py (0.14.5) that names the persisted artifacts.""" + """Core 0.15.0's packaged artifact manifest.""" + path = path / "infra" path.mkdir(parents=True, exist_ok=True) + (path / "__init__.py").touch() (path / "constants.py").write_text( "ANALYSIS_FILENAME = 'analysis.json'\n" "PERSISTED_ANALYSIS_ARTIFACT_FILENAMES = (\n" @@ -170,9 +172,10 @@ def test_installs_core_manifest_and_preserves_user_configuration(self) -> None: for directory in (output / "health", analysis): directory.mkdir(parents=True) - # The analyzed repository's own constants.py must never be what is read. - (checkout / "constants.py").write_text( - "raise RuntimeError('imported target constants')\n", encoding="utf-8" + # The analyzed repository's own infra package must never be imported. + (checkout / "infra").mkdir() + (checkout / "infra" / "__init__.py").write_text( + "raise RuntimeError('imported target infra')\n", encoding="utf-8" ) write_core(fake_core) produced = ("analysis.json", "fingerprint.json", "static_analysis.pkl")