From 11de413cab72051111cf34da96d123bce561177e Mon Sep 17 00:00:00 2001 From: Auto-revert Test Date: Fri, 21 Aug 2026 18:36:01 +0530 Subject: [PATCH 1/2] ci: shallow-fetch release-branch-validate checkouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each of the three jobs (Java, Python, UI) used fetch-depth: 0, which does a full clone (~500MB, ~16k files, 30-60s wall-clock) just to compute a two-commit diff. Drop to fetch-depth: 2 — enough for the common single-commit cherry-pick case where BEFORE == HEAD~1 — and fetch BEFORE on demand only when a multi-commit push means it's older than the shallow depth carries. Checkout drops to ~2-5s per job. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/release-branch-validate.yml | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-branch-validate.yml b/.github/workflows/release-branch-validate.yml index 2176bb51ff7a..5ed2b6d91377 100644 --- a/.github/workflows/release-branch-validate.yml +++ b/.github/workflows/release-branch-validate.yml @@ -46,10 +46,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: - - name: Checkout with history + - name: Checkout with parent uses: actions/checkout@v7 with: - fetch-depth: 0 + # Shallow: just HEAD and HEAD~1. Multi-commit pushes fetch the + # older base on demand in the "Determine changed X files" step. + fetch-depth: 2 persist-credentials: false - name: Determine changed Java files @@ -61,6 +63,9 @@ jobs: if [ -z "${BEFORE}" ] || [ "${BEFORE}" = "0000000000000000000000000000000000000000" ]; then BASE=$(git rev-parse HEAD~1) else + # Multi-commit push: BEFORE may be older than the shallow depth 2 + # checkout carries, so pull just that one object on demand. + git cat-file -e "${BEFORE}" 2>/dev/null || git fetch --depth=1 origin "${BEFORE}" BASE="${BEFORE}" fi CHANGED=$(git diff --name-only --diff-filter=ACMR "${BASE}" HEAD -- '*.java' | tr '\n' ' ') @@ -115,10 +120,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Checkout with history + - name: Checkout with parent uses: actions/checkout@v7 with: - fetch-depth: 0 + # Shallow: just HEAD and HEAD~1. Multi-commit pushes fetch the + # older base on demand in the "Determine changed X files" step. + fetch-depth: 2 persist-credentials: false - name: Determine changed Python files @@ -130,6 +137,9 @@ jobs: if [ -z "${BEFORE}" ] || [ "${BEFORE}" = "0000000000000000000000000000000000000000" ]; then BASE=$(git rev-parse HEAD~1) else + # Multi-commit push: BEFORE may be older than the shallow depth 2 + # checkout carries, so pull just that one object on demand. + git cat-file -e "${BEFORE}" 2>/dev/null || git fetch --depth=1 origin "${BEFORE}" BASE="${BEFORE}" fi # Scope to the two dirs ingestion/Makefile:py_format_check targets. @@ -176,10 +186,12 @@ jobs: env: UI_WORKING_DIRECTORY: openmetadata-ui/src/main/resources/ui steps: - - name: Checkout with history + - name: Checkout with parent uses: actions/checkout@v7 with: - fetch-depth: 0 + # Shallow: just HEAD and HEAD~1. Multi-commit pushes fetch the + # older base on demand in the "Determine changed X files" step. + fetch-depth: 2 persist-credentials: false - name: Determine changed UI files @@ -191,6 +203,9 @@ jobs: if [ -z "${BEFORE}" ] || [ "${BEFORE}" = "0000000000000000000000000000000000000000" ]; then BASE=$(git rev-parse HEAD~1) else + # Multi-commit push: BEFORE may be older than the shallow depth 2 + # checkout carries, so pull just that one object on demand. + git cat-file -e "${BEFORE}" 2>/dev/null || git fetch --depth=1 origin "${BEFORE}" BASE="${BEFORE}" fi # Match existing ui-checkstyle: src globs only, exclude generated/**. From 4e659681e8d406edc2b72b97c207aa0eaf83e693 Mon Sep 17 00:00:00 2001 From: Auto-revert Test Date: Fri, 21 Aug 2026 19:17:05 +0530 Subject: [PATCH 2/2] ci: scope spotless to changed Java files via -DspotlessFiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the Java Checkstyle job ran `mvn -B spotless:apply` across the whole reactor (~16k Java files, ~10-15 min wall-clock on a cold Maven cache) and then diffed the changed files to see if spotless had touched them. On slow runners this hit the 20-min job timeout, which produces conclusion=cancelled instead of conclusion=failure — so auto-revert-release.yml silently skips instead of reverting. spotless-maven-plugin 2.41.1 accepts `-DspotlessFiles=` matched against absolute paths. Build one anchored `.*` regex per changed file, with regex metacharacters escaped, and run `spotless:check` against just those. Fails fast on formatting drift, no in-place edits, no post-run git diff dance. Drops the step from minutes to seconds and eliminates the timeout-masks-failure hazard. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/release-branch-validate.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release-branch-validate.yml b/.github/workflows/release-branch-validate.yml index 5ed2b6d91377..822c0b5c0f41 100644 --- a/.github/workflows/release-branch-validate.yml +++ b/.github/workflows/release-branch-validate.yml @@ -95,25 +95,25 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - - name: Run spotless (full tree apply) - if: steps.files.outputs.any == 'true' - run: mvn -B spotless:apply - - - name: Fail only if changed Java files diverged + - name: Run spotless:check on changed Java files only if: steps.files.outputs.any == 'true' env: CHANGED: ${{ steps.files.outputs.changed }} run: | set -euo pipefail - # Guard against baseline drift: only assert on files the push touched. - # xargs is used so an empty CHANGED simply exits 0 rather than diffing all. - if [ -z "${CHANGED}" ]; then exit 0; fi - if [ -n "$(echo ${CHANGED} | xargs git status --porcelain --)" ]; then - echo "spotless:apply rewrote files pushed by this commit:" - echo ${CHANGED} | xargs git status --porcelain -- - echo ${CHANGED} | xargs git --no-pager diff -- - exit 1 - fi + # spotless-maven-plugin accepts a comma-separated list of regexes + # matched against absolute file paths. Build one regex per file with + # `.` escaped and a `.*` prefix so it survives Maven's absolutization. + PATTERNS="" + for f in ${CHANGED}; do + # Escape regex metacharacters we might see in filenames. + ESCAPED=$(printf '%s' "$f" | sed 's/[][().^$+*?|\\]/\\&/g') + PATTERNS="${PATTERNS}${PATTERNS:+,}.*${ESCAPED}" + done + echo "spotless:check regex: ${PATTERNS}" + # Baseline drift on other files is intentionally ignored; scope + # matches the "Determine changed X files" step above. + mvn -B spotless:check "-DspotlessFiles=${PATTERNS}" python-checkstyle: name: Python Checkstyle