From 6e69b9a4c4fd73d10fa0f23a204b31de69280bef Mon Sep 17 00:00:00 2001 From: ntampakas Date: Mon, 24 Jul 2023 16:26:45 +0300 Subject: [PATCH] Testool migration (#1540) ### Description This PR introduces testool nightly builds in GH Actions. The workflow can also be triggered manually selecting between light and nightly suites. The reports are public now under: http://testool-public.s3-website.eu-central-1.amazonaws.com/ ### Issue Link https://github.com/privacy-scaling-explorations/zkevm-circuits/issues/1505 ### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### How Has This Been Tested? Executed manually and automatically the workflow, triggering both suites. --------- Co-authored-by: Chih Cheng Liang --- .github/testoolScripts/build.sh | 15 ++++++++ .github/testoolScripts/cleanup.sh | 13 +++++++ .github/testoolScripts/prepare.sh | 18 +++++++++ .github/testoolScripts/run.sh | 17 +++++++++ .github/testoolScripts/sync.sh | 16 ++++++++ .github/testoolScripts/wakeUpRunner.sh | 23 +++++++++++ .github/workflows/testool.yml | 53 ++++++++++++++++++++++++++ 7 files changed, 155 insertions(+) create mode 100755 .github/testoolScripts/build.sh create mode 100755 .github/testoolScripts/cleanup.sh create mode 100755 .github/testoolScripts/prepare.sh create mode 100755 .github/testoolScripts/run.sh create mode 100755 .github/testoolScripts/sync.sh create mode 100755 .github/testoolScripts/wakeUpRunner.sh create mode 100644 .github/workflows/testool.yml diff --git a/.github/testoolScripts/build.sh b/.github/testoolScripts/build.sh new file mode 100755 index 0000000000..ce66b95566 --- /dev/null +++ b/.github/testoolScripts/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -x + +export PATH=/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/snap/bin:/usr/local/go/bin/ + +error() { + sudo poweroff +} + +trap 'error' ERR + +cd zkevm-circuits/testool +git submodule update --init --recursive ; git submodule update --checkout ; cargo build --release + +exit 0 diff --git a/.github/testoolScripts/cleanup.sh b/.github/testoolScripts/cleanup.sh new file mode 100755 index 0000000000..a503363652 --- /dev/null +++ b/.github/testoolScripts/cleanup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +profile="cirunner" +runner_vpc_id="vpc-05dedcb650bd24f8d" + +# Get runner status +runner=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[testool] Name=network-interface.vpc-id,Values=[$runner_vpc_id] --query "Reservations[*].Instances[*][InstanceId]" --output text | xargs) + +echo "Reports: http://testool-public.s3-website.eu-central-1.amazonaws.com" +echo "Shuting down instance..." +aws ec2 stop-instances --profile $profile --instance-ids $runner + +exit 0 diff --git a/.github/testoolScripts/prepare.sh b/.github/testoolScripts/prepare.sh new file mode 100755 index 0000000000..1a42bed3bb --- /dev/null +++ b/.github/testoolScripts/prepare.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -x + +error() { + sudo poweroff +} + +trap 'error' ERR + +branch=$1 + +rm -rf zkevm-circuits +git clone https://github.com/privacy-scaling-explorations/zkevm-circuits.git +cd zkevm-circuits/testool +git checkout $branch +ln -s /home/ubuntu/report report + +exit 0 diff --git a/.github/testoolScripts/run.sh b/.github/testoolScripts/run.sh new file mode 100755 index 0000000000..7145ed689f --- /dev/null +++ b/.github/testoolScripts/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -x + +export PATH=/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/snap/bin:/usr/local/go/bin/ + +error() { + sudo poweroff +} + +trap 'error' ERR + +suite=$1 + +cd zkevm-circuits/testool +../target/release/testool --suite $suite --report + +exit 0 diff --git a/.github/testoolScripts/sync.sh b/.github/testoolScripts/sync.sh new file mode 100755 index 0000000000..3289c55429 --- /dev/null +++ b/.github/testoolScripts/sync.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -x + +error() { + sudo poweroff +} + +trap 'error' ERR + +cd report +rm index.html +for i in `ls -t *.html`; do echo "$i
" >> index.html; done + +aws s3 sync . s3://testool-public/ + +exit 0 diff --git a/.github/testoolScripts/wakeUpRunner.sh b/.github/testoolScripts/wakeUpRunner.sh new file mode 100755 index 0000000000..bfee5ac480 --- /dev/null +++ b/.github/testoolScripts/wakeUpRunner.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +profile="cirunner" +runner_vpc_id="vpc-05dedcb650bd24f8d" + +# Get runner status +runner=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[testool] Name=network-interface.vpc-id,Values=[$runner_vpc_id] --query "Reservations[*].Instances[*][InstanceId]" --output text | xargs) + +while true; do + runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner --query "Reservations[*].Instances[*].State.[Name]" --output text) + if [ $runner_status = "stopped" ]; then + aws ec2 start-instances --profile $profile --instance-ids $runner + exit 0 + elif [ $runner_status = "running" ]; then + sleep 120 + runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner --query "Reservations[*].Instances[*].State.[Name]" --output text) + if [ $runner_status = "running" ]; then + exit 0 + fi + else + sleep 30 + fi +done diff --git a/.github/workflows/testool.yml b/.github/workflows/testool.yml new file mode 100644 index 0000000000..bab404b080 --- /dev/null +++ b/.github/workflows/testool.yml @@ -0,0 +1,53 @@ +name: Testool + +on: + schedule: + - cron: '30 23 * * *' + workflow_dispatch: + inputs: + suites: + description: "Suites" + required: true + default: "light" + type: choice + options: + - light + - nightly + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + testool: + if: github.event.pull_request.draft == false + + name: Testool + runs-on: [pse-runner] + env: + DATA: ${{ github.event.inputs.suites || 'nightly' }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: Wakeup testool + run: .github/testoolScripts/wakeUpRunner.sh + + - name: Prepare repo + run: ssh testool "bash -s" -- < .github/testoolScripts/prepare.sh "$GITHUB_REF_NAME" + + - name: Cargo build + run: ssh testool "bash -s" -- < .github/testoolScripts/build.sh + + - name: Run tests + run: ssh testool "bash -s" -- < .github/testoolScripts/run.sh ${{ env.DATA }} + + - name: Sync reports + run: ssh testool "bash -s" -- < .github/testoolScripts/sync.sh + + - name: Cleanup + run: .github/testoolScripts/cleanup.sh +