diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9c43ebb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Docker file for testing provwasm +FROM golang:1.17-buster as build +RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libleveldb-dev +RUN apt-get install -y unzip + +COPY --chown=0:0 ./scripts/setup_provenance.sh /setup_provenance.sh + +# install jq for parsing output of queries when running Provenance +RUN curl -o /usr/local/bin/jq http://stedolan.github.io/jq/download/linux64/jq && \ + chmod +x /usr/local/bin/jq + +# Initialize provenance to run with the default node configuration +ENTRYPOINT ["/setup_provenance.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..eb8cddd --- /dev/null +++ b/action.yml @@ -0,0 +1,17 @@ +# action.yml +name: 'Provenance Test' +description: 'Action to test Provenance' +inputs: + provenance_version: # version of Provenance + description: 'Version of Provenance to test against' + required: true + default: 'v1.8.0' + test_script: + description: 'Script used to run tests after provenance has been setup and is running' + required: true +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.test_script }} + - ${{ inputs.provenance_version }} \ No newline at end of file diff --git a/scripts/setup_provenance.sh b/scripts/setup_provenance.sh new file mode 100644 index 0000000..b5859dd --- /dev/null +++ b/scripts/setup_provenance.sh @@ -0,0 +1,45 @@ +#!/bin/bash -e + +# This script setups up Provenance and then runs a script it receives as an argument to do various tests afterwards + +Provenance_Version=$2 + +wget "https://github.com/provenance-io/provenance/releases/download/$Provenance_Version/provenance-linux-amd64-$Provenance_Version.zip" + +# this will create a folder with both provenance and libwasm +unzip "provenance-linux-amd64-$Provenance_Version.zip" + +mkdir ./build + +PROV_CMD="./bin/provenanced" +PIO_HOME="./build" +export PIO_HOME + +if [ ! -d "$PIO_HOME/config" ]; then + "$PROV_CMD" -t init --chain-id=testing testing + "$PROV_CMD" -t keys add validator --keyring-backend test + "$PROV_CMD" -t add-genesis-root-name validator pio --keyring-backend test + "$PROV_CMD" -t add-genesis-root-name validator pb --restrict=false \ + --keyring-backend test + "$PROV_CMD" -t add-genesis-root-name validator io --restrict \ + --keyring-backend test + "$PROV_CMD" -t add-genesis-root-name validator provenance \ + --keyring-backend test + "$PROV_CMD" -t add-genesis-account validator 100000000000000000000nhash \ + --keyring-backend test + "$PROV_CMD" -t gentx validator 1000000000000000nhash \ + --keyring-backend test --chain-id=testing + "$PROV_CMD" -t add-genesis-marker 100000000000000000000nhash --manager \ + validator --access mint,burn,admin,withdraw,deposit \ + --activate --keyring-backend test + "$PROV_CMD" -t collect-gentxs +fi +nohup "$PROV_CMD" -t start &>/dev/null & + +echo "Sleeping for provenance to start up" +sleep 10s + +# execute the script test that was passed in as an argument +echo "Executing test..." +"$1" +echo "Test complete" \ No newline at end of file