Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

feat(app): Move App and Bump to go 1.20 #256

Merged
merged 8 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ version: 2.1
executors:
standard:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20.1
environment:
FOUNDRY_COMMIT: e2fa2b5f8940d283f54df1ec701967276a934e97
resource_class: xlarge
Expand Down
111 changes: 111 additions & 0 deletions build/go.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# SPDX-License-Identifier: BUSL-1.1
#
# Copyright (C) 2023, Berachain Foundation. All rights reserved.
# Use of this software is govered by the Business Source License included
# in the LICENSE file of this repository and at www.mariadb.com/bsl11.
#
# ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY
# TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER
# VERSIONS OF THE LICENSED WORK.
#
# THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF
# LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF
# LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE).
#
# TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
# AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
# EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
# TITLE.

class Go < Formula
desc "Open source programming language to build simple/reliable/efficient software"
homepage "https://go.dev/"
url "https://go.dev/dl/go1.20.1.src.tar.gz"
mirror "https://fossies.org/linux/misc/go1.20.1.src.tar.gz"
sha256 "b5c1a3af52c385a6d1c76aed5361cf26459023980d0320de7658bae3915831a2"
license "BSD-3-Clause"
head "https://go.googlesource.com/go.git", branch: "master"

livecheck do
url "https://go.dev/dl/"
regex(/href=.*?go[._-]?v?(\d+(?:\.\d+)+)[._-]src\.t/i)
end

# bottle do
# sha256 arm64_ventura: "9e45e8c058b38e85608717871c18e8a4236f7e8895938388081fc3b873e7da35"
# sha256 arm64_monterey: "e97b3a6221357290a48fba6bd88c39ccce5d0d48927a657a810f4932465ab62a"
# sha256 arm64_big_sur: "38d5820da5d75b9956e85edf5e85a386e3f39b585389ae5fcb118827b045dea6"
# sha256 ventura: "8249f690a7898697a6c6c0a5bb21cd5b80739b65553c94ac0bb62348989aa3e9"
# sha256 monterey: "06020b3d11c2be4fc8318561203e7435c484773475b836496303cb1c6225ae0a"
# sha256 big_sur: "1863c55cd86258e10ac6b7e3a3e3da12074d7783f81e864f3b43c5c288f59d8f"
# sha256 x86_64_linux: "4060878a09c55ce7bd3b1093829a5e01622be31816c368f8fcaf07e38bca1fb9"
# end

# Don't update this unless this version cannot bootstrap the new version.
resource "gobootstrap" do
checksums = {
"darwin-arm64" => "e4ccc9c082d91eaa0b866078b591fc97d24b91495f12deb3dd2d8eda4e55a6ea",
"darwin-amd64" => "c101beaa232e0f448fab692dc036cd6b4677091ff89c4889cc8754b1b29c6608",
"linux-arm64" => "914daad3f011cc2014dea799bb7490442677e4ad6de0b2ac3ded6cee7e3f493d",
"linux-amd64" => "4cdd2bc664724dc7db94ad51b503512c5ae7220951cac568120f64f8e94399fc",
}

arch = "arm64"
platform = "darwin"

on_intel do
arch = "amd64"
end

on_linux do
platform = "linux"
end

boot_version = "1.17.13"

url "https://storage.googleapis.com/golang/go#{boot_version}.#{platform}-#{arch}.tar.gz"
version boot_version
sha256 checksums["#{platform}-#{arch}"]
end

def install
(buildpath/"gobootstrap").install resource("gobootstrap")
ENV["GOROOT_BOOTSTRAP"] = buildpath/"gobootstrap"

cd "src" do
ENV["GOROOT_FINAL"] = libexec
system "./make.bash"
end

rm_rf "gobootstrap" # Bootstrap not required beyond compile.
libexec.install Dir["*"]
bin.install_symlink Dir[libexec/"bin/go*"]

system bin/"go", "install", "-race", "std"

# Remove useless files.
# Breaks patchelf because folder contains weird debug/test files
(libexec/"src/debug/elf/testdata").rmtree
# Binaries built for an incompatible architecture
(libexec/"src/runtime/pprof/testdata").rmtree
end

test do
(testpath/"hello.go").write <<~EOS
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
EOS
# Run go fmt check for no errors then run the program.
# This is a a bare minimum of go working as it uses fmt, build, and run.
system bin/"go", "fmt", "hello.go"
assert_equal "Hello World\n", shell_output("#{bin}/go run hello.go")

ENV["GOOS"] = "freebsd"
ENV["GOARCH"] = "amd64"
system bin/"go", "build", "hello.go"
end
end
26 changes: 15 additions & 11 deletions build/mage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
moq = "github.com/matryer/moq"

// Variables and Helpers.
cmds = []string{"jsonrpcd", "stargazerd"}
cmds = []string{"stargazerd"}
production = false
statically = false
)
Expand All @@ -65,6 +65,17 @@ func All() error {
return nil
}

func BuildStargazerApp() error {
cmd := "stargazerd"
args := []string{
generateBuildTags(),
generateLinkerFlags(production, statically),
"-o", generateOutDirectory(cmd),
"./testutil/app/cmd/" + cmd,
}
return goBuild(args...)
}

// Runs `go build` on the entire project.
func Build() error {
PrintMageName()
Expand All @@ -81,17 +92,10 @@ func Build() error {
return err
}

for _, cmd := range cmds {
args := []string{
generateBuildTags(),
generateLinkerFlags(production, statically),
"-o", generateOutDirectory(cmd),
generateCmdToBuild(cmd),
}
if err = goBuild(args...); err != nil {
return err
}
if err = BuildStargazerApp(); err != nil {
return err
}

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions build/mage/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ var (
jsonrpcDockerPath = "./jsonrpc/Dockerfile"
imageName = "berachain-node"
testImageVersion = "e2e-test-dev"
goVersion = "1.19.5"
goVersion = "1.20.1"
debianStaticImage = "gcr.io/distroless/static-debian11"
golangAlpine = "golang:1.19-alpine3.17"
golangAlpine = "golang:1.20-alpine3.17"
precompileContractsDir = ""
)

Expand Down
39 changes: 22 additions & 17 deletions build/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package main
import (
"errors"
"fmt"
"runtime"

"github.com/carolynvs/magex/pkg"
"github.com/magefile/mage/sh"
Expand Down Expand Up @@ -57,15 +58,19 @@ func main() {
}

// Coming soon
// // Run the setup script for the current OS.
// switch os := runtime.GOOS; os {
// case "darwin":
// err = setupMac()
// case "linux":
// err = setupLinux()
// default:
// err = fmt.Errorf("ngmi unsupported OS")
// }
// Run the setup script for the current OS.
switch os := runtime.GOOS; os {
case "darwin":
err = setupMac()
case "linux":
err = setupLinux()
default:
err = fmt.Errorf("ngmi unsupported OS")
}

if err != nil {
panic(err)
}

if err = setupGoDeps(); err != nil {
panic(err)
Expand All @@ -85,12 +90,12 @@ func setupGoDeps() error {
return nil
}

// // setupMac runs the setup script for macOS.
// func setupMac() error {
// return fmt.Errorf("mac setup coming soon")
// }
// setupMac runs the setup script for macOS.
func setupMac() error {
return sh.Run("brew", "install", "--verbose", "./build/go.rb")
}

// // setupLinux runs the setup script for Linux.
// func setupLinux() error {
// return fmt.Errorf("linux setup coming soon")
// }
// setupLinux runs the setup script for Linux.
func setupLinux() error {
return fmt.Errorf("linux setup coming soon")
}
48 changes: 0 additions & 48 deletions cmd/jsonrpcd/main.go

This file was deleted.

7 changes: 4 additions & 3 deletions eth/core/mock/host.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading