Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,39 @@ on:
- "*"
pull_request:

env:
min_go_version: "~1.22.8"

jobs:
lint_test:
name: Lint
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.56
version: v1.63
working-directory: .
args: --timeout 10m
skip-pkg-cache: true
- name: go mod tidy
run: |
go mod tidy
git diff --exit-code

unit_test:
name: Golang Unit Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-20.04, ubuntu-latest, windows-latest]
os: [macos-latest, ubuntu-22.04, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
go-version-file: "go.mod"
- name: Set timeout on Windows # Windows UT run slower and need a longer timeout
shell: bash
if: matrix.os == 'windows-latest'
Expand All @@ -68,8 +67,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.min_go_version }}
check-latest: true
go-version-file: "go.mod"
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
10 changes: 10 additions & 0 deletions bin/ginkgo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

# Ensure the go command is run from the root of the repository so that its go.mod file is used
REPO_ROOT=$(cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
cd "${REPO_ROOT}"

# If an explicit version is not specified, go run uses the ginkgo version from go.mod
go run github.com/onsi/ginkgo/v2/ginkgo "${@}"
9 changes: 6 additions & 3 deletions scripts/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ GOPATH="$(go env GOPATH)"
# Static compilation
STATIC_LD_FLAGS=''
if [ "${STATIC_COMPILATION:-}" = 1 ]; then
export CC=musl-gcc
command -v $CC || (echo $CC must be available for static compilation && exit 1)
STATIC_LD_FLAGS=' -extldflags "-static" -linkmode external '
export CC=musl-gcc
command -v $CC || (echo $CC must be available for static compilation && exit 1)
STATIC_LD_FLAGS=' -extldflags "-static" -linkmode external '
fi

# 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="-O2 -D__BLST_PORTABLE__"

# CGO_ENABLED is required for multi-arch builds.
export CGO_ENABLED=1
7 changes: 0 additions & 7 deletions scripts/lint.sh

This file was deleted.

4 changes: 1 addition & 3 deletions scripts/run_ginkgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ source "$ROOT_DIR_PATH"/scripts/versions.sh

# Build ginkgo
echo "building precompile.test"
# to install the ginkgo binary (required for test build and run)
go install -v github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION}

TEST_SOURCE_ROOT=$(pwd)

# By default, it runs all e2e test cases!
# Use "--ginkgo.skip" to skip tests.
# Use "--ginkgo.focus" to select tests.
TEST_SOURCE_ROOT="$TEST_SOURCE_ROOT" ginkgo run -procs=5 tests/precompile \
TEST_SOURCE_ROOT="$TEST_SOURCE_ROOT" "${ROOT_DIR_PATH}"/bin/ginkgo run -procs=5 tests/precompile \
--ginkgo.vv \
--ginkgo.label-filter=${GINKGO_LABEL_FILTER:-""}
41 changes: 36 additions & 5 deletions scripts/versions.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
#!/usr/bin/env bash

# Set up the versions to be used - populate ENV variables only if they are not already populated
SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-'v0.7.1'}
# Don't export them as they're used in the context of other calls
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.12.2'}
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}
# Ignore warnings about variables appearing unused since this file is not the consumer of the variables it defines.
# shellcheck disable=SC2034

set_module_version_var() {
local env_var_name="$1"
local module_path="$2"

if [[ -z "$env_var_name" || -z "$module_path" ]]; then
echo "Usage: set_module_version_var <ENV_VAR_NAME> <GO_MODULE_PATH>"
return 1
fi

# Check if the environment variable is already set
if [[ -z "${!env_var_name:-}" ]]; then
# Get module details from go.mod
local module_details
module_details="$(go list -m "$module_path" 2>/dev/null)" || return 1

# Extract version from module details
local version
version="$(echo "$module_details" | awk '{print $2}')"

# If version is a pseudo-version (timestamp-hash format), extract the short hash
if [[ "$version" =~ ^v.*[0-9]{14}-[0-9a-f]{12}$ ]]; then
local module_hash
module_hash="$(echo "$version" | grep -Eo '[0-9a-f]{12}$')"
version="${module_hash::8}"
fi

# Don't export them as they're used in the context of other calls
eval "$env_var_name=$version"
fi
}

set_module_version_var "SUBNET_EVM_VERSION" "github.com/ava-labs/subnet-evm"
set_module_version_var "AVALANCHE_VERSION" "github.com/ava-labs/avalanchego"
Loading