Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Testool migration (#1540)
Browse files Browse the repository at this point in the history
### 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

#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 <[email protected]>
  • Loading branch information
ntampakas and ChihChengLiang committed Jul 24, 2023
1 parent b7c8a06 commit 6e69b9a
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/testoolScripts/build.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .github/testoolScripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/testoolScripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/testoolScripts/run.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/testoolScripts/sync.sh
Original file line number Diff line number Diff line change
@@ -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 "<a href=\"$i\">$i</a> <br>" >> index.html; done

aws s3 sync . s3://testool-public/

exit 0
23 changes: 23 additions & 0 deletions .github/testoolScripts/wakeUpRunner.sh
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/workflows/testool.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6e69b9a

Please sign in to comment.