From 7d1b99c972305ae8d48e20d737dc59324a574edd Mon Sep 17 00:00:00 2001 From: Ryan <80392855+RayXpub@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:21:24 +0400 Subject: [PATCH] chore: update abigen build script and go version src in ci --- .github/actions/setup-go/action.yml | 14 +------------ core/gethwrappers/abigen.go | 6 ++---- tools/bin/build_abigen | 31 +++++------------------------ 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index b1fd20ad50a..3759d390463 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -29,22 +29,10 @@ inputs: runs: using: composite steps: - - name: Get Go Version - shell: bash - id: go-version - run: | - version=$(sed -ne '/^toolchain /s/^toolchain go//p' ${{ inputs.go-version-file }}) - if [ -z "$version" ]; then - version=$(sed -ne '/^go /s/^go //p' ${{ inputs.go-version-file }}) - echo "Toolchain version not found in ${{ inputs.go-version-file }}, using go directive instead." - fi - echo "Go Version: $version" - echo "version=$version" >> "$GITHUB_OUTPUT" - - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{ steps.go-version.outputs.version }} + go-version-file: ${{ inputs.go-version-file }} cache: false check-latest: true diff --git a/core/gethwrappers/abigen.go b/core/gethwrappers/abigen.go index 9d0fa742928..bdab141b733 100644 --- a/core/gethwrappers/abigen.go +++ b/core/gethwrappers/abigen.go @@ -9,7 +9,6 @@ import ( "go/token" "os" "os/exec" - "path/filepath" "regexp" "strings" @@ -40,8 +39,7 @@ type AbigenArgs struct { // Check whether native abigen is installed, and has correct version func Abigen(a AbigenArgs) { var versionResponse bytes.Buffer - abigenExecutablePath := filepath.Join(GetProjectRoot(), "tools/bin/abigen") - abigenVersionCheck := exec.Command(abigenExecutablePath, "--version") + abigenVersionCheck := exec.Command("abigen", "--version") abigenVersionCheck.Stdout = &versionResponse if err := abigenVersionCheck.Run(); err != nil { Exit("no native abigen; you must install it (`make abigen` in the "+ @@ -64,7 +62,7 @@ func Abigen(a AbigenArgs) { if a.Bin != "-" { args = append(args, "-bin", a.Bin) } - buildCommand := exec.Command(abigenExecutablePath, args...) + buildCommand := exec.Command("abigen", args...) var buildResponse bytes.Buffer buildCommand.Stderr = &buildResponse if err := buildCommand.Run(); err != nil { diff --git a/tools/bin/build_abigen b/tools/bin/build_abigen index f0087c7d800..6984776bfe4 100755 --- a/tools/bin/build_abigen +++ b/tools/bin/build_abigen @@ -3,40 +3,19 @@ # Checks that the correct abigen is installed in this directory, and installs it # if not. -set -e +set -euo pipefail # Version of abigen to install. Must be run within chainlink project GETH_VERSION=$(go list -json -m github.com/ethereum/go-ethereum | jq -r .Version) -GETH_REPO_URL="https://github.com/ethereum/go-ethereum" - -function realpath { echo $(cd $(dirname $1); pwd)/$(basename $1); } -THIS_DIR="$(realpath "$(dirname $0)")" NATIVE_ABIGEN_VERSION=v"$( - "$THIS_DIR/abigen" --version 2> /dev/null | \ - grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)' + abigen --version 2>/dev/null | + grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)' )" || true -if [ "$NATIVE_ABIGEN_VERSION" == "$GETH_VERSION" ]; then +if [ "$NATIVE_ABIGEN_VERSION" = "$GETH_VERSION" ]; then echo "Correct abigen version already installed." exit 0 fi -function cleanup() { - rm -rf "$TMPDIR" -} - -trap cleanup EXIT - -TMPDIR="$(mktemp -d)" - -pushd "$TMPDIR" - -git clone --depth=1 --single-branch --branch "$GETH_VERSION" "$GETH_REPO_URL" -cd go-ethereum/cmd/abigen -go build -rm -f "$THIS_DIR/abigen" # necessary on MacOS for code signing -cp ./abigen "$THIS_DIR" - -popd - +go install github.com/ethereum/go-ethereum/cmd/abigen@$GETH_VERSION