Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(ci): restore merge base for three-dot diffs broken by shallow clones (#3865)

sangwook5cc03eaebff2
diff --git a/.github/scripts/analyze-pr.js b/.github/scripts/analyze-pr.js
index 3e8b02fc45..2c374cb853 100644
--- a/.github/scripts/analyze-pr.js
+++ b/.github/scripts/analyze-pr.js
@@ -5,7 +5,7 @@
/**
* @description Analyzes PR changes to detect new/modified components and gather stats
* @input --base <branch> --head <ref> --output <file>
- * @output JSON file with component analysis
+ * @output JSON file with component analysis; exits non-zero if the base...head diff fails (e.g. shallow clone without a merge base)
*/
const fs = require('node:fs');
@@ -46,8 +46,12 @@ function getChangedFiles() {
);
return output.trim().split('\n').filter(Boolean);
} catch (e) {
- console.error('Error getting changed files:', e.message);
- return [];
+ // A failed diff (e.g. no merge base on a too-shallow clone) is not the
+ // same as "no changes" — fail loudly instead of publishing an empty
+ // analysis report that looks legitimate.
+ console.error(`::error::git diff ${baseBranch}...${headRef} failed: ${e.message}`);
+ console.error('The clone is likely too shallow to contain the merge base (see fetch-depth in ci.yml).');
+ process.exit(1);
}
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6774329653..5b362cf9b0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -83,13 +83,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
+ with:
+ # Depth 50 (same as check-scope) so the three-dot diff below can find
+ # a merge base. With the default depth of 1 the diff fails with
+ # "no merge base", the error is swallowed by the pipeline, and
+ # has_components silently becomes false — skipping pr-a11y entirely.
+ fetch-depth: 50
- name: Fetch base branch
- run: git fetch origin ${{ github.base_ref }} --depth=1
+ run: git fetch origin ${{ github.base_ref }} --depth=50
- name: Check for component changes
id: check
run: |
+ if ! git merge-base HEAD origin/${{ github.base_ref }} >/dev/null 2>&1; then
+ echo "::warning::No merge base between HEAD and origin/${{ github.base_ref }} (clone too shallow) — assuming components changed so pr-a11y still runs"
+ echo "has_components=true" >> $GITHUB_OUTPUT
+ exit 0
+ fi
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- packages/core/src/ | grep -v -E '(hooks|theme|utils)/' | head -1)
echo "has_components=$( [ -n "$CHANGED" ] && echo true || echo false )" >> $GITHUB_OUTPUT
@@ -149,10 +160,15 @@ jobs:
- name: Checkout
if: needs.check-scope.outputs.docsite_only != 'true'
uses: actions/checkout@v7
+ with:
+ # Depth 50 (same as check-scope) so analyze-pr.js's three-dot diff
+ # can find a merge base — depth 1 breaks it ("no merge base") and
+ # the analysis silently reported zero changed components.
+ fetch-depth: 50
- name: Fetch base branch for PR analysis
if: needs.check-scope.outputs.docsite_only != 'true' && github.event_name == 'pull_request'
- run: git fetch origin ${{ github.base_ref }} --depth=1
+ run: git fetch origin ${{ github.base_ref }} --depth=50
- name: Setup Node and pnpm
if: needs.check-scope.outputs.docsite_only != 'true'