diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 20a117a8..edb8ce27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,5 +32,5 @@ jobs: - name: Run Relayer Unit Tests run: | cd awm-relayer - go test ./... + ./scripts/test.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 34126291..99620918 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ To start developing on AWM Relayer, you'll need Golang >= v1.18.1. - Run the unit tests ```sh -go test ./... +./scripts/test.sh ``` ### Continuous Integration (CI) diff --git a/scripts/build.sh b/scripts/build.sh index 322ff9d5..4c03ade9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -30,13 +30,14 @@ if version_lt "$(go_version)" "$go_version_minimum"; then fi # Root directory -AWM_RELAYER_PATH=$( +RELAYER_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" cd .. && pwd ) -# Load the versions -source "$AWM_RELAYER_PATH"/scripts/versions.sh +# Load the versions and constants +source "$RELAYER_PATH"/scripts/versions.sh +source "$RELAYER_PATH"/scripts/constants.sh if [[ $# -eq 1 ]]; then binary_path=$1 diff --git a/scripts/build_local_image.sh b/scripts/build_local_image.sh index 71a8fa0f..aae95bf8 100755 --- a/scripts/build_local_image.sh +++ b/scripts/build_local_image.sh @@ -7,8 +7,10 @@ set -o nounset set -o pipefail # Directory above this script -RELAYER_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) - +RELAYER_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) # Load the constants source "$RELAYER_PATH"/scripts/constants.sh diff --git a/scripts/constants.sh b/scripts/constants.sh index 14a0d5e6..bfb90688 100755 --- a/scripts/constants.sh +++ b/scripts/constants.sh @@ -5,7 +5,10 @@ # Use lower_case variables in the scripts and UPPER_CASE variables for override # Use the constants.sh for env overrides -RELAYER_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Directory above this script +RELAYER_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) # Where AWM Relayer binary goes relayer_path="$RELAYER_PATH/build/awm-relayer" @@ -22,3 +25,12 @@ relayer_dockerhub_repo=${DOCKER_REPO:-"awm-relayer"} current_branch=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match || true) git_commit=${RELAYER_COMMIT:-$( git rev-list -1 HEAD )} + +# Set the CGO flags to use the portable version of BLST +# +# We use "export" here instead of just setting a bash variable because we need +# to pass this flag to all child processes spawned by the shell. +export CGO_CFLAGS="-O -D__BLST_PORTABLE__" +# While CGO_ENABLED doesn't need to be explicitly set, it produces a much more +# clear error due to the default value change in go1.20. +export CGO_ENABLED=1 \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 00000000..c402fedb --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +set -o errexit +set -o nounset +set -o pipefail + +# Directory above this script +RELAYER_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) +source "$RELAYER_PATH"/scripts/constants.sh + +go test ./... \ No newline at end of file