Skip to content

Commit 4cac22f

Browse files
fix: install CodeBoarding engine from PyPI
Amp-Thread-ID: https://ampcode.com/threads/T-019edcb0-130a-713d-8e97-997ec5e29b33 Co-authored-by: Amp <amp@ampcode.com>
1 parent 7339fbf commit 4cac22f

4 files changed

Lines changed: 54 additions & 79 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Review mode does not need `contents: write`: PR-specific generated files are sto
264264
| `mode` | both | `review` | `review` posts the PR architecture-diff comment; `sync` analyzes on push and commits the architecture (`analysis.json` + rendered docs) to `target_branch`, keeping it versioned and current. |
265265
| `github_token` | both | `${{ github.token }}` | Token for GitHub API calls; in review mode it posts or updates the PR comment. |
266266
| `push_token` | sync | `${{ github.token }}` | Token used for sync-mode pushes to `target_branch`. The workflow token can push when the workflow grants `permissions: contents: write`. Separate from `github_token` so commenting can use a GitHub App token while the push uses the workflow token. |
267-
| `engine_ref` | both | `v0.12.1` | CodeBoarding engine ref. Pin for reproducibility. |
267+
| `codeboarding_version` | both | `0.12.2` | CodeBoarding PyPI package version used as the analysis engine. Pin for reproducibility. |
268268
| `depth_level` | both | empty (`2` for cold starts) | Analysis depth, 1 to 3, used for first analysis and `force_full` rebuilds. Once `.codeboarding/analysis.json` exists, its `metadata.depth_level` is the source of truth for incremental analysis and fallback-full recovery. |
269269
| `render_depth` | review | `1` | Display depth for the PR diagram. Keep `1` for a clean top-level view. |
270270
| `diagram_direction` | review | `LR` | Mermaid direction: `LR`, `TD`, `TB`, `RL`, or `BT`. |
@@ -298,7 +298,7 @@ Outputs of the mode that did not run are empty strings.
298298

299299
## Notes
300300

301-
- No checkout step is required in your workflow. This action checks out the target (the PR in review mode, the pushed commit in sync mode) and the CodeBoarding engine internally.
301+
- No checkout step is required in your workflow. This action checks out the target (the PR in review mode, the pushed commit in sync mode) and installs the CodeBoarding engine from PyPI internally.
302302
- GitHub withholds secrets from fork PRs on `pull_request`, so fork runs fail early if an LLM key is unavailable.
303303
- Do not use `pull_request_target` for this action. It can expose secrets to PR-head code.
304304
- GitHub renders Mermaid in strict mode, so node click-through links are not supported in the PR diagram.
@@ -315,8 +315,9 @@ Full local pipeline:
315315

316316
```bash
317317
export OPENROUTER_API_KEY=sk-or-...
318-
scripts/run_local.sh --repo /path/to/repo --base <base-ref> --head <head-ref> \
319-
--engine /path/to/CodeBoarding
318+
python -m pip install codeboarding==0.12.2
319+
codeboarding-setup --auto-install-npm
320+
scripts/run_local.sh --repo /path/to/repo --base <base-ref> --head <head-ref>
320321
```
321322

322323
Useful flags:

‎action.yml‎

Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ inputs:
3131
description: 'Token used for sync-mode git pushes to target_branch. Defaults to the workflow github.token, which can push when the calling workflow grants "permissions: contents: write". Kept separate from github_token so commenting can use a GitHub App token while the push uses the workflow token (whose write access the consumer controls).'
3232
required: false
3333
default: ${{ github.token }}
34-
engine_ref:
35-
description: 'Git ref (tag/branch/SHA) of CodeBoarding/CodeBoarding used as the analysis engine. Pinned to a release for reproducibility; override to track a newer ref.'
34+
codeboarding_version:
35+
description: 'CodeBoarding PyPI package version used as the analysis engine. Pin for reproducibility; set to a newer released version to opt into newer engine releases.'
3636
required: false
37-
default: 'v0.12.1'
37+
default: '0.12.2'
3838
depth_level:
3939
description: 'Analysis depth (1-3) for cold-start or force_full rebuilds. Once .codeboarding/analysis.json exists, its metadata.depth_level is the source of truth for incremental analysis and fallback-full recovery. Empty (default): 2 for cold starts.'
4040
required: false
@@ -142,7 +142,7 @@ runs:
142142
# interleave only because they share the LLM-key lifecycle, NOT because they
143143
# are unrelated:
144144
# 1. GUARD — resolve mode + event eligibility + SHAs (one source of truth)
145-
# 2. SHARED SETUP — checkout engine + target, Python/Node/uv, caches, LLM-key prep
145+
# 2. SHARED SETUP — checkout target, Python/Node/uv, install CodeBoarding, caches, LLM-key prep
146146
# 3. ANALYSIS (key live) — review: base/seed/head/health ; sync: seed/analyze
147147
# 4. Drop LLM key, then OUTPUT (no key) — review: diff→artifact→comment ; sync: render→commit
148148
# The binding between the modes is the committed .codeboarding/analysis.json
@@ -425,15 +425,6 @@ runs:
425425
9.0.x
426426
10.0.x
427427
428-
- name: Checkout CodeBoarding engine
429-
if: steps.guard.outputs.skip != 'true'
430-
uses: actions/checkout@v4
431-
with:
432-
repository: CodeBoarding/CodeBoarding
433-
ref: ${{ inputs.engine_ref }}
434-
path: codeboarding-engine
435-
persist-credentials: false
436-
437428
# Review mode: the PR head repo at the head SHA. Sync mode: this repo at the
438429
# pushed/selected SHA. Always credential-free — sync pushes authenticate
439430
# explicitly via push_token.
@@ -508,36 +499,36 @@ runs:
508499
with:
509500
node-version: '20'
510501

511-
- name: Install uv
512-
if: steps.guard.outputs.skip != 'true'
513-
uses: astral-sh/setup-uv@v4
514-
with:
515-
enable-cache: true # cache ~/.cache/uv (wheels/builds) for fast cold installs
516-
517502
- name: Cache LSP servers
518503
if: steps.guard.outputs.skip != 'true'
519504
uses: actions/cache@v4
520505
with:
521506
path: |
522-
codeboarding-engine/static_analyzer/servers/node_modules
523-
codeboarding-engine/static_analyzer/servers/bin
524-
key: cb-lsp-${{ runner.os }}-v1
507+
~/.codeboarding/servers
508+
key: cb-lsp-${{ runner.os }}-${{ inputs.codeboarding_version }}-v1
525509
restore-keys: |
526510
cb-lsp-${{ runner.os }}-
527511
528-
- name: Install Python dependencies
512+
- name: Install CodeBoarding package
529513
if: steps.guard.outputs.skip != 'true'
530514
shell: bash
531-
working-directory: codeboarding-engine
515+
env:
516+
CODEBOARDING_VERSION: ${{ inputs.codeboarding_version }}
532517
run: |
533-
uv pip install -e .
518+
set -euo pipefail
519+
SPEC="$CODEBOARDING_VERSION"
520+
case "$SPEC" in
521+
'' ) SPEC='' ;;
522+
[0-9]* ) SPEC="==$SPEC" ;;
523+
esac
524+
python -m pip install --upgrade pip
525+
python -m pip install "codeboarding${SPEC}"
534526
535527
- name: Install LSP servers
536528
if: steps.guard.outputs.skip != 'true'
537529
shell: bash
538-
working-directory: codeboarding-engine
539530
run: |
540-
uv run python install.py --auto-install-npm
531+
codeboarding-setup --auto-install-npm
541532
542533
- name: Prepare & verify LLM key
543534
if: steps.guard.outputs.skip != 'true'
@@ -784,7 +775,7 @@ runs:
784775
# inputs. So a free-tier run (oidc, forced Gemini) and a BYO OpenRouter-key
785776
# run with no model pinned would share a key yet produce different base
786777
# analyses; the mode discriminator keeps them from reusing each other's cache.
787-
key: cb-base-v2-${{ runner.os }}-${{ steps.base.outputs.baseline_sha }}-d${{ steps.resolve_depth.outputs.depth }}-${{ inputs.engine_ref }}-${{ steps.llm.outputs.mode }}-${{ inputs.llm_provider }}-${{ inputs.agent_model }}-${{ inputs.parsing_model }}
778+
key: cb-base-v2-${{ runner.os }}-${{ steps.base.outputs.baseline_sha }}-d${{ steps.resolve_depth.outputs.depth }}-${{ inputs.codeboarding_version }}-${{ steps.llm.outputs.mode }}-${{ inputs.llm_provider }}-${{ inputs.agent_model }}-${{ inputs.parsing_model }}
788779

789780
- name: Reassert committed base analysis after cache restore
790781
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.base.outputs.committed == 'true'
@@ -818,10 +809,7 @@ runs:
818809
id: seedbase
819810
continue-on-error: true
820811
shell: bash
821-
working-directory: codeboarding-engine
822812
env:
823-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
824-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
825813
CACHING_DOCUMENTATION: 'false'
826814
ENABLE_MONITORING: 'false'
827815
ACTION_PATH: ${{ github.action_path }}
@@ -836,7 +824,7 @@ runs:
836824
git -C "$TARGET" worktree prune
837825
rm -rf "$BASE_SRC"
838826
git -C "$TARGET" worktree add --detach "$BASE_SRC" "$BASELINE_SHA"
839-
if uv run python "$ACTION_PATH/scripts/engine_adapter.py" seed \
827+
if python "$ACTION_PATH/scripts/engine_adapter.py" seed \
840828
--repo "$BASE_SRC" \
841829
--out "$BASE_DIR" \
842830
--source-sha "$BASELINE_SHA" \
@@ -855,10 +843,7 @@ runs:
855843
- name: Generate base analysis (no committed baseline)
856844
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.base.outputs.empty_base != 'true' && steps.base.outputs.committed == 'false' && steps.basecache.outputs.cache-hit != 'true'
857845
shell: bash
858-
working-directory: codeboarding-engine
859846
env:
860-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
861-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
862847
DIAGRAM_DEPTH_LEVEL: ${{ steps.resolve_depth.outputs.depth }}
863848
CACHING_DOCUMENTATION: 'false'
864849
ENABLE_MONITORING: 'false'
@@ -896,7 +881,7 @@ runs:
896881
git -C "$TARGET" worktree prune
897882
rm -rf "$BASE_SRC"
898883
git -C "$TARGET" worktree add --detach "$BASE_SRC" "$BASE_SHA"
899-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" base \
884+
python "$ACTION_PATH/scripts/engine_adapter.py" base \
900885
--repo "$BASE_SRC" \
901886
--out "$BASE_DIR" \
902887
--name "$REPO_NAME" \
@@ -924,16 +909,13 @@ runs:
924909
# inputs. So a free-tier run (oidc, forced Gemini) and a BYO OpenRouter-key
925910
# run with no model pinned would share a key yet produce different base
926911
# analyses; the mode discriminator keeps them from reusing each other's cache.
927-
key: cb-base-v2-${{ runner.os }}-${{ steps.base.outputs.baseline_sha }}-d${{ steps.resolve_depth.outputs.depth }}-${{ inputs.engine_ref }}-${{ steps.llm.outputs.mode }}-${{ inputs.llm_provider }}-${{ inputs.agent_model }}-${{ inputs.parsing_model }}
912+
key: cb-base-v2-${{ runner.os }}-${{ steps.base.outputs.baseline_sha }}-d${{ steps.resolve_depth.outputs.depth }}-${{ inputs.codeboarding_version }}-${{ steps.llm.outputs.mode }}-${{ inputs.llm_provider }}-${{ inputs.agent_model }}-${{ inputs.parsing_model }}
928913

929914
- name: Analyze PR head (incremental from base)
930915
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
931916
id: analyze
932917
shell: bash
933-
working-directory: codeboarding-engine
934918
env:
935-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
936-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
937919
DIAGRAM_DEPTH_LEVEL: ${{ steps.resolve_depth.outputs.depth }}
938920
CACHING_DOCUMENTATION: 'false'
939921
ENABLE_MONITORING: 'false'
@@ -986,32 +968,28 @@ runs:
986968
if [ "$EMPTY_BASE" = "true" ]; then
987969
head_args+=(--force-full)
988970
fi
989-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" "${head_args[@]}"
971+
python "$ACTION_PATH/scripts/engine_adapter.py" "${head_args[@]}"
990972
if [ ! -f "$HEAD_DIR/analysis.json" ]; then
991973
echo "::error::Head analysis ran but analysis.json is missing."
992974
exit 1
993975
fi
994-
echo "base_analysis=$BASE_DIR/analysis.json"
995-
$GITHUB_OUTPUT
976+
echo "base_analysis=$BASE_DIR/analysis.json" >> "$GITHUB_OUTPUT"
996977
echo "head_analysis=$HEAD_DIR/analysis.json" >> $GITHUB_OUTPUT
997978
998979
- name: Architecture health check (best-effort)
999980
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
1000981
id: health
1001982
continue-on-error: true
1002983
shell: bash
1003-
working-directory: codeboarding-engine
1004984
env:
1005-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
1006-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
1007985
ACTION_PATH: ${{ github.action_path }}
1008986
ARTIFACT_DIR: ${{ steps.base.outputs.head_dir }}
1009987
TARGET_REPO: ${{ github.workspace }}/target-repo
1010988
REPO_NAME: ${{ github.event.repository.name }}
1011989
run: |
1012990
rm -f /tmp/cb-issues.txt
1013991
# engine_adapter writes the WARNING/CRITICAL count (0 on any failure — best-effort).
1014-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" health \
992+
python "$ACTION_PATH/scripts/engine_adapter.py" health \
1015993
--artifact-dir "$ARTIFACT_DIR" \
1016994
--repo "$TARGET_REPO" \
1017995
--name "$REPO_NAME" \
@@ -1085,7 +1063,7 @@ runs:
10851063
path: |
10861064
${{ runner.temp }}/cb-sync/static_analysis.pkl
10871065
${{ runner.temp }}/cb-sync/static_analysis.sha
1088-
key: cb-sync-${{ runner.os }}-${{ inputs.engine_ref }}-d${{ steps.resolve_depth.outputs.depth }}-${{ steps.llm.outputs.cache_provider }}-${{ steps.llm.outputs.cache_agent_model }}-${{ steps.llm.outputs.cache_parsing_model }}-${{ steps.sync_seed.outputs.baseline_sha }}
1066+
key: cb-sync-${{ runner.os }}-${{ inputs.codeboarding_version }}-d${{ steps.resolve_depth.outputs.depth }}-${{ steps.llm.outputs.cache_provider }}-${{ steps.llm.outputs.cache_agent_model }}-${{ steps.llm.outputs.cache_parsing_model }}-${{ steps.sync_seed.outputs.baseline_sha }}
10891067

10901068
# Same rationale as the review pipeline's seed step: the committed
10911069
# analysis.json supplies component ids, but the incremental path also needs
@@ -1095,10 +1073,7 @@ runs:
10951073
id: sync_seedcache
10961074
continue-on-error: true
10971075
shell: bash
1098-
working-directory: codeboarding-engine
10991076
env:
1100-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
1101-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
11021077
# The seed subcommand defaults to github_action attribution; sync-mode
11031078
# telemetry must report as sync (setdefault never clobbers this).
11041079
CODEBOARDING_SOURCE: 'sync'
@@ -1123,7 +1098,7 @@ runs:
11231098
git -C "$TARGET_REPO" worktree prune
11241099
rm -rf "$BASE_SRC"
11251100
git -C "$TARGET_REPO" worktree add --detach "$BASE_SRC" "$BASELINE_SHA"
1126-
if uv run python "$ACTION_PATH/scripts/engine_adapter.py" seed \
1101+
if python "$ACTION_PATH/scripts/engine_adapter.py" seed \
11271102
--repo "$BASE_SRC" \
11281103
--out "$ANALYSIS_DIR" \
11291104
--source-sha "$BASELINE_SHA" \
@@ -1140,10 +1115,7 @@ runs:
11401115
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
11411116
id: sync_analyze
11421117
shell: bash
1143-
working-directory: codeboarding-engine
11441118
env:
1145-
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
1146-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
11471119
DIAGRAM_DEPTH_LEVEL: ${{ steps.resolve_depth.outputs.depth }}
11481120
CACHING_DOCUMENTATION: 'false'
11491121
ENABLE_MONITORING: 'false'
@@ -1186,7 +1158,7 @@ runs:
11861158
)
11871159
[ "$FORCE_FULL" = "true" ] && args+=(--force-full)
11881160
LOG="${RUNNER_TEMP}/cb-sync-analyze.log"
1189-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" analyze "${args[@]}" | tee "$LOG"
1161+
python "$ACTION_PATH/scripts/engine_adapter.py" analyze "${args[@]}" | tee "$LOG"
11901162
MODE="$(sed -n 's/^analysis_mode=//p' "$LOG" | tail -1)"
11911163
MODE="${MODE:-unknown}"
11921164
echo "analysis_mode=$MODE" >> "$GITHUB_OUTPUT"
@@ -1417,9 +1389,7 @@ runs:
14171389
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
14181390
id: sync_render
14191391
shell: bash
1420-
working-directory: codeboarding-engine
14211392
env:
1422-
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
14231393
ACTION_PATH: ${{ github.action_path }}
14241394
ANALYSIS_DIR: ${{ steps.sync_seed.outputs.cb_dir }}
14251395
RENDER_DIR: ${{ steps.sync_seed.outputs.render_dir }}
@@ -1433,14 +1403,14 @@ runs:
14331403
run: |
14341404
set -euo pipefail
14351405
REPO_REF="https://github.com/${REPOSITORY}/blob/${TARGET_BRANCH}/${OUTPUT_DIR}"
1436-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" render \
1406+
python "$ACTION_PATH/scripts/engine_adapter.py" render \
14371407
--analysis "$ANALYSIS_DIR/analysis.json" \
14381408
--out "$RENDER_DIR" \
14391409
--repo-name "$REPO_NAME" \
14401410
--repo-ref "$REPO_REF" \
14411411
--format "$OUTPUT_FORMAT"
14421412
if [ "$WRITE_ARCHITECTURE_MD" = "true" ]; then
1443-
uv run python "$ACTION_PATH/scripts/engine_adapter.py" concat \
1413+
python "$ACTION_PATH/scripts/engine_adapter.py" concat \
14441414
--docs-dir "$RENDER_DIR" \
14451415
--out "$ARCHITECTURE_FILE"
14461416
fi
@@ -1470,7 +1440,7 @@ runs:
14701440
path: |
14711441
${{ runner.temp }}/cb-sync/static_analysis.pkl
14721442
${{ runner.temp }}/cb-sync/static_analysis.sha
1473-
key: cb-sync-${{ runner.os }}-${{ inputs.engine_ref }}-d${{ steps.resolve_depth.outputs.depth }}-${{ steps.llm.outputs.cache_provider }}-${{ steps.llm.outputs.cache_agent_model }}-${{ steps.llm.outputs.cache_parsing_model }}-${{ steps.guard.outputs.target_sha }}
1443+
key: cb-sync-${{ runner.os }}-${{ inputs.codeboarding_version }}-d${{ steps.resolve_depth.outputs.depth }}-${{ steps.llm.outputs.cache_provider }}-${{ steps.llm.outputs.cache_agent_model }}-${{ steps.llm.outputs.cache_parsing_model }}-${{ steps.guard.outputs.target_sha }}
14741444

14751445
- name: Commit and push synced architecture
14761446
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'

‎scripts/engine_adapter.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""CLI adapter between the action and the CodeBoarding analysis ENGINE.
22
3-
No analysis logic lives here. The engine is the separate ``CodeBoarding/
4-
CodeBoarding`` repo, checked out at runtime into ``codeboarding-engine/``; this
5-
module just turns the action's shell steps into typed, tested calls into it.
3+
No analysis logic lives here. The engine is the published ``codeboarding`` PyPI
4+
package installed by the action and imported lazily inside each function
5+
(``codeboarding_workflows`` etc.); this module just turns the action's shell
6+
steps into typed, tested calls into it. The lazy imports mean this file imports
7+
fine without the package present — the tests stub those modules and assert we
8+
call the engine with the right args.
69
710
Subcommands (all paths/refs come in as argv, never interpolated into source):
811

0 commit comments

Comments
 (0)