Skip to content

fix(cicd): fetch origin/main for Nx affected in Frontend Unit Tests - #37231

Merged
wezell merged 1 commit into
mainfrom
fix-frontend-unit-tests-shallow-checkout
Aug 26, 2026
Merged

fix(cicd): fetch origin/main for Nx affected in Frontend Unit Tests#37231
wezell merged 1 commit into
mainfrom
fix-frontend-unit-tests-shallow-checkout

Conversation

@wezell

@wezell wezell commented Aug 26, 2026

Copy link
Copy Markdown
Member

Problem

Merge Group Test / Frontend Unit Tests fails on every merge-group run:

fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree.

nx affected (lint-test, -Pvalidate) diffs against origin/main
(core-web/pom.xml git.origin.branch), but the shallow fetch-depth: 1
checkout landed for #37178 leaves no origin/main ref, so Maven's
exec:exec@lint-test exits 1. That fails the job, which cancels every
other job in the merge group and blocks the queue.

Run: https://github.com/dotCMS/core/actions/runs/32915658690/job/98021660180

Fix

Fetch just origin/main, shallow, before the lint-test step — only for
the suite that actually runs nx affected (-Pvalidate).

Fixes #37178

Test plan

  • Merge-group run shows Frontend Unit Tests passing with origin/main present

Merge Group Test / Frontend Unit Tests runs nx affected lint-test
(-Pvalidate), which diffs against origin/main (core-web/pom.xml
git.origin.branch). The shallow fetch-depth:1 checkout added for
#37178 has no origin/main ref, so the job fails:

  fatal: ambiguous argument 'origin/main': unknown revision

which cancels every other job in the merge group. Fetch just that
ref, shallow, before the lint-test step runs.

Refs #37178
@wezell
wezell requested a review from a team as a code owner August 26, 2026 02:35
@github-actions github-actions Bot added the Area : CI/CD PR changes GitHub Actions/workflows label Aug 26, 2026
@claude

claude Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @wezell's task in 1m 21s —— View job


Code Review: fetch origin/main for Nx affected

Task list

  • Read the diff and surrounding workflow context
  • Verify the root cause (nx affected base ref) against core-web/pom.xml
  • Check the fix for correctness, edge cases, and scope
  • Post review

The fix is correct and well-scoped. I traced the root cause through core-web/pom.xml:

  • git.origin.branch = origin/main (line 26), used as --base by the lint-test (lint, format:check) and unit-test (test) nx affected executions (lines 162, 184, 230), all gated by -Pvalidate.
  • The fetch-depth: 1 checkout (line 259) leaves no origin/main ref, so --base=origin/main fails with the ambiguous argument error from the PR description.

The added step (lines 261–266) resolves this correctly:

  • git fetch --depth=1 origin main:refs/remotes/origin/main populates exactly the ref Nx resolves (origin/mainrefs/remotes/origin/main), shallow, so no return to the ~1.1 GB fetch-depth: 0 cost.
  • The if: contains(matrix.maven_args, '-Pvalidate') guard scopes it to the only suite that runs nx affected, leaving the other matrix jobs untouched.
  • Placed before the Run step, so the ref exists when Maven invokes Nx.

New Issues

No blocking issues.

Notes (non-blocking)

  • 🟡 Medium: .github/workflows/cicd_comp_test-phase.yml:266 — With both HEAD and origin/main fetched at --depth=1, the two histories share no common ancestor locally, so git merge-base fails inside Nx. Nx falls back to a two-dot git diff <base> <head>, which fails safe: it still catches every file the PR touched (no under-reporting / no silently-skipped suites), and in a merge-group HEAD already contains main so the file set matches what a full-history diff would produce. Worst case is over-reporting affected projects (a few extra lint/test runs), never missed coverage. No change needed — flagging only so the shallow-vs-shallow diff behavior is documented. What to verify: confirm the merge-group run shows Frontend Unit Tests green (already the PR's test plan).

The change matches the existing shallow-checkout rationale in the surrounding comments and needs no modification.

· fix-frontend-unit-tests-shallow-checkout

@wezell
wezell enabled auto-merge August 26, 2026 02:40
@wezell
wezell added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit 76ebf3f Aug 26, 2026
70 of 71 checks passed
@wezell
wezell deleted the fix-frontend-unit-tests-shallow-checkout branch August 26, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : CI/CD PR changes GitHub Actions/workflows

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Release CI: fetch-depth: 0 checkouts cost ~19-20 min per job (fetch of all ~2k branches)

2 participants