diff --git a/.github/workflows/abi_bindings_checker.yml b/.github/workflows/abi_bindings_checker.yml index 3d490c806..1fad9aeb8 100644 --- a/.github/workflows/abi_bindings_checker.yml +++ b/.github/workflows/abi_bindings_checker.yml @@ -8,25 +8,28 @@ on: branches: - "*" -env: - GO_VERSION: "1.20.10" - jobs: abi_binding: name: abi_binding runs-on: ubuntu-20.04 steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - name: Checkout Teleporter repository uses: actions/checkout@v4 with: submodules: recursive + - name: Set Go version + run: | + source ./scripts/versions.sh + GO_VERSION=$GO_VERSION >> $GITHUB_ENV + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: @@ -49,16 +52,21 @@ jobs: runs-on: ubuntu-20.04 steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - name: Checkout repositories and submodules uses: actions/checkout@v4 with: submodules: recursive + - name: Set Go version + run: | + source ./scripts/versions.sh + GO_VERSION=$GO_VERSION >> $GITHUB_ENV + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run ABI Binding Unit Tests run: | source scripts/constants.sh diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index beab04840..1fe2468d4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,9 +11,6 @@ on: branches: - "*" -env: - GO_VERSION: "1.20.10" - jobs: e2e_tests: name: e2e_tests @@ -25,6 +22,11 @@ jobs: with: submodules: recursive + - name: Set Go version + run: | + source ./scripts/versions.sh + GO_VERSION=$GO_VERSION >> $GITHUB_ENV + - name: Setup Go uses: actions/setup-go@v4 with: @@ -40,9 +42,6 @@ jobs: cd subnet-evm ./scripts/build.sh /tmp/e2e-test/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy - - name: Checkout teleporter repository - uses: actions/checkout@v4 - - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: diff --git a/.github/workflows/gomod_checker.yml b/.github/workflows/gomod_checker.yml new file mode 100644 index 000000000..831258703 --- /dev/null +++ b/.github/workflows/gomod_checker.yml @@ -0,0 +1,31 @@ +name: go.mod Check + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + +jobs: + gomod_check: + name: Check go.mod + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - run: | + source ./scripts/versions.sh + GO_VERSION=$GO_VERSION >> $GITHUB_ENV + + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - run: go mod tidy + - run: git --no-pager diff -- go.mod go.sum # This prints the diff + - run: git --no-pager diff --quiet -- go.mod go.sum # This errors if there is a diff \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3520c30f3..94e3e7580 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,9 +8,6 @@ on: branches: - "*" -env: - RELAYER_VERSION: v0.2.4 - jobs: teleporter-integration-test: runs-on: ubuntu-20.04 @@ -25,7 +22,8 @@ jobs: - name: Download awm-relayer image run: | - docker pull avaplatform/awm-relayer:${RELAYER_VERSION} + source ./scripts/versions.sh + docker pull avaplatform/awm-relayer:${AWM_RELAYER_VERSION} - name: Teleporter Integration Tests run: | diff --git a/docker/Dockerfile b/docker/Dockerfile index c4080bb63..4850c5f1f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,6 +9,8 @@ ARG DEBIAN_FRONTEND=noninteractive # configured using either docker --build-arg flag or docker composer yaml service.build.args ARG ARCH=amd64 +ARG GO_VERSION + # defaults to grep running in a container. ENV grepcmd=grep @@ -22,8 +24,8 @@ RUN apt-get install -y wget curl git python3 make gcc build-essential # Install Golang RUN apt-get install -y bison -RUN wget https://go.dev/dl/go1.20.10.linux-${ARCH}.tar.gz -RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.10.linux-${ARCH}.tar.gz +RUN wget https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz +RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH}.tar.gz ENV PATH $PATH:/usr/local/go/bin ENV GOPATH $HOME/go ENV GOROOT /usr/local/go diff --git a/docker/docker-compose-run-local-template.yml b/docker/docker-compose-run-local-template.yml index db3dc38d6..880743230 100644 --- a/docker/docker-compose-run-local-template.yml +++ b/docker/docker-compose-run-local-template.yml @@ -9,6 +9,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by run.sh + GO_VERSION: ${GO_VERSION} # set by run.sh container_name: local_network_run init: true working_dir: /code diff --git a/docker/docker-compose-run.yml b/docker/docker-compose-run.yml index 87dd099d4..a16b4857e 100644 --- a/docker/docker-compose-run.yml +++ b/docker/docker-compose-run.yml @@ -9,6 +9,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by run.sh + GO_VERSION: ${GO_VERSION} # set by run.sh container_name: local_network_run init: true working_dir: /code diff --git a/docker/docker-compose-test-local-template.yml b/docker/docker-compose-test-local-template.yml index 39ced67c6..c3119c394 100644 --- a/docker/docker-compose-test-local-template.yml +++ b/docker/docker-compose-test-local-template.yml @@ -10,6 +10,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by test.sh + GO_VERSION: ${GO_VERSION} # set by test.sh container_name: local_network_test init: true working_dir: /code @@ -38,6 +39,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by test.sh + GO_VERSION: ${GO_VERSION} # set by test.sh container_name: test_runner init: true working_dir: /code diff --git a/docker/docker-compose-test.yml b/docker/docker-compose-test.yml index ca8becfc8..a4c65fdb3 100644 --- a/docker/docker-compose-test.yml +++ b/docker/docker-compose-test.yml @@ -10,6 +10,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by test.sh + GO_VERSION: ${GO_VERSION} # set by test.sh container_name: local_network_test init: true working_dir: /code @@ -37,6 +38,7 @@ services: dockerfile: ./docker/Dockerfile args: ARCH: ${ARCH} # set by test.sh + GO_VERSION: ${GO_VERSION} # set by test.sh container_name: test_runner init: true working_dir: /code diff --git a/go.mod b/go.mod index 1b07ef4f4..a4e2fcb51 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,6 @@ module github.com/ava-labs/teleporter +// Patch version for go is set in versions.sh go 1.20 require ( diff --git a/scripts/abi_bindings.sh b/scripts/abi_bindings.sh index f37a2d97b..9a2282b28 100755 --- a/scripts/abi_bindings.sh +++ b/scripts/abi_bindings.sh @@ -11,6 +11,7 @@ TELEPORTER_PATH=$( source $TELEPORTER_PATH/scripts/constants.sh source $TELEPORTER_PATH/scripts/utils.sh +source $TELEPORTER_PATH/scripts/versions.sh setARCH diff --git a/scripts/local/run.sh b/scripts/local/run.sh index 648ff9a7e..d0ba1d77d 100755 --- a/scripts/local/run.sh +++ b/scripts/local/run.sh @@ -5,6 +5,7 @@ set -e # Stop on first error source ./scripts/utils.sh +source ./scripts/versions.sh LOCAL_RELAYER_IMAGE= RUN_STOP_FLAG="-c" diff --git a/scripts/local/test.sh b/scripts/local/test.sh index 39658c9d6..4048e329a 100755 --- a/scripts/local/test.sh +++ b/scripts/local/test.sh @@ -4,6 +4,7 @@ set -e # Stop on first error source ./scripts/utils.sh +source ./scripts/versions.sh TEST_TARGET= LOCAL_RELAYER_IMAGE= diff --git a/scripts/versions.sh b/scripts/versions.sh index 50cc1c28c..a5be5e19f 100755 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -2,9 +2,29 @@ # Copyright (C) 2023, Ava Labs, Inc. All rights reserved. # See the file LICENSE for licensing terms. -# Set up the versions to be used -AWM_RELAYER_VERSION=${AWM_RELAYER_VERSION:-'v0.2.4'} -SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-'v0.5.8'} +set -e +set -o pipefail + +# The go version for this project is set from a combination of major.minor from go.mod and the patch version set here. +GO_PATCH_VERSION=10 + +TELEPORTER_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) + +# Pass in the full name of the dependency. +# Parses go.mod for a matching entry and extracts the version number. +function getDepVersion() { + grep -m1 "^\s*$1" $TELEPORTER_PATH/go.mod | cut -d ' ' -f2 +} + +# AWM_RELAYER_VERSION is needed for the docker run setup, but is not a go module dependency. +AWM_RELAYER_VERSION=${AWM_RELAYER_VERSION:-'v0.2.3'} + +# This needs to be exported to be picked up by the dockerfile. +export GO_VERSION=${GO_VERSION:-$(getDepVersion go).$GO_PATCH_VERSION} + # Don't export them as they're used in the context of other calls -AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.10.14'} -GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'} +AVALANCHE_VERSION=${AVALANCHE_VERSION:-$(getDepVersion github.com/ava-labs/avalanchego)} +GINKGO_VERSION=${GINKGO_VERSION:-$(getDepVersion github.com/onsi/ginkgo/v2)}