From 388b21660db9a20017cd634c74ca105b37260f9a Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 29 Apr 2024 17:19:22 -0600 Subject: [PATCH] Add CI test --- .gitea/workflows/fixturenet-eth-stack.yml | 38 ++++++++++++++ README.md | 2 +- scripts/install-so.sh | 5 ++ tests/fixturenet-eth-stack/run-test.sh | 63 +++++++++++++++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/fixturenet-eth-stack.yml create mode 100755 scripts/install-so.sh create mode 100755 tests/fixturenet-eth-stack/run-test.sh diff --git a/.gitea/workflows/fixturenet-eth-stack.yml b/.gitea/workflows/fixturenet-eth-stack.yml new file mode 100644 index 0000000..7f71d9b --- /dev/null +++ b/.gitea/workflows/fixturenet-eth-stack.yml @@ -0,0 +1,38 @@ +name: Ethereum Fixturenet Stack Test + +on: + pull_request: + branches: '*' + push: + branches: + - main + - ci-test + - add-tests + +jobs: + test: + name: "Run Ethereum Fixturenet stack test" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + # At present the stock setup-python action fails on Linux/aarch64 + # Conditional steps below workaroud this by using deadsnakes for that case only + - name: "Install Python for ARM on Linux" + if: ${{ runner.arch == 'arm64' && runner.os == 'Linux' }} + uses: deadsnakes/action@v3.0.1 + with: + python-version: '3.8' + - name: "Install Python cases other than ARM on Linux" + if: ${{ ! (runner.arch == 'arm64' && runner.os == 'Linux') }} + uses: actions/setup-python@v4 + with: + python-version: '3.8' + - name: "Print Python version" + run: python3 --version + - name: "Install stack orchestrator" + run: ./scripts/install-so.sh + - name: "Run stack tests" + run: | + PATH=$PATH:~/bin + ./tests/fixturenet-eth-stack/run-test.sh diff --git a/README.md b/README.md index 6117e17..8d06514 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Experimental external packaging of the Ethereum fixturenet stack. -[stack documentation](stacks/fixturenet-eth/README.md) +[stack documentation](stack-orchestrator/stacks/fixturenet-eth/README.md) diff --git a/scripts/install-so.sh b/scripts/install-so.sh new file mode 100755 index 0000000..87000a8 --- /dev/null +++ b/scripts/install-so.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +mkdir ~/bin +curl -L -o ~/bin/laconic-so https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so +chmod +x ~/bin/laconic-so + diff --git a/tests/fixturenet-eth-stack/run-test.sh b/tests/fixturenet-eth-stack/run-test.sh new file mode 100755 index 0000000..749d5ef --- /dev/null +++ b/tests/fixturenet-eth-stack/run-test.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +SO_COMMAND=laconic-so + +test_name="Fixturenet eth stack deploy test" +echo "Running ${test_name}" + +stack_name=$(pwd)/stack-orchestrator/stacks/fixturenet-eth + +test_fail_exit () { + local fail_message=$1 + echo "${test_name}: ${fail_message}" + echo "${test_name}: FAILED" + exit 1 +} + +# Sanity check the stack dir exists +if [ ! -d "${stack_name}" ]; then + test_fail_exit "stack directory not present" + exit 1 +fi + +# Set a non-default repo dir +export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir +reported_version_string=$( $SO_COMMAND version ) +echo "SO version is: ${reported_version_string}" +echo "Cloning repositories into: $CERC_REPO_BASE_DIR" +rm -rf $CERC_REPO_BASE_DIR +mkdir -p $CERC_REPO_BASE_DIR + +$SO_COMMAND --stack ${stack_name} setup-repositories + +echo "Building containers" +$SO_COMMAND --stack ${stack_name} build-containers + +test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir +test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml + +$SO_COMMAND --stack ${stack_name} deploy init --output $test_deployment_spec +# Check the file now exists +if [ ! -f "$test_deployment_spec" ]; then + test_fail_exit "deploy init test: spec fille not present" +fi +echo "deploy init test: passed" + +$SO_COMMAND --stack ${stack_name} deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir +# Check the deployment dir exists +if [ ! -d "$test_deployment_dir" ]; then + test_fail_exit "deploy create test: deployment directory not present" +fi +echo "deploy create test: passed" + +$SO_COMMAND deployment --dir $test_deployment_dir start + +sleep 30 + +$SO_COMMAND deployment --dir $test_deployment_dir stop + +echo "${test_name}: PASSED"