@@ -257,22 +257,42 @@ runs:
257257 REPO_NAME="${{ github.event.repository.name }}"
258258 RUN_ID="${{ github.run_id }}-${{ github.run_attempt }}"
259259
260- # Use run_incremental directly against the already-checked-out PR
261- # head — avoids generate_analysis()'s redundant clone (which only
262- # gets 'main' as a local head and fails on checkout_repo).
260+ # Use run_incremental against the already-checked-out PR head.
261+ # On IncrementalCacheMissingError (legacy pkl, tiny repo with no
262+ # cluster baseline, first-ever incremental run) fall back to a full
263+ # run — yields a fresh analysis.json that we can still diff against
264+ # the base SHA's analysis.json.
263265 uv run python -c "
264266 from pathlib import Path
265- from codeboarding_workflows.analysis import run_incremental
266- result = run_incremental(
267- repo_path=Path('$TARGET_REPO'),
268- output_dir=Path('$SEED_DIR'),
269- project_name='$REPO_NAME',
270- run_id='$RUN_ID',
271- log_path='/tmp/cb-analysis.log',
272- base_ref='$BASE_SHA',
273- target_ref='$HEAD_SHA',
274- source_sha='$HEAD_SHA',
275- )
267+ from codeboarding_workflows.analysis import run_incremental, run_full
268+ from diagram_analysis.exceptions import IncrementalCacheMissingError
269+ try:
270+ result = run_incremental(
271+ repo_path=Path('$TARGET_REPO'),
272+ output_dir=Path('$SEED_DIR'),
273+ project_name='$REPO_NAME',
274+ run_id='$RUN_ID',
275+ log_path='/tmp/cb-analysis.log',
276+ base_ref='$BASE_SHA',
277+ target_ref='$HEAD_SHA',
278+ source_sha='$HEAD_SHA',
279+ )
280+ except IncrementalCacheMissingError as exc:
281+ print(f'Incremental unavailable ({exc}); falling back to full analysis.')
282+ # Wipe the seed dir so run_full starts clean (it picks up
283+ # depth_level from env / default).
284+ for p in Path('$SEED_DIR').glob('*'):
285+ if p.is_file():
286+ p.unlink()
287+ result = run_full(
288+ repo_name='$REPO_NAME',
289+ repo_path=Path('$TARGET_REPO'),
290+ output_dir=Path('$SEED_DIR'),
291+ run_id='$RUN_ID',
292+ log_path='/tmp/cb-analysis.log',
293+ depth_level=int('${{ inputs.depth_level }}'),
294+ source_sha='$HEAD_SHA',
295+ )
276296 print(f'Wrote: {result}')
277297 "
278298
0 commit comments