-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[antithesis] Propose initial test setup
- Loading branch information
Showing
17 changed files
with
569 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Publish Antithesis Images | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: us-central1-docker.pkg.dev | ||
REPOSITORY: molten-verve-216720/avalanche-repository | ||
|
||
jobs: | ||
antithesis: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GAR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: _json_key | ||
password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }} | ||
|
||
- name: Build and publish images | ||
run: bash -x ./scripts/build_antithesis_images.sh | ||
env: | ||
IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} | ||
TAG: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,6 @@ cmd/simulator/simulator | |
|
||
# goreleaser | ||
dist/ | ||
|
||
# clone used for antithesis image builds | ||
avalanchego/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Builds docker images for antithesis testing. | ||
|
||
# e.g., | ||
# ./scripts/build_antithesis_images.sh # Build local images | ||
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag | ||
|
||
# Directory above this script | ||
SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Allow configuring the clone path to point to a shared and/or existing clone of the avalanchego repo | ||
AVALANCHEGO_CLONE_PATH="${AVALANCHEGO_CLONE_PATH:-${SUBNET_EVM_PATH}/avalanchego}" | ||
|
||
# Specifying an image prefix will ensure the image is pushed after build | ||
IMAGE_PREFIX="${IMAGE_PREFIX:-}" | ||
|
||
TAG="${TAG:-}" | ||
if [[ -z "${TAG}" ]]; then | ||
# Default to tagging with the commit hash | ||
source "${SUBNET_EVM_PATH}"/scripts/constants.sh | ||
TAG="${SUBNET_EVM_COMMIT::8}" | ||
fi | ||
|
||
# The dockerfiles don't specify the golang version to minimize the changes required to bump | ||
# the version. Instead, the golang version is provided as an argument. | ||
GO_VERSION="$(go list -m -f '{{.GoVersion}}')" | ||
|
||
function build_images { | ||
local base_image_name=$1 | ||
local uninstrumented_node_dockerfile=$2 | ||
local avalanche_node_image=$3 | ||
|
||
# Define image names | ||
if [[ -n "${IMAGE_PREFIX}" ]]; then | ||
base_image_name="${IMAGE_PREFIX}/${base_image_name}" | ||
fi | ||
local node_image_name="${base_image_name}-node:${TAG}" | ||
local workload_image_name="${base_image_name}-workload:${TAG}" | ||
local config_image_name="${base_image_name}-config:${TAG}" | ||
|
||
# Define dockerfiles | ||
local base_dockerfile="${SUBNET_EVM_PATH}/tests/antithesis/Dockerfile" | ||
local node_dockerfile="${base_dockerfile}.node" | ||
if [[ "$(go env GOARCH)" == "arm64" ]]; then | ||
# Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the | ||
# uninstrumented Dockerfile will be used to build the node image to enable local test | ||
# development. | ||
node_dockerfile="${uninstrumented_node_dockerfile}" | ||
fi | ||
|
||
# Define default build command | ||
local docker_cmd="docker buildx build --build-arg GO_VERSION=${GO_VERSION} --build-arg NODE_IMAGE=${node_image_name}" | ||
|
||
# Build node image first to allow the config and workload image builds to use it. | ||
${docker_cmd} --build-arg AVALANCHEGO_NODE_IMAGE="${avalanche_node_image}" -t "${node_image_name}" \ | ||
-f "${node_dockerfile}" "${SUBNET_EVM_PATH}" | ||
${docker_cmd} --build-arg IMAGE_TAG="${TAG}" -t "${config_image_name}" -f "${base_dockerfile}.config" "${SUBNET_EVM_PATH}" | ||
${docker_cmd} -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${SUBNET_EVM_PATH}" | ||
} | ||
|
||
# Assume it's necessary to build the avalanchego node image from source | ||
# TODO(marun) Support use of a released node image if using a release version of avalanchego | ||
|
||
source "${SUBNET_EVM_PATH}"/scripts/versions.sh | ||
|
||
echo "checking out target avalanchego version ${AVALANCHE_VERSION}" | ||
if [[ -d "${AVALANCHEGO_CLONE_PATH}" ]]; then | ||
echo "updating existing clone" | ||
cd "${AVALANCHEGO_CLONE_PATH}" | ||
git fetch | ||
else | ||
echo "creating new clone" | ||
git clone https://github.com/ava-labs/avalanchego.git "${AVALANCHEGO_CLONE_PATH}" | ||
cd "${AVALANCHEGO_CLONE_PATH}" | ||
fi | ||
# Branch will be reset to $AVALANCHE_VERSION if it already exists | ||
git checkout -B "test-${AVALANCHE_VERSION}" "${AVALANCHE_VERSION}" | ||
cd "${SUBNET_EVM_PATH}" | ||
|
||
# Build avalanchego node image | ||
NODE_ONLY=1 TEST_SETUP=avalanchego IMAGE_PREFIX="${IMAGE_PREFIX}" "${AVALANCHEGO_CLONE_PATH}"/scripts/build_antithesis_images.sh | ||
|
||
build_images antithesis-subnet-evm "${SUBNET_EVM_PATH}/Dockerfile" "antithesis-avalanchego-node:${AVALANCHE_VERSION::8}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Directory above this script | ||
SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
# Load the constants | ||
source "$SUBNET_EVM_PATH"/scripts/constants.sh | ||
|
||
echo "Building Workload..." | ||
go build -o "$SUBNET_EVM_PATH/build/workload" "$SUBNET_EVM_PATH/tests/antithesis/"*.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.