Skip to content

Commit 4db6869

Browse files
fix: read sync artifact manifest from Core's infra package (#147)
Amp-Thread-ID: https://ampcode.com/threads/T-01a13d0d-fbe1-76fa-8fad-21c3940a2399 Co-authored-by: Amp <amp@ampcode.com>
1 parent f985011 commit 4db6869

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ jobs:
4242
python -m pip install --disable-pip-version-check "$requirement"
4343
- name: Check the provider table against the installed release
4444
run: python -m unittest tests.test_provider_table_drift -v
45+
- name: Install sync artifacts with the installed CodeBoarding release
46+
shell: bash
47+
env:
48+
ACTION_PATH: ${{ github.workspace }}
49+
ANALYSIS_DIR: ${{ runner.temp }}/sync-analysis
50+
CHECKOUT_DIR: ${{ runner.temp }}/sync-checkout
51+
run: |
52+
mkdir -p "$ANALYSIS_DIR" "$CHECKOUT_DIR"
53+
printf '{"components": []}\n' > "$ANALYSIS_DIR/analysis.json"
54+
scripts/action/install-sync.sh
55+
cmp "$ANALYSIS_DIR/analysis.json" "$CHECKOUT_DIR/.codeboarding/analysis.json"
4556
- name: Render with the installed CodeBoarding release
4657
run: >-
4758
python scripts/diff_to_mermaid.py

‎scripts/action/install-sync.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ fail() { echo "::error::$1" >&2; echo "failure_reason=$1" >> "${GITHUB_OUTPUT:-/
77
output="$CHECKOUT_DIR/.codeboarding"
88
mkdir -p "$output"
99
# Core exposes one canonical manifest. Read from the action's directory, never the
10-
# analyzed repository's, which may have a constants.py of its own.
10+
# analyzed repository's, which may have an infra package of its own.
1111
manifest="$(cd "$ACTION_PATH" && python3 - <<'PY'
12-
from constants import ANALYSIS_FILENAME, PERSISTED_ANALYSIS_ARTIFACT_FILENAMES as artifacts
12+
from infra.constants import ANALYSIS_FILENAME, PERSISTED_ANALYSIS_ARTIFACT_FILENAMES as artifacts
1313
print(ANALYSIS_FILENAME)
1414
print(*artifacts, sep="\n")
1515
PY

‎tests/test_action_sync.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717

1818
def write_core(path: Path) -> None:
19-
"""The part of Core's constants.py (0.14.5) that names the persisted artifacts."""
19+
"""Core 0.15.0's packaged artifact manifest."""
20+
path = path / "infra"
2021
path.mkdir(parents=True, exist_ok=True)
22+
(path / "__init__.py").touch()
2123
(path / "constants.py").write_text(
2224
"ANALYSIS_FILENAME = 'analysis.json'\n"
2325
"PERSISTED_ANALYSIS_ARTIFACT_FILENAMES = (\n"
@@ -170,9 +172,10 @@ def test_installs_core_manifest_and_preserves_user_configuration(self) -> None:
170172
for directory in (output / "health", analysis):
171173
directory.mkdir(parents=True)
172174

173-
# The analyzed repository's own constants.py must never be what is read.
174-
(checkout / "constants.py").write_text(
175-
"raise RuntimeError('imported target constants')\n", encoding="utf-8"
175+
# The analyzed repository's own infra package must never be imported.
176+
(checkout / "infra").mkdir()
177+
(checkout / "infra" / "__init__.py").write_text(
178+
"raise RuntimeError('imported target infra')\n", encoding="utf-8"
176179
)
177180
write_core(fake_core)
178181
produced = ("analysis.json", "fingerprint.json", "static_analysis.pkl")

0 commit comments

Comments
 (0)