Skip to content

Commit c31045e

Browse files
committed
build: warn on new duplicated code since the pull request base
Require fensu 0.29.0 and run `fensu dupes --since <base> --fail-on-new` from check-ci. A new cluster prints a warning and does not fail the build until it becomes a gate. CI fetches the pull request base so the shallow checkout can diff against it.
1 parent 54d0dd8 commit c31045e

4 files changed

Lines changed: 41 additions & 18 deletions

File tree

‎.github/workflows/verify.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,15 @@ jobs:
279279
run: uv python install 3.12
280280
- name: Install dependencies
281281
run: uv sync --locked --all-groups --all-extras
282+
- name: Fetch pull request base for the new-duplicate check
283+
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
284+
run: git fetch --no-tags --depth=1 origin "$BASE_SHA"
285+
env:
286+
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
282287
- name: Run static checks
283288
run: make check-ci
289+
env:
290+
DUPES_BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || 'origin/main' }}
284291
- name: Run native checks
285292
run: make rust-check
286293
- name: Run unit and integration tests

‎Makefile‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL := /bin/bash
22

3-
.PHONY: verify verify-quick verify-pg coverage cli-preview rust-check check-native-layering check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill \
3+
.PHONY: verify verify-quick verify-pg coverage cli-preview rust-check check-native-layering check-dupes-new check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill \
44
check-e2e-shards test-e2e-duckdb test-e2e-duckdb-build-core \
55
test-e2e-duckdb-build-incremental \
66
test-e2e-duckdb-cli-data test-e2e-duckdb-cli test-e2e-duckdb-inspection \
@@ -562,6 +562,22 @@ dupes:
562562
uv run fensu dupes
563563

564564

565+
# Warn mode: report new duplicated code since DUPES_BASE without failing the build.
566+
DUPES_BASE ?= origin/main
567+
568+
check-dupes-new:
569+
@if ! git rev-parse --verify --quiet "$(DUPES_BASE)^{commit}" >/dev/null; then \
570+
echo "warning: skipped new-duplicate check: base $(DUPES_BASE) is not available"; \
571+
exit 0; \
572+
fi; \
573+
uv run fensu dupes --since "$(DUPES_BASE)" --fail-on-new; rc=$$?; \
574+
if [ $$rc -eq 1 ]; then \
575+
echo "warning: new duplicated code above (warn mode: this check does not fail yet)"; \
576+
elif [ $$rc -ne 0 ]; then \
577+
exit $$rc; \
578+
fi
579+
580+
565581
check:
566582
uv run ruff format .
567583
uv run ruff check --fix .
@@ -671,7 +687,7 @@ verify-quick:
671687
exit $$status
672688

673689

674-
check-ci: check-e2e-shards check-native-layering check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill rust-lint
690+
check-ci: check-dupes-new check-e2e-shards check-native-layering check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill rust-lint
675691
uv run ruff format --check .
676692
uv run ruff check .
677693
uv run ty check src tests

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dev = [
8181
"pytest-cov>=7.0.0",
8282
"pytest-xdist>=3.8.0",
8383
"ruff>=0.12.0",
84-
"fensu>=0.28.3",
84+
"fensu>=0.29.0",
8585
"testcontainers>=4.8.1",
8686
"ty>=0.0.1a19",
8787
]

‎uv.lock‎

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)