Skip to content

build: resolve Bazel Go deps through GOPROXY#69503

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
dillon-zheng:codex/use-goproxy-for-bazel-go-deps
Jun 29, 2026
Merged

build: resolve Bazel Go deps through GOPROXY#69503
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
dillon-zheng:codex/use-goproxy-for-bazel-go-deps

Conversation

@dillon-zheng

@dillon-zheng dillon-zheng commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Issue Number: close #69513

Summary

  • change cmd/mirror to generate go_repository entries with sum and version instead of mirrored urls, sha256, and strip_prefix
  • remove the pingcapmirror Go module upload path and deprecated bazel_mirror_upload
  • regenerate DEPS.bzl so Bazel Go dependencies are resolved by rules_go through the configured Go module environment, e.g. GOPROXY=...|...,direct

Test Plan

  • make tidy
  • go test ./cmd/mirror
  • PATH=/tmp/tidb-bazel-shim:$PATH make bazel_prepare
  • PATH=/tmp/tidb-bazel-shim:$PATH make bazel_mirror_upload
  • PATH=/tmp/tidb-bazel-shim:$PATH make lint
  • git -c core.whitespace=-tab-in-indent diff --check
  • verified DEPS.bzl has no pingcapmirror, cache.hawkingrei.com, urls, sha256, or strip_prefix entries for Go modules

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Release note

None

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jun 28, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

Hi @dillon-zheng. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot

ti-chi-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

Welcome @dillon-zheng!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@ti-chi-bot ti-chi-bot Bot added the first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. label Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Removes GCS-backed mirror upload functionality from cmd/mirror, deletes skylarkutil.go, updates dumpNewDepsBzl to emit module data from downloaded metadata, and changes Makefile mirror targets to redirect output directly while deprecating bazel_mirror_upload.

Changes

Mirror upload removal and GOPROXY migration

Layer / File(s) Summary
Deprecate Makefile target and CLI flags
Makefile, cmd/mirror/mirror.go
bazel_ci_prepare, bazel_prepare, and bazel_mirror now redirect mirror command output into tmp.txt; bazel_mirror_upload prints a deprecation message; --mirror and --upload are marked deprecated and ignored.
Remove upload support and skylark helpers
cmd/mirror/BUILD.bazel, cmd/mirror/mirror.go, cmd/mirror/skylarkutil.go, go.mod
uploadFile and getExistingMirrors are removed; imports are trimmed; mirror_lib now compiles only mirror.go; skylarkutil.go is deleted; the Skylark module dependency is removed.
Rewrite deps.bzl generation
cmd/mirror/mirror.go
dumpNewDepsBzl drops existingMirrors, stops generating mirror URL/SHA fields, and emits sum, version, and optional replace from downloaded module metadata; mirror() and main() are updated for the new flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pingcap/tidb#69320: Directly touches the same cmd/mirror/mirror.go module-generation path, including dumpNewDepsBzl behavior around module source selection.

Suggested reviewers

  • hawkingrei
  • tangenta

Poem

🐇 The GCS jars hop away,
GOPROXY lights the path today.
I nibbled flags down to a sigh,
And mirror echoes wave goodbye.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: resolving Bazel Go deps through GOPROXY.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description covers the required issue, summary, tests, and release note, with only minor template sections omitted.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dillon-zheng dillon-zheng changed the title build: resolve Bazel Go deps through GOPROXY CI: resolve Bazel Go deps through GOPROXY Jun 28, 2026
@dillon-zheng

Copy link
Copy Markdown
Contributor Author

/ok-to-test

@ti-chi-bot

ti-chi-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

@dillon-zheng: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/mirror/mirror.go`:
- Around line 282-291: Handle local-path replaces in dumpNewDepsBzl: the current
lookup of downloaded[replaced.Path] assumes every replacement was downloaded,
but local-path replaces like ./pkg/parser are skipped by downloadZips and will
not exist in that map. Update dumpNewDepsBzl (around the replaced.Path /
downloaded lookup logic) to either skip local-path replacements explicitly or
branch to handle them without requiring a downloaded entry, while keeping the
existing behavior for remote modules.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bfbec787-2b7f-4bbc-a454-62ba5543a2a1

📥 Commits

Reviewing files that changed from the base of the PR and between 13282a8 and 70ce59f.

📒 Files selected for processing (5)
  • DEPS.bzl
  • Makefile
  • cmd/mirror/BUILD.bazel
  • cmd/mirror/mirror.go
  • cmd/mirror/skylarkutil.go
💤 Files with no reviewable changes (1)
  • cmd/mirror/skylarkutil.go

Comment thread cmd/mirror/mirror.go
Comment on lines +282 to +291
d, ok := downloaded[replaced.Path]
if !ok {
return fmt.Errorf("could not find downloaded module for %s@%s", replaced.Path, replaced.Version)
}
if mod.Replace != nil {
fmt.Printf(" replace = \"%s\",\n", replaced.Path)
}
fmt.Printf(` sum = "%s",
version = "%s",
`, d.Sum, d.Version)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find any replace directives, highlighting local-path (no version) replaces
rg -n '=>' go.mod pkg/parser/go.mod || echo "no replace directives found"

Repository: pingcap/tidb

Length of output: 680


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the generator logic around downloadZips and dumpNewDepsBzl.
ast-grep outline cmd/mirror/mirror.go --view expanded

printf '\n--- relevant slices ---\n'
sed -n '90,160p' cmd/mirror/mirror.go
printf '\n---\n'
sed -n '250,320p' cmd/mirror/mirror.go

printf '\n--- replace handling in go.mod / parser go.mod context ---\n'
rg -n '^\s*replace\s+|=>\s+\.{1,2}/|=>\s+\./' go.mod pkg/parser/go.mod

Repository: pingcap/tidb

Length of output: 5229


Handle local-path replaces in dumpNewDepsBzl
go.mod already has github.com/pingcap/tidb/pkg/parser => ./pkg/parser, and downloadZips skips local-path replaces while dumpNewDepsBzl still looks up downloaded[replaced.Path]. That makes make bazel_mirror fail on the current tree unless local replaces are skipped or handled explicitly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/mirror/mirror.go` around lines 282 - 291, Handle local-path replaces in
dumpNewDepsBzl: the current lookup of downloaded[replaced.Path] assumes every
replacement was downloaded, but local-path replaces like ./pkg/parser are
skipped by downloadZips and will not exist in that map. Update dumpNewDepsBzl
(around the replaced.Path / downloaded lookup logic) to either skip local-path
replacements explicitly or branch to handle them without requiring a downloaded
entry, while keeping the existing behavior for remote modules.

@dillon-zheng dillon-zheng force-pushed the codex/use-goproxy-for-bazel-go-deps branch from 70ce59f to c7f2d4d Compare June 28, 2026 06:09
@dillon-zheng dillon-zheng changed the title CI: resolve Bazel Go deps through GOPROXY build: resolve Bazel Go deps through GOPROXY Jun 28, 2026
@dillon-zheng

Copy link
Copy Markdown
Contributor Author

Addressed the follow-up review points:

  • Removed the no-op --mirror argument from the Makefile call sites (bazel_ci_prepare, bazel_prepare, and bazel_mirror).
  • Kept the --mirror flag for compatibility with external/manual invocations, but it now prints a deprecation warning to stderr, matching --upload.
  • Verified the current workspace uses rules_go v0.60.0 and the generated go_repository(sum + version) flow works with make bazel_prepare and make bazel_mirror.
  • Verified the old --mirror invocation remains compatible and emits the warning.

Additional validation after the update:

  • go test ./cmd/mirror
  • PATH=/tmp/tidb-bazel-shim:$PATH make bazel_mirror
  • PATH=/tmp/tidb-bazel-shim:$PATH bazel run --remote_cache=https://cache.hawkingrei.com/bazelcache --noremote_upload_local_results --norun_validations //cmd/mirror:mirror -- --mirror > /tmp/tidb-mirror-compat.out
  • PATH=/tmp/tidb-bazel-shim:$PATH make lint
  • git -c core.whitespace=-tab-in-indent diff --check

@wuhuizuo

Copy link
Copy Markdown
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jun 29, 2026
@wuhuizuo

Copy link
Copy Markdown
Contributor

/retest

@dillon-zheng dillon-zheng force-pushed the codex/use-goproxy-for-bazel-go-deps branch from c7f2d4d to 3f295a6 Compare June 29, 2026 06:19
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.4734%. Comparing base (aa35069) to head (3f295a6).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #69503        +/-   ##
================================================
- Coverage   76.3257%   74.4734%   -1.8524%     
================================================
  Files          2041       2044         +3     
  Lines        561045     574288     +13243     
================================================
- Hits         428222     427692       -530     
- Misses       131922     146352     +14430     
+ Partials        901        244       -657     
Flag Coverage Δ
integration 40.9783% <ø> (+1.3502%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 60.4471% <ø> (ø)
parser ∅ <ø> (∅)
br 47.6078% <ø> (-15.1433%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dillon-zheng

Copy link
Copy Markdown
Contributor Author

/skip-issue-check

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-tests-checked do-not-merge/needs-linked-issue do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 29, 2026
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 29, 2026
@dillon-zheng

Copy link
Copy Markdown
Contributor Author

/cc cfzjywxk

@ti-chi-bot ti-chi-bot Bot requested a review from cfzjywxk June 29, 2026 08:09
@dillon-zheng

Copy link
Copy Markdown
Contributor Author

/assign cfzjywxk

@dillon-zheng

Copy link
Copy Markdown
Contributor Author

/cc D3Hunter

@ti-chi-bot ti-chi-bot Bot requested a review from D3Hunter June 29, 2026 08:09
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 29, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-29 08:00:03.954249276 +0000 UTC m=+26345.654628690: ☑️ agreed by YangKeao.
  • 2026-06-29 08:15:19.222748247 +0000 UTC m=+27260.923127670: ☑️ agreed by JmPotato.

@ti-chi-bot

ti-chi-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, D3Hunter, JmPotato, YangKeao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [D3Hunter,JmPotato,YangKeao,cfzjywxk]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Jun 29, 2026
@hawkingrei

Copy link
Copy Markdown
Contributor

/hold

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 29, 2026
@hawkingrei

Copy link
Copy Markdown
Contributor

Please do not remove sha256, because once it is removed, stable network downloads via goproxy cannot be guaranteed. It will also cause repeated downloads and prevent cache. Therefore, this PR must absolutely not be merged.

@dillon-zheng

Copy link
Copy Markdown
Contributor Author

Thanks for pointing this out. I agree that removing urls + sha256 changes the caching layer: these Go deps will no longer use Bazel's HTTP archive repository cache keyed by sha256.

But this does not remove integrity verification. The generated go_repository entries still contain sum = "h1:...", and rules_go module mode verifies the downloaded module with that sum when resolving version + sum.

The intent of this PR is to migrate Go module dependencies from the manually maintained pingcapmirror/static archive cache to the standard Go module resolution path. In CI, GOPROXY is configured to use our Artifact Registry remote Go proxy first, then fallback, so caching should be handled by the Go proxy remote cache instead of requiring manual uploads to pingcapmirror.

So I think the real tradeoff is:

  • old path: Bazel archive cache + static mirror + manual upload
  • new path: rules_go module mode + sum verification + CI-controlled GOPROXY/Artifact Registry remote cache

@hawkingrei

Copy link
Copy Markdown
Contributor

Do whatever you want, I still stand by my point. The previous migration to the current model was due to goproxy instability.

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 29, 2026
@ti-chi-bot ti-chi-bot Bot merged commit 6c90f90 into pingcap:master Jun 29, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove Bazel Go deps on pingcapmirror

7 participants