Skip to content

Commit 1597d58

Browse files
authored
go.work, build: remove workspace file (#32699)
https://go.dev/ref/mod#go-work-file advises against checking `go.work` files because they can interfere with local development. We added the workspace file in order to make `go test` and other tools work across multiple modules. But it seems to cause weird issues with the `go.work.sum` file being modified, etc. So with this PR, we instead run all the `ci.go` commands for all modules in the workspace manually.
1 parent aa37bd0 commit 1597d58

File tree

6 files changed

+92
-599
lines changed

6 files changed

+92
-599
lines changed

build/ci.go

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ import (
6464
)
6565

6666
var (
67+
goModules = []string{
68+
".",
69+
"./cmd/keeper",
70+
}
71+
6772
// Files that end up in the geth*.zip archive.
6873
gethArchiveFiles = []string{
6974
"COPYING",
@@ -295,6 +300,7 @@ func doTest(cmdline []string) {
295300
if *dlgo {
296301
tc.Root = build.DownloadGo(csdb)
297302
}
303+
298304
gotest := tc.Go("test")
299305

300306
// CI needs a bit more time for the statetests (default 45m).
@@ -323,11 +329,19 @@ func doTest(cmdline []string) {
323329
}
324330

325331
packages := flag.CommandLine.Args()
326-
if len(packages) == 0 {
327-
packages = workspacePackagePatterns()
332+
if len(packages) > 0 {
333+
gotest.Args = append(gotest.Args, packages...)
334+
build.MustRun(gotest)
335+
return
336+
}
337+
338+
// No packages specified, run all tests for all modules.
339+
gotest.Args = append(gotest.Args, "./...")
340+
for _, mod := range goModules {
341+
test := *gotest
342+
test.Dir = mod
343+
build.MustRun(&test)
328344
}
329-
gotest.Args = append(gotest.Args, packages...)
330-
build.MustRun(gotest)
331345
}
332346

333347
// downloadSpecTestFixtures downloads and extracts the execution-spec-tests fixtures.
@@ -351,40 +365,46 @@ func doCheckGenerate() {
351365
cachedir = flag.String("cachedir", "./build/cache", "directory for caching binaries.")
352366
tc = new(build.GoToolchain)
353367
)
354-
// Compute the origin hashes of all the files
355-
var hashes map[string][32]byte
356368

357-
var err error
358-
hashes, err = build.HashFolder(".", []string{"tests/testdata", "build/cache", ".git"})
359-
if err != nil {
360-
log.Fatal("Error computing hashes", "err", err)
361-
}
362369
// Run any go generate steps we might be missing
363370
var (
364371
protocPath = downloadProtoc(*cachedir)
365372
protocGenGoPath = downloadProtocGenGo(*cachedir)
366373
)
367-
c := tc.Go("generate", workspacePackagePatterns()...)
368374
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
369-
c.Env = append(c.Env, "PATH="+strings.Join(pathList, string(os.PathListSeparator)))
370-
build.MustRun(c)
371375

372-
// Check if generate file hashes have changed
373-
generated, err := build.HashFolder(".", []string{"tests/testdata", "build/cache", ".git"})
374-
if err != nil {
375-
log.Fatalf("Error re-computing hashes: %v", err)
376-
}
377-
updates := build.DiffHashes(hashes, generated)
378-
for _, file := range updates {
379-
log.Printf("File changed: %s", file)
380-
}
381-
if len(updates) != 0 {
382-
log.Fatal("One or more generated files were updated by running 'go generate ./...'")
376+
for _, mod := range goModules {
377+
// Compute the origin hashes of all the files
378+
hashes, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
379+
if err != nil {
380+
log.Fatal("Error computing hashes", "err", err)
381+
}
382+
383+
c := tc.Go("generate", "./...")
384+
c.Env = append(c.Env, "PATH="+strings.Join(pathList, string(os.PathListSeparator)))
385+
c.Dir = mod
386+
build.MustRun(c)
387+
// Check if generate file hashes have changed
388+
generated, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
389+
if err != nil {
390+
log.Fatalf("Error re-computing hashes: %v", err)
391+
}
392+
updates := build.DiffHashes(hashes, generated)
393+
for _, file := range updates {
394+
log.Printf("File changed: %s", file)
395+
}
396+
if len(updates) != 0 {
397+
log.Fatal("One or more generated files were updated by running 'go generate ./...'")
398+
}
383399
}
384400
fmt.Println("No stale files detected.")
385401

386402
// Run go mod tidy check.
387-
build.MustRun(tc.Go("mod", "tidy", "-diff"))
403+
for _, mod := range goModules {
404+
tidy := tc.Go("mod", "tidy", "-diff")
405+
tidy.Dir = mod
406+
build.MustRun(tidy)
407+
}
388408
fmt.Println("No untidy module files detected.")
389409
}
390410

@@ -425,20 +445,29 @@ func doLint(cmdline []string) {
425445
)
426446
flag.CommandLine.Parse(cmdline)
427447

448+
linter := downloadLinter(*cachedir)
449+
linter, err := filepath.Abs(linter)
450+
if err != nil {
451+
log.Fatal(err)
452+
}
453+
config, err := filepath.Abs(".golangci.yml")
454+
if err != nil {
455+
log.Fatal(err)
456+
}
457+
458+
lflags := []string{"run", "--config", config}
428459
packages := flag.CommandLine.Args()
429-
if len(packages) == 0 {
430-
// Get module directories in workspace.
431-
packages = []string{"./..."}
432-
modules := workspaceModules()
433-
for _, m := range modules[1:] {
434-
dir := strings.TrimPrefix(m, modules[0])
435-
packages = append(packages, "."+dir+"/...")
460+
if len(packages) > 0 {
461+
build.MustRunCommandWithOutput(linter, append(lflags, packages...)...)
462+
} else {
463+
// Run for all modules in workspace.
464+
for _, mod := range goModules {
465+
args := append(lflags, "./...")
466+
lintcmd := exec.Command(linter, args...)
467+
lintcmd.Dir = mod
468+
build.MustRunWithOutput(lintcmd)
436469
}
437470
}
438-
439-
linter := downloadLinter(*cachedir)
440-
lflags := []string{"run", "--config", ".golangci.yml"}
441-
build.MustRunCommandWithOutput(linter, append(lflags, packages...)...)
442471
fmt.Println("You have achieved perfection.")
443472
}
444473

@@ -1176,31 +1205,3 @@ func doSanityCheck() {
11761205
csdb := download.MustLoadChecksums("build/checksums.txt")
11771206
csdb.DownloadAndVerifyAll()
11781207
}
1179-
1180-
// workspaceModules lists the module paths in the current work.
1181-
func workspaceModules() []string {
1182-
listing, err := new(build.GoToolchain).Go("list", "-m").Output()
1183-
if err != nil {
1184-
log.Fatalf("go list failed:", err)
1185-
}
1186-
var modules []string
1187-
for _, m := range bytes.Split(listing, []byte("\n")) {
1188-
m = bytes.TrimSpace(m)
1189-
if len(m) > 0 {
1190-
modules = append(modules, string(m))
1191-
}
1192-
}
1193-
if len(modules) == 0 {
1194-
panic("no modules found")
1195-
}
1196-
return modules
1197-
}
1198-
1199-
func workspacePackagePatterns() []string {
1200-
modules := workspaceModules()
1201-
patterns := make([]string, len(modules))
1202-
for i, m := range modules {
1203-
patterns[i] = m + "/..."
1204-
}
1205-
return patterns
1206-
}

cmd/keeper/go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ require (
1313
github.com/bits-and-blooms/bitset v1.20.0 // indirect
1414
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1515
github.com/consensys/gnark-crypto v0.18.0 // indirect
16-
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
16+
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
1717
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
1818
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
1919
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
2020
github.com/emicklei/dot v1.6.2 // indirect
21-
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
21+
github.com/ethereum/c-kzg-4844/v2 v2.1.3 // indirect
22+
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab // indirect
2223
github.com/ethereum/go-verkle v0.2.2 // indirect
2324
github.com/ferranbt/fastssz v0.1.4 // indirect
2425
github.com/go-ole/go-ole v1.3.0 // indirect
@@ -33,12 +34,12 @@ require (
3334
github.com/olekukonko/tablewriter v0.0.5 // indirect
3435
github.com/rivo/uniseg v0.2.0 // indirect
3536
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
36-
github.com/supranational/blst v0.3.14 // indirect
37+
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
3738
github.com/tklauser/go-sysconf v0.3.12 // indirect
3839
github.com/tklauser/numcpus v0.6.1 // indirect
3940
golang.org/x/crypto v0.36.0 // indirect
4041
golang.org/x/sync v0.12.0 // indirect
41-
golang.org/x/sys v0.31.0 // indirect
42+
golang.org/x/sys v0.36.0 // indirect
4243
gopkg.in/yaml.v2 v2.4.0 // indirect
4344
)
4445

cmd/keeper/go.sum

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAK
2727
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
2828
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
2929
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
30-
github.com/crate-crypto/go-eth-kzg v1.3.0 h1:05GrhASN9kDAidaFJOda6A4BEvgvuXbazXg/0E3OOdI=
31-
github.com/crate-crypto/go-eth-kzg v1.3.0/go.mod h1:J9/u5sWfznSObptgfa92Jq8rTswn6ahQWEuiLHOjCUI=
30+
github.com/crate-crypto/go-eth-kzg v1.4.0 h1:WzDGjHk4gFg6YzV0rJOAsTK4z3Qkz5jd4RE3DAvPFkg=
31+
github.com/crate-crypto/go-eth-kzg v1.4.0/go.mod h1:J9/u5sWfznSObptgfa92Jq8rTswn6ahQWEuiLHOjCUI=
3232
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a h1:W8mUrRp6NOVl3J+MYp5kPMoUZPp7aOYHtaua31lwRHg=
3333
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM=
3434
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -42,8 +42,10 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
4242
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
4343
github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
4444
github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
45-
github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w=
46-
github.com/ethereum/c-kzg-4844/v2 v2.1.0/go.mod h1:TC48kOKjJKPbN7C++qIgt0TJzZ70QznYR7Ob+WXl57E=
45+
github.com/ethereum/c-kzg-4844/v2 v2.1.3 h1:DQ21UU0VSsuGy8+pcMJHDS0CV1bKmJmxsJYK8l3MiLU=
46+
github.com/ethereum/c-kzg-4844/v2 v2.1.3/go.mod h1:fyNcYI/yAuLWJxf4uzVtS8VDKeoAaRM8G/+ADz/pRdA=
47+
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab h1:rvv6MJhy07IMfEKuARQ9TKojGqLVNxQajaXEp/BoqSk=
48+
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab/go.mod h1:IuLm4IsPipXKF7CW5Lzf68PIbZ5yl7FFd74l/E0o9A8=
4749
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
4850
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
4951
github.com/ferranbt/fastssz v0.1.4 h1:OCDB+dYDEQDvAgtAGnTSidK1Pe2tW3nFV40XyMkTeDY=
@@ -114,8 +116,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
114116
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
115117
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
116118
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
117-
github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo=
118-
github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
119+
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe h1:nbdqkIGOGfUAD54q1s2YBcBz/WcsxCO9HUQ4aGV5hUw=
120+
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
119121
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
120122
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
121123
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
@@ -133,8 +135,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
133135
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
134136
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
135137
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
136-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
137-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
138+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
139+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
138140
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
139141
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
140142
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=

go.work

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)