Skip to content

Commit 215d57e

Browse files
fix: minimize review artifact payload
Amp-Thread-ID: https://ampcode.com/threads/T-019ecb81-dc76-76cb-8bf3-22a366c9be41 Co-authored-by: Amp <amp@ampcode.com>
1 parent fe8c28b commit 215d57e

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
One action, two modes: architecture review on every pull request, and a versioned, always-current architecture baseline on your main branch.
44

5-
- **`mode: review`** (the default) — CodeBoarding analyzes your architecture before and after a change, comments on the PR with an inline Mermaid diagram and hosted webview link, and uploads the PR-specific analysis JSON/health outputs as a GitHub Actions artifact. It never commits generated files to the PR branch. Runs on `pull_request` and `issue_comment`.
5+
- **`mode: review`** (the default) — CodeBoarding analyzes your architecture before and after a change, comments on the PR with an inline Mermaid diagram and hosted webview link, and uploads the PR-head `analysis.json` plus base-commit metadata as a GitHub Actions artifact. It never commits generated files to the PR branch. Runs on `pull_request` and `issue_comment`.
66
- **`mode: sync`** — CodeBoarding keeps your architecture analysis versioned and current on your branch: on every push it commits the `analysis.json` baseline, `static_analysis.pkl` cache pair, health report, and readable markdown (`.codeboarding/*.md`), so reviews diff against your current architecture and your architecture has real git history. Runs on `push`, `workflow_dispatch`, and `schedule`. See [sync mode](#keep-your-architecture-versioned-sync-mode).
77

88
Both modes run the [CodeBoarding](https://github.com/CodeBoarding/CodeBoarding) engine in CI: static analysis combined with LLM reasoning. They are designed to be used together — [sync mode keeps the baseline fresh that review mode diffs against](#how-the-two-modes-work-together) — but each works on its own.
@@ -23,7 +23,7 @@ Both modes run the [CodeBoarding](https://github.com/CodeBoarding/CodeBoarding)
2323
- Builds or reuses a baseline architecture analysis for the PR base.
2424
- Runs incremental analysis on the PR head, then diffs components and relationships.
2525
- Posts a sticky PR comment with an inline Mermaid map. Green is added, yellow is modified, red (dashed) is deleted, for both nodes and edges.
26-
- Uploads the PR analysis outputs as a GitHub Actions artifact and links the hosted webview to that artifact instead of committing generated files to the PR branch.
26+
- Uploads the PR-head `analysis.json` plus base-commit metadata as a GitHub Actions artifact and links the hosted webview to that artifact instead of committing generated files to the PR branch.
2727

2828
A PR comment looks like this:
2929

@@ -287,7 +287,7 @@ Review mode does not need `contents: write`: PR-specific generated files are sto
287287
| `diagram_md` | review | Path to the generated Mermaid markdown block on the runner. |
288288
| `n_changed` | review | Number of changed components, counted recursively. |
289289
| `truncated` | review | `true` when the graph was reduced to fit GitHub Mermaid limits. |
290-
| `review_artifact_url` | review | GitHub Actions artifact URL containing the PR base/head analysis outputs. |
290+
| `review_artifact_url` | review | GitHub Actions artifact URL containing the PR-head `analysis.json` and base-commit metadata. |
291291
| `analysis_mode` | sync | `full` or `incremental`: whether the run rebuilt the analysis from scratch or reused the committed baseline. |
292292
| `files_written` | sync | The generated files written for the docs commit. |
293293
| `committed` | sync | `true` when a docs commit was pushed to `target_branch`; `false` when sync mode ran but had nothing to commit (or the push failed open). Empty only if sync mode did not run. |

action.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ outputs:
132132
description: 'Sync mode: true when a docs commit was created and pushed.'
133133
value: ${{ steps.sync_commit.outputs.committed }}
134134
review_artifact_url:
135-
description: 'Review mode: GitHub Actions artifact URL containing PR analysis outputs.'
135+
description: 'Review mode: GitHub Actions artifact URL containing the PR-head analysis.json and metadata.'
136136
value: ${{ steps.upload_review_artifact.outputs.artifact-url }}
137137

138138
runs:
@@ -1126,11 +1126,10 @@ runs:
11261126
id: review_artifact
11271127
shell: bash
11281128
env:
1129-
BASE_ANALYSIS: ${{ steps.analyze.outputs.base_analysis }}
11301129
HEAD_ANALYSIS: ${{ steps.analyze.outputs.head_analysis }}
1131-
HEAD_DIR: ${{ steps.base.outputs.head_dir }}
1132-
DIAGRAM_MD: ${{ steps.diagram.outputs.diagram_md }}
11331130
BASE_SHA: ${{ steps.guard.outputs.base_sha }}
1131+
BASELINE_SHA: ${{ steps.base.outputs.baseline_sha }}
1132+
BASELINE_COMMITTED: ${{ steps.base.outputs.committed }}
11341133
HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
11351134
PR: ${{ steps.guard.outputs.pr_number }}
11361135
OWNER_REPO: ${{ github.repository }}
@@ -1142,19 +1141,18 @@ runs:
11421141
ARTIFACT_NAME="codeboarding-pr-${PR}-${HEAD_SHA}"
11431142
export ARTIFACT_NAME
11441143
rm -rf "$ARTIFACT_DIR"
1145-
mkdir -p "$ARTIFACT_DIR/base" "$ARTIFACT_DIR/head/health"
1146-
cp "$BASE_ANALYSIS" "$ARTIFACT_DIR/base/analysis.json"
1147-
cp "$HEAD_ANALYSIS" "$ARTIFACT_DIR/head/analysis.json"
1148-
[ -f "$HEAD_DIR/health/health_report.json" ] && cp "$HEAD_DIR/health/health_report.json" "$ARTIFACT_DIR/head/health/health_report.json"
1149-
[ -f "$DIAGRAM_MD" ] && cp "$DIAGRAM_MD" "$ARTIFACT_DIR/diagram.md"
1150-
[ -f "${RUNNER_TEMP}/diagram_meta.json" ] && cp "${RUNNER_TEMP}/diagram_meta.json" "$ARTIFACT_DIR/diagram_meta.json"
1144+
mkdir -p "$ARTIFACT_DIR"
1145+
cp "$HEAD_ANALYSIS" "$ARTIFACT_DIR/analysis.json"
11511146
python3 - <<'PY' > "$ARTIFACT_DIR/metadata.json"
11521147
import json, os
11531148
1149+
baseline_committed = os.environ["BASELINE_COMMITTED"] == "true"
11541150
print(json.dumps({
11551151
"repository": os.environ["OWNER_REPO"],
11561152
"pr": os.environ["PR"],
1157-
"base_sha": os.environ["BASE_SHA"],
1153+
"pr_base_sha": os.environ["BASE_SHA"],
1154+
"base_commit_sha": os.environ["BASELINE_SHA"] if baseline_committed else None,
1155+
"base_commit_found": baseline_committed,
11581156
"head_sha": os.environ["HEAD_SHA"],
11591157
"run_id": os.environ["RUN_ID"],
11601158
"run_attempt": os.environ["RUN_ATTEMPT"],

docs/COMMIT_STRATEGY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The engine writes these under `.codeboarding/`:
2222
-`static_analysis.pkl` + `static_analysis.sha` — required for reliable warm-start incremental sync from the committed baseline.
2323

2424
**Upload in review mode:**
25-
- ✅ PR base/head `analysis.json`, head health report, rendered diagram, and metadata — stored as a GitHub Actions artifact.
25+
- ✅ PR-head `analysis.json` and metadata containing the PR base SHA plus the committed baseline SHA when one was found — stored as a GitHub Actions artifact.
2626

2727
> **Principle:** sync mode is the only git writer. Review mode never commits generated files to PR branches, so generated artifacts cannot conflict with `main` during merge.
2828
@@ -51,6 +51,6 @@ Either way the head analysis is seeded from that directory and runs incrementall
5151
| Artifact | Commit? | Where | Why |
5252
|---|---|---|---|
5353
| `analysis.json` || sync commit on `main`; review artifact for PRs | diagram source |
54-
| `health_report.json` || sync commit on `main`; review artifact for PRs | warnings |
54+
| `health_report.json` || sync commit on `main`; computed in review for comments, not uploaded | warnings |
5555
| `static_analysis.pkl` || sync commit on `main` only | warm-start incremental baseline |
5656
| `static_analysis.sha` || with `static_analysis.pkl` | warm-start gate |

0 commit comments

Comments
 (0)