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

Commit

Permalink
Adds weekly benchmarks, tencent test run
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofpaliga committed Aug 11, 2023
1 parent 3620c07 commit 74a6be5
Show file tree
Hide file tree
Showing 26 changed files with 1,009 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/cloudRun/cloud-tests-local-trigger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
cd "$(dirname "$0")" || exit 1

GITHUB_RUN_ID=$1
BRANCH_NAME=$2

PROVER_INSTANCE=$(cat "$HOME/CI_Github_Trigger/$GITHUB_RUN_ID/prover_instance")
echo "Prover instance at trigger: $PROVER_INSTANCE"

export PROVER_IP=$(tccli cvm DescribeInstances --InstanceIds "[\"$PROVER_INSTANCE\"]" | grep -A 1 PublicIpAddress | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
echo "Prover IP: $PROVER_IP"

rm ~/.ssh/known_hosts*

prepare_env() {
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- <../weeklyBenchScripts/00_installGo.sh
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- <../weeklyBenchScripts/00_installRust.sh
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- <../weeklyBenchScripts/01_installDeps.sh
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- <../weeklyBenchScripts/02_setup.sh
}

prepare_repo() {
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- "$GITHUB_RUN_ID" <../weeklyBenchScripts/03_prepareProver.sh
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- "$GITHUB_RUN_ID" "$BRANCH_NAME" <../weeklyBenchScripts/04_clone.sh
ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- "$GITHUB_RUN_ID" <../weeklyBenchScripts/05_build.sh

}

prepare_env
prepare_repo

ssh -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP "bash -s" -- "$GITHUB_RUN_ID" <run.sh
scp -i ~/.ssh/bench.pem -o StrictHostKeyChecking=no ubuntu@$PROVER_IP:"$HOME"/CI_Prover_Benches/"$GITHUB_RUN_ID"/run_result ../../../
RESULT=$(cat ../../../run_result)
echo "exiting cloud-tests-local-trigger with RESULT $RESULT"
exit $RESULT
35 changes: 35 additions & 0 deletions .github/cloudRun/cloud-tests-trigger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
GITHUB_RUN_ID=$1
BRANCH_NAME=$2

ensure_git_installed() {
if ! command -v git &>/dev/null; then
echo "Git is not installed. Installing..."
sudo apt update
sudo apt install -y git
else
echo "Git is already installed."
fi
}

ensure_git_installed

clone_zkevm-circuits() {
git clone -q https://github.com/taikoxyz/zkevm-circuits.git
cd zkevm-circuits || exit 1
git checkout $BRANCH_NAME
echo "Cloned zkevm-circuits"
}

directory_name="$HOME/CI_Github_Trigger/$GITHUB_RUN_ID"
cd $directory_name || exit 1


clone_zkevm-circuits

cd .github/cloudRun || exit 1
chmod u+x cloud-tests-local-trigger.sh
./cloud-tests-local-trigger.sh $GITHUB_RUN_ID $BRANCH_NAME
RESULT=$?
echo "exiting cloud-tests-trigger with result $RESULT"
exit $RESULT
6 changes: 6 additions & 0 deletions .github/cloudRun/github-action-trigger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sshpass -p $BENCH_RESULTS_PASS ssh -o StrictHostKeyChecking=no [email protected] "bash -s" -- "$GITHUB_RUN_ID" "$BRANCH_NAME" <cloud-tests-trigger.sh
RESULT=$?
echo "exiting github-action-trigger with RESULT=$RESULT"
exit $RESULT
20 changes: 20 additions & 0 deletions .github/cloudRun/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
GITHUB_RUN_ID=$1
export GOROOT="/usr/local/go"
export GOPATH="$HOME/go"
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH:$HOME/.cargo/bin/"

# Get the latest temp directory in the home directory
current_dir="$HOME"/CI_Prover_Benches/"$GITHUB_RUN_ID"

target_dir="$current_dir/zkevm-circuits"

cd $target_dir || exit 1

# ENTER YOUR TEST COMMAND BELOW
make test-all
# ENTER YOUR TEST COMMAND ABOVE

RESULT=$?
echo $RESULT > ../run_result
echo "exiting run.sh with RESULT $RESULT"
38 changes: 38 additions & 0 deletions .github/weeklyBenchScripts/00_installGo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Check if Go is already installed
if command -v go &>/dev/null; then
echo "Go is already installed."
else
# Set the Go version to be installed (latest as of current date)
GO_VERSION="1.19.1"

# Determine the architecture
ARCH="amd64"

# Download and extract the Go archive
wget -q "https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz"
sudo tar -C /usr/local -xzf "go$GO_VERSION.linux-$ARCH.tar.gz"

# Set Go environment variables
export GOROOT="/usr/local/go"
export GOPATH="$HOME/go"
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"

# Append Go environment variables to the shell profile
echo 'export GOROOT="/usr/local/go"' >> "$HOME/.bashrc"
echo 'export GOPATH="$HOME/go"' >> "$HOME/.bashrc"
echo 'export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"' >> "$HOME/.bashrc"

# Refresh the shell session to make Go available
source "$HOME/.bashrc"

# Cleanup the downloaded archive
rm "go$GO_VERSION.linux-$ARCH.tar.gz"

echo "Go $GO_VERSION has been installed successfully."
fi

# Display the installed Go version
go version

24 changes: 24 additions & 0 deletions .github/weeklyBenchScripts/00_installRust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Check if rustup is already installed
if ! command -v rustup &>/dev/null; then
echo "Installing rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
else
echo "rustup is already installed. Checking for updates..."
rustup update
fi

# Install the latest version of Rust
echo "Installing the latest version of Rust..."
rustup install stable

# Set the latest version as the default
rustup default stable

# Print the installed Rust version
echo "Rust has been installed successfully. Current version:"
rustc --version
cargo --version

62 changes: 62 additions & 0 deletions .github/weeklyBenchScripts/01_installDeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
sudo apt update

# Check if Git is already installed
if command -v git &>/dev/null; then
echo "Git is already installed."
else
# Detect the Linux distribution and install Git
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID == "ubuntu" || $ID == "debian" ]]; then
sudo apt install -y git
elif [[ $ID == "centos" || $ID == "rhel" ]]; then
sudo yum install -y git
elif [[ $ID == "fedora" ]]; then
sudo dnf install -y git
else
echo "Unsupported Linux distribution. Please install Git manually."
exit 1
fi
else
echo "Cannot determine the Linux distribution. Please install Git manually."
exit 1
fi

# Verify Git installation
if command -v git &>/dev/null; then
echo "Git has been installed successfully."
else
echo "Failed to install Git. Please install it manually."
fi
fi

# Check if the C compiler is installed
if ! command -v cc &>/dev/null; then
# Detect the Linux distribution and install the C compiler
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID == "ubuntu" || $ID == "debian" ]]; then
sudo apt install -y build-essential
elif [[ $ID == "centos" || $ID == "rhel" ]]; then
sudo yum groupinstall -y "Development Tools"
elif [[ $ID == "fedora" ]]; then
sudo dnf groupinstall -y "Development Tools"
else
echo "Unsupported Linux distribution. Please install the C compiler manually."
exit 1
fi
else
echo "Cannot determine the Linux distribution. Please install the C compiler manually."
exit 1
fi

# Verify C compiler installation
if command -v cc &>/dev/null; then
echo "The C compiler has been installed successfully."
else
echo "Failed to install the C compiler. Please install it manually."
fi
fi

sudo apt install -y pkg-config fontconfig libfontconfig-dev
48 changes: 48 additions & 0 deletions .github/weeklyBenchScripts/02_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Function to check if sysstat is installed
check_sysstat_installed() {
if command -v sar &>/dev/null; then
echo "sysstat is already installed."
return 0
else
echo "sysstat is not installed."
return 1
fi
}

# Function to install sysstat
install_sysstat() {
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID == "ubuntu" || $ID == "debian" ]]; then
sudo apt update
sudo apt install -y sysstat
elif [[ $ID == "centos" || $ID == "rhel" ]]; then
sudo yum install -y sysstat
else
echo "Unsupported operating system. Please install sysstat manually."
exit 1
fi
else
echo "Cannot determine the operating system. Please install sysstat manually."
exit 1
fi
}

# Function to enable sysstat service
enable_sysstat_service() {
sudo systemctl enable sysstat
sudo systemctl start sysstat
echo "sysstat service has been enabled and started."
}

# Main script
sudo timedatectl set-timezone UTC
check_sysstat_installed
if [[ $? -ne 0 ]]; then
install_sysstat
fi

enable_sysstat_service

16 changes: 16 additions & 0 deletions .github/weeklyBenchScripts/03_prepareProver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

GITHUB_RUN_ID=$1

# Set up the directory name with the timestamp
directory_name="CI_Prover_Benches/$GITHUB_RUN_ID"

# Set up the full path for the directory in the home directory
directory_path="$HOME/$directory_name"

# Create the directory
if [ ! -d "$directory_path" ]; then
mkdir -p "$directory_path"
echo "Directory '$directory_name' with GITHUB_RUN_ID '$GITHUB_RUN_ID' has been created in the home directory."
fi

22 changes: 22 additions & 0 deletions .github/weeklyBenchScripts/04_clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

GITHUB_RUN_ID=$1

# Get the latest temp directory in the home directory
current_dir="$HOME"/CI_Prover_Benches/"$GITHUB_RUN_ID"
target_dir="$current_dir"/zkevm-circuits

if [ ! -d "$target_dir" ]; then
# Clone the repository into the latest temp directory
echo "Cloning the repository into the latest temp directory: $current_dir"
git clone -q https://github.com/taikoxyz/zkevm-circuits.git "$current_dir/zkevm-circuits"

if [ -n "$BRANCH_NAME" ]; then
old_dir=$(pwd)
cd "$current_dir/zkevm-circuits" || exit 1
git checkout "$BRANCH_NAME"
cd "$old_dir" || exit 1
fi
# Print a message to indicate successful cloning
echo "Repository cloned successfully into: $current_dir/zkevm-circuits"
fi
19 changes: 19 additions & 0 deletions .github/weeklyBenchScripts/05_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
GITHUB_RUN_ID=$1

export GOROOT="/usr/local/go"
export GOPATH="$HOME/go"
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"

# Get the latest temp directory in the home directory
current_dir="$HOME"/CI_Prover_Benches/"$GITHUB_RUN_ID"

if [ -z "$current_dir" ]; then
echo "No temp directory found starting with 'CI_Prover_Benches__' in the home directory."
exit 1
fi

echo "Building zkevm-circuits inside: $current_dir"
cd "$current_dir/zkevm-circuits" || exit 1
~/.cargo/bin/cargo build -q

11 changes: 11 additions & 0 deletions .github/weeklyBenchScripts/06_rsSysstat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#set -e
#set -x
echo "Killing sadc"
sudo pkill sadc
echo "Cleaning /var/log/sysstat"
sudo rm -rf /var/log/sysstat/*
echo "Running sadc"
nohup sudo /usr/lib/sysstat/sadc -S ALL 10 604800 /var/log/sysstat/ &
disown

Loading

0 comments on commit 74a6be5

Please sign in to comment.