From 3f5dc8a60f6a73a718596fcfe1d0f924c32298b4 Mon Sep 17 00:00:00 2001 From: marun Date: Tue, 29 Aug 2023 10:17:05 -0700 Subject: [PATCH] e2e: Add avalanchego e2e job (#305) * e2e: Add avalanchego e2e job * fixup: Use currently supported golang version * fixup: Enable configurable avalanchego clone path --- .github/workflows/ci.yml | 23 ++++++++++++++++++ .gitignore | 3 +++ scripts/tests.e2e.sh | 52 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100755 scripts/tests.e2e.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec6f3f2355..ceb4d32e6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,3 +148,26 @@ jobs: DOCKER_PASS: ${{ secrets.DOCKER_PASS }} KURTOSIS_CLIENT_ID: ${{ secrets.KURTOSIS_CLIENT_ID }} KURTOSIS_CLIENT_SECRET: ${{ secrets.KURTOSIS_CLIENT_SECRET }} + avalanchego_e2e: + name: AvalancheGo E2E Tests v${{ matrix.go }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-20.04 ] + steps: + - uses: actions/checkout@v3 + - name: check out ${{ github.event.inputs.avalanchegoRepo }} ${{ github.event.inputs.avalanchegoBranch }} + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: actions/checkout@v3 + with: + repository: ${{ github.event.inputs.avalanchegoRepo }} + ref: ${{ github.event.inputs.avalanchegoBranch }} + path: avalanchego + token: ${{ secrets.AVALANCHE_PAT }} + - uses: actions/setup-go@v3 + with: + go-version: '~1.19.12' + check-latest: true + - name: Run e2e tests + run: E2E_SERIAL=1 ./scripts/tests.e2e.sh + shell: bash diff --git a/.gitignore b/.gitignore index 87ff040a44..a93619ce95 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ awscpu bin/ build/ + +# Used for e2e testing +avalanchego diff --git a/scripts/tests.e2e.sh b/scripts/tests.e2e.sh new file mode 100755 index 0000000000..31cf438e56 --- /dev/null +++ b/scripts/tests.e2e.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Run AvalancheGo e2e tests from the target version against the current state of coreth. + +# e.g., +# ./scripts/tests.e2e.sh +# AVALANCHE_VERSION=v1.10.x ./scripts/tests.e2e.sh +if ! [[ "$0" =~ scripts/tests.e2e.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +# Coreth root directory +CORETH_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) + +# Allow configuring the clone path to point to an existing clone +AVALANCHEGO_CLONE_PATH="${AVALANCHEGO_CLONE_PATH:-avalanchego}" + +# Load the version +source "$CORETH_PATH"/scripts/versions.sh + +# Always return to the coreth path on exit +function cleanup { + cd "${CORETH_PATH}" +} +trap cleanup EXIT + +echo "checking out target AvalancheGo version ${avalanche_version}" +if [[ -d "${AVALANCHEGO_CLONE_PATH}" ]]; then + echo "updating existing clone" + cd "${AVALANCHEGO_CLONE_PATH}" + git fetch + git checkout -B "${avalanche_version}" +else + echo "creating new clone" + git clone -b "${avalanche_version}"\ + --single-branch https://github.com/ava-labs/avalanchego.git\ + "${AVALANCHEGO_CLONE_PATH}" + cd "${AVALANCHEGO_CLONE_PATH}" +fi + +echo "updating coreth dependency to point to ${CORETH_PATH}" +go mod edit -replace "github.com/ava-labs/coreth=${CORETH_PATH}" +go mod tidy + +echo "building avalanchego" +./scripts/build.sh -r + +echo "running AvalancheGo e2e tests" +./scripts/tests.e2e.sh ./build/avalanchego