Update renovate and pinning behavior, run tools from go.mod (#4759)
- Renovate config:recommended (config:base is deprecated) and matchPackageNames globs instead of the deprecated matchPackagePrefixes. Vulnerability alerts get a fast path: 2-day quarantine, no concurrency/hourly/schedule limits. Go modules are no longer grouped into one "go deps" PR — each gets its own, so a bad bump can be reverted alone. The pion modules stay grouped as a documented exception: they're co-released and interdependent, so individual PRs wouldn't build. First-party github.com/livekit/** skips the 2-week quarantine. go.mod's go directive is no longer an update target — the build toolchain is pinned in the Dockerfile instead. Dockerfile deps get pinDigests; the golang image is ungrouped with separateMinorPatch so a patch and a minor bump are each separately approvable. Custom manager to bump the builder image's -alpineA.B suffix together with its digest, which the stock docker manager holds fixed. - Pinning Both Dockerfiles pin golang and alpine by digest alongside the readable tag. GOTOOLCHAIN=local so a go.mod bump fails loudly instead of silently downloading a different toolchain. apk upgrade in the runtime stage — a digest pin plus the 2-week quarantine would otherwise ship base-package CVEs Alpine has already fixed. This relies on a cold layer cache, which holds today because the release workflow configures no buildx cache; there's a comment saying so. Workflows resolve the Go version from the Dockerfile via .github/scripts/go-version.sh, so tests, releases and images share one toolchain. - Tools All four code generators now come from the module graph, and tools/tools.go (the pre-Go-1.24 blank-import idiom) is replaced by go.mod tool directives: tool how why goimports go tool lives in x/tools — its own module is the one being selected gotestfmt go tool zero dependencies, nothing to skew wire go run pins x/tools v0.24.1; building it in our graph changes its output counterfeiter go run unchanged, matches its //go:generate directives The wire distinction is load-bearing. Building wire inside our module raises it from the x/tools v0.24.1 it pins to our v0.48.0, and that module version difference changes what it generates: it falls back to v/v2/v3 instead of deriving real identifiers from the type. wire_gen.go is regenerated here to match the in-module build — a cosmetic rename of 9 lines, with no other change to the generated code. golangci-lint deliberately keeps its action rather than becoming a tool: it pins its own x/tools (v0.44.0 vs our v0.48.0) for the analyzers it bundles, adding it to go.mod would double our go.mod/go.sum (158→338 / 441→889 lines), and the action supplies caching, only-new-issues and PR annotations that invoking a binary can't. Its version stays manual by request.
This commit is contained in:
+13
-38
@@ -51,9 +51,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// explicitly reinstall all deps
|
||||
// downloads module deps at the versions pinned in go.mod
|
||||
//
|
||||
// Code generators are not installed here: they run as `go run <pkg>` from their
|
||||
// //go:generate directives (see pkg/service/wire_gen.go and the counterfeiter
|
||||
// directives under pkg/), so they always execute at the version go.mod pins and
|
||||
// Renovate keeps them current alongside every other module.
|
||||
func Deps() error {
|
||||
return installTools(true)
|
||||
return mageutil.Run(context.Background(), "go mod download")
|
||||
}
|
||||
|
||||
// builds LiveKit server
|
||||
@@ -109,9 +114,6 @@ func BuildLinux() error {
|
||||
|
||||
func Deadlock() error {
|
||||
ctx := context.Background()
|
||||
if err := mageutil.InstallTool("golang.org/x/tools/cmd/goimports", "latest", false); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mageutil.Run(ctx, "go get github.com/sasha-s/go-deadlock"); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -121,7 +123,7 @@ func Deadlock() error {
|
||||
if err := mageutil.Pipe("grep -rl sync.RWMutex ./pkg", "xargs sed -i -e s/sync.RWMutex/deadlock.RWMutex/g"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mageutil.Pipe("grep -rl deadlock.Mutex\\|deadlock.RWMutex ./pkg", "xargs goimports -w"); err != nil {
|
||||
if err := mageutil.Pipe("grep -rl deadlock.Mutex\\|deadlock.RWMutex ./pkg", "xargs go tool goimports -w"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mageutil.Run(ctx, "go mod tidy"); err != nil {
|
||||
@@ -137,7 +139,7 @@ func Sync() error {
|
||||
if err := mageutil.Pipe("grep -rl deadlock.RWMutex ./pkg", "xargs sed -i -e s/deadlock.RWMutex/sync.RWMutex/g"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mageutil.Pipe("grep -rl sync.Mutex\\|sync.RWMutex ./pkg", "xargs goimports -w"); err != nil {
|
||||
if err := mageutil.Pipe("grep -rl sync.Mutex\\|sync.RWMutex ./pkg", "xargs go tool goimports -w"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mageutil.Run(context.Background(), "go mod tidy"); err != nil {
|
||||
@@ -199,7 +201,7 @@ func Clean() {
|
||||
|
||||
// regenerate code
|
||||
func Generate() error {
|
||||
mg.Deps(installDeps, generateWire)
|
||||
mg.Deps(generateWire)
|
||||
|
||||
fmt.Println("generating...")
|
||||
return mageutil.Run(context.Background(), "go generate ./...")
|
||||
@@ -207,40 +209,13 @@ func Generate() error {
|
||||
|
||||
// code generation for wiring
|
||||
func generateWire() error {
|
||||
mg.Deps(installDeps)
|
||||
if !checksummer.IsChanged() {
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("wiring...")
|
||||
|
||||
wire, err := mageutil.GetToolPath("wire")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Command(wire)
|
||||
cmd.Dir = "pkg/service"
|
||||
mageutil.ConnectStd(cmd)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// implicitly install deps
|
||||
func installDeps() error {
|
||||
return installTools(false)
|
||||
}
|
||||
|
||||
func installTools(force bool) error {
|
||||
tools := map[string]string{
|
||||
"github.com/google/wire/cmd/wire": "latest",
|
||||
}
|
||||
for t, v := range tools {
|
||||
if err := mageutil.InstallTool(t, v, force); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
// Matches the //go:generate directive in pkg/service/wire_gen.go, so running
|
||||
// wire here and running `go generate ./...` produce the same output.
|
||||
return mageutil.RunDir(context.Background(), "pkg/service", "go run github.com/google/wire/cmd/wire")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user