From 23398664b9283c3703a24e149d5018399a3ec1e2 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Tue, 30 Apr 2024 18:05:06 -0700 Subject: [PATCH] Simplify go version maintenance Now that the minimum go version is defined in go.mod, source the version from there for everywhere that needs it rather than hard-coding. This is intended to simplify version changes. --- .github/workflows/build-linux-binaries.yml | 11 ++++--- .github/workflows/build-macos-release.yml | 3 +- .github/workflows/build-public-ami.yml | 5 +-- .../workflows/build-ubuntu-amd64-release.yml | 9 +++--- .../workflows/build-ubuntu-arm64-release.yml | 9 +++--- .github/workflows/build-win-release.yml | 4 ++- .github/workflows/ci.yml | 32 ++++++++++++------- .github/workflows/codeql-analysis.yml | 5 ++- .github/workflows/fuzz.yml | 4 ++- .github/workflows/fuzz_merkledb.yml | 4 ++- .github/workflows/go_version_env.sh | 14 ++++++++ .../workflows/publish_antithesis_images.yml | 15 ++++++--- CONTRIBUTING.md | 2 +- Dockerfile | 12 +++---- README.md | 9 +----- go.mod | 7 +--- proto/Dockerfile.buf | 22 ------------- proto/README.md | 5 ++- scripts/build_image.sh | 6 ++++ scripts/protobuf_codegen.sh | 10 +----- tests/antithesis/Dockerfile.node | 14 ++++---- tests/antithesis/Dockerfile.workload | 12 +++---- 22 files changed, 106 insertions(+), 108 deletions(-) create mode 100755 .github/workflows/go_version_env.sh delete mode 100644 proto/Dockerfile.buf diff --git a/.github/workflows/build-linux-binaries.yml b/.github/workflows/build-linux-binaries.yml index 048c7f1f36a8..86375d141cd7 100644 --- a/.github/workflows/build-linux-binaries.yml +++ b/.github/workflows/build-linux-binaries.yml @@ -10,9 +10,6 @@ on: tags: - "*" -env: - go_version: '~1.21.9' - jobs: build-x86_64-binaries-tarball: runs-on: ubuntu-20.04 @@ -20,9 +17,11 @@ jobs: steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version @@ -82,9 +81,11 @@ jobs: steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + - uses: actions/setup-go@v3 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version diff --git a/.github/workflows/build-macos-release.yml b/.github/workflows/build-macos-release.yml index 233a96bca85c..09abea39d5dd 100644 --- a/.github/workflows/build-macos-release.yml +++ b/.github/workflows/build-macos-release.yml @@ -24,9 +24,10 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true - run: go version diff --git a/.github/workflows/build-public-ami.yml b/.github/workflows/build-public-ami.yml index 321e28d2c036..90acfc13e054 100644 --- a/.github/workflows/build-public-ami.yml +++ b/.github/workflows/build-public-ami.yml @@ -21,9 +21,10 @@ jobs: steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true - run: go version @@ -62,7 +63,7 @@ jobs: id: setup with: version: ${{ env.PACKER_VERSION }} - + - name: Run `packer init` id: init run: "packer init ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" diff --git a/.github/workflows/build-ubuntu-amd64-release.yml b/.github/workflows/build-ubuntu-amd64-release.yml index 29813eb197f3..f705b2fecd9b 100644 --- a/.github/workflows/build-ubuntu-amd64-release.yml +++ b/.github/workflows/build-ubuntu-amd64-release.yml @@ -10,18 +10,16 @@ on: tags: - "*" -env: - go_version: '~1.21.9' - jobs: build-jammy-amd64-package: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version @@ -79,9 +77,10 @@ jobs: steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version diff --git a/.github/workflows/build-ubuntu-arm64-release.yml b/.github/workflows/build-ubuntu-arm64-release.yml index b558720a432c..5fe9648f5232 100644 --- a/.github/workflows/build-ubuntu-arm64-release.yml +++ b/.github/workflows/build-ubuntu-arm64-release.yml @@ -10,18 +10,16 @@ on: tags: - "*" -env: - go_version: '~1.21.9' - jobs: build-jammy-arm64-package: runs-on: [self-hosted, linux, ARM64, jammy] steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v3 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version @@ -79,9 +77,10 @@ jobs: steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v3 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - run: go version diff --git a/.github/workflows/build-win-release.yml b/.github/workflows/build-win-release.yml index 2ef6031cfbed..b9bad3a4961a 100644 --- a/.github/workflows/build-win-release.yml +++ b/.github/workflows/build-win-release.yml @@ -24,9 +24,11 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + - uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true - run: go version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a64efdbbd05..426b60f9c546 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,6 @@ concurrency: cancel-in-progress: true env: - go_version: '~1.21.9' grafana_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7Cava-labs%2Favalanchego&var-filter=gh_run_id%7C%3D%7C${{ github.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ github.run_attempt }} jobs: @@ -32,9 +31,10 @@ jobs: os: [macos-12, ubuntu-20.04, ubuntu-22.04, windows-2022, [self-hosted, linux, ARM64, focal], [self-hosted, linux, ARM64, jammy]] steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v3 with: - go-version: ${{ env.go_version }} + go-version: '${{ env.GO_VERSION }}' check-latest: true - name: Set timeout on Windows # Windows UT run slower and need a longer timeout shell: bash @@ -49,9 +49,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - name: fuzz_test shell: bash @@ -60,9 +61,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - name: Build AvalancheGo Binary shell: bash @@ -114,9 +116,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - name: Build AvalancheGo Binary shell: bash @@ -167,9 +170,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - name: Build AvalancheGo Binary shell: bash @@ -220,9 +224,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - name: Run static analysis tests shell: bash @@ -246,9 +251,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - uses: bufbuild/buf-setup-action@v1.31.0 - shell: bash @@ -260,9 +266,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - shell: bash run: scripts/mock.gen.sh @@ -273,9 +280,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - uses: actions/setup-go@v5 with: - go-version: ${{ env.go_version }} + go-version: ${{ env.GO_VERSION }} check-latest: true - shell: bash run: go mod tidy @@ -297,7 +305,9 @@ jobs: runs-on: ubuntu-latest name: govulncheck steps: + - uses: actions/checkout@v4 + - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - id: govulncheck uses: golang/govulncheck-action@v1 with: - go-version-input: ${{ env.go_version }} + go-version-input: ${{ env.GO_VERSION }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 470226b42682..2818db2f482e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,10 +42,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Get Go version from project + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + - name: Setup Golang uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true # Initializes the CodeQL tools for scanning. diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 23e0dc6ccea1..efa2e2e872a2 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -15,10 +15,12 @@ jobs: uses: actions/checkout@v4 with: ref: 'dev' + - name: Get Go version from project + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true - name: Run fuzz tests shell: bash diff --git a/.github/workflows/fuzz_merkledb.yml b/.github/workflows/fuzz_merkledb.yml index c0dbc1dfdb13..366e7b36afa7 100644 --- a/.github/workflows/fuzz_merkledb.yml +++ b/.github/workflows/fuzz_merkledb.yml @@ -17,10 +17,12 @@ jobs: uses: actions/checkout@v4 with: ref: 'dev' + - name: Get Go version from project + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '~1.21.9' + go-version: '${{ env.GO_VERSION }}' check-latest: true - name: Run merkledb fuzz tests shell: bash diff --git a/.github/workflows/go_version_env.sh b/.github/workflows/go_version_env.sh new file mode 100755 index 000000000000..60b643ac386e --- /dev/null +++ b/.github/workflows/go_version_env.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Prints the go version defined in the repo's go.mod. This is useful +# for configuring the correct version of go to install in CI. +# +# `go list -m -f '{{.GoVersion}}'` should be preferred outside of CI +# when go is already installed. + +# 2 directories above this script +AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../.. && pwd ) + +echo GO_VERSION="~$(sed -n -e 's/^go //p' "${AVALANCHE_PATH}"/go.mod)" diff --git a/.github/workflows/publish_antithesis_images.yml b/.github/workflows/publish_antithesis_images.yml index 851260858990..546923c6351a 100644 --- a/.github/workflows/publish_antithesis_images.yml +++ b/.github/workflows/publish_antithesis_images.yml @@ -6,7 +6,7 @@ on: branches: - master -env: +env: REGISTRY: us-central1-docker.pkg.dev REPOSITORY: molten-verve-216720/avalanche-repository NODE_NAME: avalanche-node @@ -28,18 +28,25 @@ jobs: registry: ${{ env.REGISTRY }} username: _json_key password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }} - + + - name: Get Go version from project + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + - name: Build node id: build-node-image run: | - docker build -t $REGISTRY/$REPOSITORY/$NODE_NAME:$TAG -f ./tests/antithesis/Dockerfile.node . + docker build --build-arg GO_VERSION=${GO_VERSION} -t $REGISTRY/$REPOSITORY/$NODE_NAME:$TAG -f ./tests/antithesis/Dockerfile.node . echo "name=image::$REGISTRY/$REPOSITORY/$NODE_NAME:$TAG" >> $GITHUB_OUTPUT + env: + GO_VERSION: '${{ env.GO_VERSION }}' - name: Build workload id: build-workload-image run: | - docker build -t $REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG -f ./tests/antithesis/Dockerfile.workload . + docker build --build-arg GO_VERSION=${GO_VERSION} -t $REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG -f ./tests/antithesis/Dockerfile.workload . echo "name=image::$REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG" >> $GITHUB_OUTPUT + env: + GO_VERSION: '${{ env.GO_VERSION }}' - name: Build config id: build-config-image diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a56527948c8f..f641ed1275ad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ To start developing on AvalancheGo, you'll need a few things installed. -- Golang version >= 1.21.9 +- Golang version >= the version defined in go.mod - gcc - g++ diff --git a/Dockerfile b/Dockerfile index f20299cf9f3d..f7fffb848b2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ -# Changes to the minimum golang version must also be replicated in -# tests/antithesis/Dockerfile.node -# tests/antithesis/Dockerfile.workload -# Dockerfile (here) -# README.md -# go.mod +# The version is supplied as a build argument rather than hard-coded +# to minimize the cost of version changes. +ARG GO_VERSION + # ============= Compilation Stage ================ # Always use the native platform to ensure fast builds -FROM --platform=$BUILDPLATFORM golang:1.21.9-bullseye AS builder +FROM --platform=$BUILDPLATFORM golang:$GO_VERSION-bullseye AS builder WORKDIR /build diff --git a/README.md b/README.md index 46c98ead6c73..c9e99b238169 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The minimum recommended hardware specification for nodes connected to Mainnet is If you plan to build AvalancheGo from source, you will also need the following software: -- [Go](https://golang.org/doc/install) version >= 1.21.9 +- [Go](https://golang.org/doc/install) - minimum required version is defined in go.mod - [gcc](https://gcc.gnu.org/) - g++ @@ -185,13 +185,6 @@ scripts/protobuf_codegen.sh For more information, refer to the [GRPC Golang Quick Start Guide](https://grpc.io/docs/languages/go/quickstart/). -### Running protobuf codegen from docker - -```sh -docker build -t avalanche:protobuf_codegen -f api/Dockerfile.buf . -docker run -t -i -v $(pwd):/opt/avalanche -w/opt/avalanche avalanche:protobuf_codegen bash -c "scripts/protobuf_codegen.sh" -``` - ### Running mock codegen To regenerate the [gomock](https://github.com/uber-go/mock) code, run `scripts/mock.gen.sh` from the root of the repo. diff --git a/go.mod b/go.mod index f420912f5c95..c68758eea342 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,6 @@ module github.com/ava-labs/avalanchego -// Changes to the minimum golang version must also be replicated in -// tests/antithesis/Dockerfile.node -// tests/antithesis/Dockerfile.workload -// Dockerfile -// README.md -// go.mod (here) +// The minimum golang version defined here will be reused for CI and image builds. go 1.21.9 require ( diff --git a/proto/Dockerfile.buf b/proto/Dockerfile.buf deleted file mode 100644 index ef7f87c43467..000000000000 --- a/proto/Dockerfile.buf +++ /dev/null @@ -1,22 +0,0 @@ -FROM bufbuild/buf:1.31.0 AS builder - -FROM ubuntu:20.04 - -RUN apt-get update && apt -y install bash curl unzip git -WORKDIR /opt - -RUN \ - curl -L https://go.dev/dl/go1.21.9.linux-amd64.tar.gz > golang.tar.gz && \ - mkdir golang && \ - tar -zxvf golang.tar.gz -C golang/ - -ENV PATH="${PATH}:/opt/golang/go/bin" - -COPY --from=builder /usr/local/bin/buf /usr/local/bin/ - -# any version changes here should also be bumped in scripts/protobuf_codegen.sh -RUN \ - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0 && \ - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 - -ENV PATH="${PATH}:/root/go/bin/" diff --git a/proto/README.md b/proto/README.md index 5d60f6bb094e..e1ef00f4e996 100644 --- a/proto/README.md +++ b/proto/README.md @@ -10,8 +10,7 @@ Protobuf linting and generation for this project is managed by [buf](https://github.com/bufbuild/buf). Please find installation instructions on -[https://docs.buf.build/installation/](https://docs.buf.build/installation/) or -use `Dockerfile.buf` provided in the `proto/` directory of AvalancheGo. +[https://docs.buf.build/installation/](https://docs.buf.build/installation/). Any changes made to proto definition can be updated by running `protobuf_codegen.sh` located in the `scripts/` directory of AvalancheGo. @@ -34,4 +33,4 @@ subnet vm must use the same protocol version to be compatible. - Publish new tag to buf registry. `buf push -t v26` Note: Publishing requires auth to the ava-labs org in buf -https://buf.build/ava-labs/repositories \ No newline at end of file +https://buf.build/ava-labs/repositories diff --git a/scripts/build_image.sh b/scripts/build_image.sh index b533f22f31b2..3a7b7e588d05 100755 --- a/scripts/build_image.sh +++ b/scripts/build_image.sh @@ -44,6 +44,12 @@ DOCKER_IMAGE=${DOCKER_IMAGE:-"avalanchego"} # Reference: https://docs.docker.com/build/buildkit/ DOCKER_CMD="docker buildx build" +# The dockerfile doesn't specify the golang version to minimize the +# changes required to bump the version. Instead, the golang version is +# provided as an argument. +GO_VERSION="$(go list -m -f '{{.GoVersion}}')" +DOCKER_CMD="${DOCKER_CMD} --build-arg GO_VERSION=${GO_VERSION}" + if [[ "${DOCKER_IMAGE}" == *"/"* ]]; then # Build a multi-arch image since the image name includes a slash which indicates # the use of a registry e.g. diff --git a/scripts/protobuf_codegen.sh b/scripts/protobuf_codegen.sh index 9890b72a13d1..d57868924906 100755 --- a/scripts/protobuf_codegen.sh +++ b/scripts/protobuf_codegen.sh @@ -7,10 +7,7 @@ if ! [[ "$0" =~ scripts/protobuf_codegen.sh ]]; then exit 255 fi -## install "buf" -# any version changes here should also be bumped in Dockerfile.buf -# ref. https://docs.buf.build/installation -# ref. https://github.com/bufbuild/buf/releases +## ensure the correct version of "buf" is installed BUF_VERSION='1.31.0' if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then echo "could not find buf ${BUF_VERSION}, is it installed + in PATH?" @@ -18,8 +15,6 @@ if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then fi ## install "protoc-gen-go" -# any version changes here should also be bumped in Dockerfile.buf -# ref. https://github.com/protocolbuffers/protobuf-go/releases PROTOC_GEN_GO_VERSION='v1.33.0' go install -v google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION} if [[ $(protoc-gen-go --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_VERSION}" ]]; then @@ -29,9 +24,6 @@ if [[ $(protoc-gen-go --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_VERSION}" ] fi ### install "protoc-gen-go-grpc" -# any version changes here should also be bumped in Dockerfile.buf -# ref. https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc -# ref. https://github.com/grpc/grpc-go/blob/master/cmd/protoc-gen-go-grpc/main.go PROTOC_GEN_GO_GRPC_VERSION='1.3.0' go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC_VERSION} if [[ $(protoc-gen-go-grpc --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_GRPC_VERSION}" ]]; then diff --git a/tests/antithesis/Dockerfile.node b/tests/antithesis/Dockerfile.node index 243e8c74c285..d4591250e202 100644 --- a/tests/antithesis/Dockerfile.node +++ b/tests/antithesis/Dockerfile.node @@ -1,14 +1,12 @@ +# The version is supplied as a build argument rather than hard-coded +# to minimize the cost of version changes. +ARG GO_VERSION + # Antithesis: Getting the Antithesis golang instrumentation library FROM docker.io/antithesishq/go-instrumentor AS instrumentor -# Changes to the minimum golang version must also be replicated in -# tests/antithesis/Dockerfile.node (here) -# tests/antithesis/Dockerfile.workload -# Dockerfile -# README.md -# go.mod # ============= Compilation Stage ================ -FROM golang:1.21.9-bullseye AS builder +FROM golang:$GO_VERSION-bullseye AS builder WORKDIR /build # Copy and download avalanche dependencies using go mod @@ -30,7 +28,7 @@ COPY --from=instrumentor /opt/antithesis/lib /lib RUN mkdir -p /avalanchego_instrumented # Park the .git file in a safe location -RUN mkdir -p /opt/tmp/ +RUN mkdir -p /opt/tmp/ RUN cp -r .git /opt/tmp/ # Instrument avalanchego diff --git a/tests/antithesis/Dockerfile.workload b/tests/antithesis/Dockerfile.workload index 80b2e0d77dcf..5ac63b893177 100644 --- a/tests/antithesis/Dockerfile.workload +++ b/tests/antithesis/Dockerfile.workload @@ -1,11 +1,9 @@ -# Changes to the minimum golang version must also be replicated in -# tests/antithesis/Dockerfile.node -# tests/antithesis/Dockerfile.workload (here) -# Dockerfile -# README.md -# go.mod +# The version is supplied as a build argument rather than hard-coded +# to minimize the cost of version changes. +ARG GO_VERSION + # ============= Compilation Stage ================ -FROM golang:1.21.9-bullseye AS builder +FROM golang:$GO_VERSION-bullseye AS builder WORKDIR /build # Copy and download avalanche dependencies using go mod