From f972a30c634b6cebb75c159d4c1d9c77a485c826 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Fri, 20 Dec 2024 16:18:59 -0500 Subject: [PATCH] Added some form of support for using `go build/ci.go` tooling with Firehose branch --- build/ci.go | 14 ++++++++++---- internal/build/util.go | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build/ci.go b/build/ci.go index 754d88a86a..479a151365 100644 --- a/build/ci.go +++ b/build/ci.go @@ -59,6 +59,7 @@ import ( "github.com/cespare/cp" "github.com/ethereum/go-ethereum/crypto/signify" + "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/internal/build" "github.com/ethereum/go-ethereum/internal/version" ) @@ -679,7 +680,7 @@ func maybeSkipArchive(env build.Environment) { log.Printf("skipping archive creation because this is a PR build") os.Exit(0) } - if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") { + if env.Branch != "master" && !strings.HasPrefix(env.Branch, "firehose") && !strings.HasPrefix(env.Tag, "v1.") && !strings.Contains(env.Tag, "fh") { log.Printf("skipping archive creation because branch %q, tag %q is not on the inclusion list", env.Branch, env.Tag) os.Exit(0) } @@ -722,22 +723,27 @@ func doDockerBuildx(cmdline []string) { tags = []string{"latest"} case strings.HasPrefix(env.Tag, "v1."): tags = []string{"stable", fmt.Sprintf("release-%v", version.Family), "v" + version.Semantic} + + case strings.HasPrefix(env.Branch, "firehose"): + tags = []string{"edge-fh" + tracers.FirehoseProtocolVersion} + case strings.Contains(env.Tag, "fh"): + tags = []string{"stable-fh" + tracers.FirehoseProtocolVersion, "v" + version.Semantic + "-fh" + tracers.FirehoseProtocolVersion} } // Need to create a mult-arch builder - build.MustRunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform) + build.RunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform) for _, spec := range []struct { file string base string }{ {file: "Dockerfile", base: fmt.Sprintf("%s:", *upload)}, - {file: "Dockerfile.alltools", base: fmt.Sprintf("%s:alltools-", *upload)}, + // {file: "Dockerfile.alltools", base: fmt.Sprintf("%s:alltools-", *upload)}, } { for _, tag := range tags { // latest, stable etc gethImage := fmt.Sprintf("%s%s", spec.base, tag) build.MustRunCommand("docker", "buildx", "build", "--build-arg", "COMMIT="+env.Commit, - "--build-arg", "VERSION="+version.WithMeta, + "--build-arg", "VERSION="+version.WithMeta+"-fh"+tracers.FirehoseProtocolVersion, "--build-arg", "BUILDNUM="+env.Buildnum, "--tag", gethImage, "--platform", *platform, diff --git a/internal/build/util.go b/internal/build/util.go index aee8bf0fc8..11b0d05dad 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -36,6 +36,17 @@ import ( var DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands") +func Run(cmd *exec.Cmd) { + fmt.Println(">>>", printArgs(cmd.Args)) + if !*DryRunFlag { + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + if err := cmd.Run(); err != nil { + fmt.Println("Command error: " + err.Error()) + } + } +} + // MustRun executes the given command and exits the host process for // any error. func MustRun(cmd *exec.Cmd) { @@ -63,6 +74,10 @@ func printArgs(args []string) string { return s.String() } +func RunCommand(cmd string, args ...string) { + Run(exec.Command(cmd, args...)) +} + func MustRunCommand(cmd string, args ...string) { MustRun(exec.Command(cmd, args...)) }