Skip to content

Commit 1bee76d

Browse files
gnodetclaude
andcommitted
ci: fix Scalpel fetch failure in shallow CI clones
Pre-fetch the base branch using git CLI in the workflow instead of relying on Scalpel's JGit fetchBaseBranch=true. JGit's FetchCommand crashes with MissingObjectException during fetchSubmodules in GitHub Actions' shallow clones, even with fetchBaseBranch enabled. - Remove persist-credentials: false so git fetch works after checkout - Add "Fetch base branch" step using git CLI (handles shallow clones) - Set scalpel.fetchBaseBranch=false (base branch already available) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 98f1de8 commit 1bee76d

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

.github/CI-ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Scalpel flags are set in `etc/scripts/regen.sh` when running in CI (`GITHUB_ACTI
131131
| --- | --- | --- |
132132
| `scalpel.mode` | `skip-tests` | Build all, test only affected |
133133
| `scalpel.skipTestsForUpstream` | `true` | Don't test upstream-only modules |
134-
| `scalpel.fetchBaseBranch` | `true` | Auto-fetch base branch in shallow clones |
134+
| `scalpel.fetchBaseBranch` | `false` | Base branch pre-fetched by workflow (git CLI handles shallow clones better than JGit) |
135135
| `scalpel.fullBuildTriggers` | *(empty)* | Override `.mvn/**` default |
136136
| `scalpel.reportFile` | `target/scalpel-report.json` | JSON report for PR comment |
137137
| `scalpel.impactedLog` | `target/scalpel-impacted.txt` | Simple module path list |

.github/workflows/pr-build-main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ jobs:
7676
steps:
7777
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7878
with:
79-
persist-credentials: false
8079
ref: ${{ inputs.pr_ref || '' }}
80+
- name: Fetch base branch for Scalpel change detection
81+
if: ${{ !inputs.skip_full_build }}
82+
run: |
83+
# Scalpel needs the base branch to detect changes.
84+
# git CLI handles shallow clones reliably (JGit's fetchSubmodules does not).
85+
git fetch --no-tags --depth=200 origin "${GITHUB_BASE_REF:-main}:refs/remotes/origin/${GITHUB_BASE_REF:-main}"
8186
- id: install-packages
8287
uses: ./.github/actions/install-packages
8388
- id: install-mvnd

.github/workflows/sonar-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
runs-on: ubuntu-latest
4444
steps:
4545
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46-
with:
47-
persist-credentials: false
48-
46+
- name: Fetch base branch for Scalpel change detection
47+
run: |
48+
git fetch --no-tags --depth=200 origin "${GITHUB_BASE_REF:-main}:refs/remotes/origin/${GITHUB_BASE_REF:-main}"
4949
- id: install-packages
5050
uses: ./.github/actions/install-packages
5151

etc/scripts/regen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rm -Rf **/src/generated/
3939
# On developer machines, Scalpel auto-disables (no GITHUB_BASE_REF).
4040
scalpel_flags=""
4141
if [ "${GITHUB_ACTIONS:-}" = "true" ] && [ -z "$skip_tests" ]; then
42-
scalpel_flags="-Dscalpel.mode=skip-tests -Dscalpel.skipTestsForUpstream=true -Dscalpel.fetchBaseBranch=true -Dscalpel.fullBuildTriggers= -Dscalpel.reportFile=target/scalpel-report.json -Dscalpel.impactedLog=target/scalpel-impacted.txt"
42+
scalpel_flags="-Dscalpel.mode=skip-tests -Dscalpel.skipTestsForUpstream=true -Dscalpel.fetchBaseBranch=false -Dscalpel.fullBuildTriggers= -Dscalpel.reportFile=target/scalpel-report.json -Dscalpel.impactedLog=target/scalpel-impacted.txt"
4343
fi
4444

4545
extra_flags=""

0 commit comments

Comments
 (0)