-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial push of the kurtosis_upgrade
- Loading branch information
Showing
15 changed files
with
594 additions
and
118 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
.ci | ||
.git | ||
.github | ||
.gitignore | ||
.golangci.yml | ||
|
||
.idea | ||
.vscode | ||
|
||
LICENSE | ||
*.md | ||
|
||
Dockerfile | ||
|
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,25 @@ | ||
name: Test + build Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- kurtosis_upgrade | ||
|
||
jobs: | ||
e2e_plus_publish: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run Kurtosis Tests | ||
env: # Secret as an environment variable | ||
KURTOSIS_CLIENT_ID: ${{ secrets.kurtosis_client_id }} | ||
KURTOSIS_CLIENT_SECRET: ${{ secrets.kurtosis_client_secret }} | ||
DOCKER_USERNAME: ${{ secrets.docker_username }} | ||
DOCKER_PASS: ${{ secrets.docker_pass }} | ||
run: ./run_e2e_tests.sh | ||
|
||
- name: Publish image to DockerHub | ||
env: # Secret as an environment variable | ||
DOCKER_USERNAME: ${{ secrets.docker_username }} | ||
DOCKER_PASS: ${{ secrets.docker_pass }} | ||
run: .github/workflows/publish_image.sh |
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,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# Skip if this is not on the main public repo or | ||
# if this is not a trusted build (Docker Credentials are not set) | ||
#if [[ $TRAVIS_REPO_SLUG != "ava-labs/avalanchego" || -z "$DOCKER_USERNAME" ]]; then | ||
# exit 0; | ||
#fi | ||
|
||
# Directory above this script | ||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Load the versions | ||
source "$AVALANCHE_PATH"/scripts/versions.sh | ||
|
||
# Load the constants | ||
source "$AVALANCHE_PATH"/scripts/constants.sh | ||
|
||
echo "Path: $AVALANCHE_PATH" | ||
current_branch=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
if [[ $current_branch == "master" ]]; then | ||
echo "Tagging current avalanchego image as $dockerhub_repo:latest" | ||
docker_image=$dockerhub_repo:latest | ||
fi | ||
|
||
if [[ $current_branch == "dev" ]]; then | ||
echo "Tagging current avalanchego image as $dockerhub_repo:dev" | ||
docker_image=$dockerhub_repo:dev | ||
fi | ||
|
||
if [[ $current_branch != "" ]]; then | ||
echo "Tagging current avalanchego image as $dockerhub_repo:current_branch" | ||
docker_image=$dockerhub_repo:current_branch | ||
fi | ||
|
||
echo "Pushing: $docker_image" | ||
|
||
#echo "$DOCKER_PASS" | docker login --username "$DOCKER_USERNAME" --password-stdin | ||
# | ||
## pushing image with tags | ||
#docker push $docker_image |
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,56 @@ | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
root_dirpath="$(cd "$(dirname "${0}")" && cd ../../ && pwd)" | ||
kurtosis_core_dirpath="${root_dirpath}/.kurtosis" | ||
|
||
echo "root_dirpath: ${root_dirpath}" | ||
echo "kurtosis_core_dirpath: ${kurtosis_core_dirpath}" | ||
|
||
# Define avalanche byzantine version to use | ||
avalanche_byzantine_image="avaplatform/avalanche-byzantine:v0.2.0-rc.1" | ||
# Define avalanche testing version to use | ||
avalanche_testing_image="avaplatform/avalanche-testing:kurtosis_upgrade" | ||
|
||
# Fetch the images | ||
# If Docker Credentials are not available fail | ||
if [[ -z ${DOCKER_USERNAME} ]]; then | ||
echo "Skipping Byzantine Tests because Docker Credentials were not present." | ||
exit 1 | ||
else | ||
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USERNAME" --password-stdin | ||
docker pull ${avalanche_testing_image} | ||
docker pull ${avalanche_byzantine_image} | ||
fi | ||
|
||
# Setting the build ID | ||
GIT_COMMIT_ID=$( git rev-list -1 HEAD ) | ||
|
||
# Build current avalanchego | ||
"${root_dirpath}"/scripts/build_image.sh | ||
|
||
# Target built version to use in avalanche-testing | ||
# Todo hook this with the e2e matchup | ||
#avalanche_image_tag=$(docker image ls --format="{{.Tag}}" | head -n 1) | ||
avalanche_image_tag="dev" | ||
avalanche_image="avaplatform/avalanchego:${avalanche_image_tag}" | ||
|
||
echo "Running Avalanche Image: ${avalanche_image}" | ||
echo "Running Avalanche Image Tag: ${avalanche_image_tag}" | ||
echo "Running Avalanche Testing Image: ${avalanche_testing_image}" | ||
echo "Running Avalanche Byzantine Image: ${avalanche_byzantine_image}" | ||
echo "Git Commit ID : ${GIT_COMMIT_ID}" | ||
|
||
|
||
# >>>>>>>> avalanche-testing custom parameters <<<<<<<<<<<<< | ||
custom_params_json="{ | ||
\"isKurtosisCoreDevMode\": false, | ||
\"avalanchegoImage\":\"${avalanche_image}\", | ||
\"avalanchegoByzantineImage\":\"${avalanche_byzantine_image}\" | ||
}" | ||
# >>>>>>>> avalanche-testing custom parameters <<<<<<<<<<<<< | ||
|
||
bash "${kurtosis_core_dirpath}/kurtosis.sh" \ | ||
--custom-params "${custom_params_json}" \ | ||
"${avalanche_testing_image}" |
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,140 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# This script is intended to be wrapped with a thin script passing in testsuite-specific | ||
# variables (e.g. the name of the testsuite image) | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
set -euo pipefail | ||
|
||
# ====================== CONSTANTS ======================================================= | ||
BUILD_ACTION="build" | ||
RUN_ACTION="run" | ||
BOTH_ACTION="all" | ||
HELP_ACTION="help" | ||
|
||
# ====================== ARG PARSING ======================================================= | ||
show_help_and_exit() { | ||
echo "$(basename ${0}) action suite_image_name repo_dirpath dockerfile_filepath [run_arg1] [run_arg2]..." | ||
echo "" | ||
echo " This script will optionally a) build your Kurtosis testsuite into a Docker image and/or b) run it via a call to the kurtosis.sh script" | ||
echo "" | ||
echo " action Determines the action this script will execute ('${HELP_ACTION}' to print this message, '${BUILD_ACTION}' to only build the testsuite" | ||
echo " image, '${RUN_ACTION}' to just run the testsuite image, and '${BOTH_ACTION}' to both build and run the testsuite)" | ||
echo " suite_image The name to give the built Docker image containing the testsuite" | ||
echo " repo_dirpath Path to the root of the repo containing the testsuite to build" | ||
echo " dockerfile_filepath Filepath to the Dockerfile for building the testsuite Docker image" | ||
echo " wrapper_filepath Filepath to the kurtosis.sh wrapper script" | ||
echo " run_arg Argument to pass to kurtosis.sh when running the testsuite (use '--help' here to see all options)" | ||
echo "" | ||
echo " To see the args the kurtosis.sh script accepts for the 'run' phase, call '$(basename ${0}) all --help'" | ||
echo "" | ||
exit 1 # Exit with error code so we dont't get spurious CI passes | ||
} | ||
|
||
if [ "${#}" -lt 5 ]; then | ||
show_help_and_exit | ||
fi | ||
|
||
action="${1:-}" | ||
shift 1 | ||
|
||
suite_image="${1:-}" | ||
shift 1 | ||
|
||
repo_dirpath="${1:-}" | ||
shift 1 | ||
|
||
dockerfile_filepath="${1:-}" | ||
shift 1 | ||
|
||
wrapper_filepath="${1:-}" | ||
shift 1 | ||
|
||
do_build=true | ||
do_run=true | ||
case "${action}" in | ||
${HELP_ACTION}) | ||
show_help_and_exit | ||
;; | ||
${BUILD_ACTION}) | ||
do_build=true | ||
do_run=false | ||
;; | ||
${RUN_ACTION}) | ||
do_build=false | ||
do_run=true | ||
;; | ||
${BOTH_ACTION}) | ||
do_build=true | ||
do_run=true | ||
;; | ||
*) | ||
echo "Error: Action argument must be one of '${HELP_ACTION}', '${BUILD_ACTION}', '${RUN_ACTION}', or '${BOTH_ACTION}'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# ====================== ARG VALIDATION =================================================== | ||
if [ -z "${suite_image}" ]; then | ||
echo "Error: Suite image name cannot be empty" >&2 | ||
exit 1 | ||
fi | ||
if [ -z "${repo_dirpath}" ]; then | ||
echo "Error: Repo dirpath cannot be empty" >&2 | ||
exit 1 | ||
fi | ||
if ! [ -d "${repo_dirpath}" ]; then | ||
echo "Error: Repo dirpath '${repo_dirpath}' is not a directory" >&2 | ||
exit 1 | ||
fi | ||
if [ -z "${dockerfile_filepath}" ]; then | ||
echo "Error: Dockerfile filepath cannot be empty" >&2 | ||
exit 1 | ||
fi | ||
if ! [ -f "${dockerfile_filepath}" ]; then | ||
echo "Error: Dockerfile filepath '${dockerfile_filepath}' is not a file" >&2 | ||
exit 1 | ||
fi | ||
if [ -z "${wrapper_filepath}" ]; then | ||
echo "Error: Wrapper filepath cannot be empty" >&2 | ||
exit 1 | ||
fi | ||
if ! [ -f "${wrapper_filepath}" ]; then | ||
echo "Error: Wrapper filepath '${dockerfile_filepath}' is not a file" >&2 | ||
exit 1 | ||
fi | ||
|
||
# ====================== MAIN LOGIC ======================================================= | ||
# Captures the first of tag > branch > commit | ||
git_ref="$(cd "${repo_dirpath}" && git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)" | ||
if [ "${git_ref}" == "" ]; then | ||
echo "Error: Could not determine a Git ref to use for the Docker tag; is the repo a Git directory?" >&2 | ||
exit 1 | ||
fi | ||
|
||
docker_tag="$(echo "${git_ref}" | sed 's,[/:],_,g')" | ||
if [ "${docker_tag}" == "" ]; then | ||
echo "Error: Sanitizing Git ref to get a Docker tag for the testsuite yielded an empty string" >&2 | ||
exit 1 | ||
fi | ||
|
||
if "${do_build}"; then | ||
if ! [ -f "${repo_dirpath}"/.dockerignore ]; then | ||
echo "Error: No .dockerignore file found in root of repo '${repo_dirpath}'; this is required so Docker caching is enabled and your testsuite builds remain quick" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Building '${suite_image}' Docker image..." | ||
if ! docker build -t "${suite_image}:${docker_tag}" -f "${dockerfile_filepath}" "${repo_dirpath}"; then | ||
echo "Error: Docker build of the testsuite failed" >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if "${do_run}"; then | ||
# The funky ${1+"${@}"} incantation is how you you feed arguments exactly as-is to a child script in Bash | ||
# ${*} loses quoting and ${@} trips set -e if no arguments are passed, so this incantation says, "if and only if | ||
# ${1} exists, evaluate ${@}" | ||
if ! bash "${wrapper_filepath}" ${1+"${@}"} "${suite_image}:${docker_tag}"; then | ||
echo "Error: Testsuite execution failed" | ||
exit 1 | ||
fi | ||
fi |
Oops, something went wrong.