Skip to content

Commit

Permalink
Merge pull request #138 from ava-labs/gstuart/diff-go-mod-sum
Browse files Browse the repository at this point in the history
Single source of truth for go version
  • Loading branch information
geoff-vball authored Nov 22, 2023
2 parents 9a69b72 + 52e5739 commit ee1fd7d
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 29 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/abi_bindings_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
branches:
- "*"

env:
GO_VERSION: "1.20.10"

jobs:
e2e_tests:
name: e2e_tests
Expand All @@ -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:
Expand All @@ -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:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/gomod_checker.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
branches:
- "*"

env:
RELAYER_VERSION: v0.2.4

jobs:
teleporter-integration-test:
runs-on: ubuntu-20.04
Expand All @@ -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: |
Expand Down
6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose-run-local-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose-test-local-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module github.com/ava-labs/teleporter

// Patch version for go is set in versions.sh
go 1.20

require (
Expand Down
1 change: 1 addition & 0 deletions scripts/abi_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions scripts/local/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions scripts/local/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

set -e # Stop on first error
source ./scripts/utils.sh
source ./scripts/versions.sh

TEST_TARGET=
LOCAL_RELAYER_IMAGE=
Expand Down
30 changes: 25 additions & 5 deletions scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

0 comments on commit ee1fd7d

Please sign in to comment.