Skip to content

Commit

Permalink
Parallel tests (#234)
Browse files Browse the repository at this point in the history
* Tidy up tests and logfiles

* Split off prebuild from tests

* Try running tests in parallel

* Add typechain bindings

* Dont run all tests in prebuild
  • Loading branch information
ryardley authored Dec 31, 2024
1 parent 72e4a57 commit 55c4f66
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 28 deletions.
84 changes: 64 additions & 20 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
name: "INTEGRATION"

env:
HARDHAT_VAR_MNEMONIC: "test test test test test test test test test test test junk"
HARDHAT_VAR_INFURA_API_KEY: "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# Uncomment the following lines to set your configuration variables using
# GitHub secrets (https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)
#
# HARDHAT_VAR_MNEMONIC: ${{ secrets.Mnemonic }}
# HARDHAT_VAR_INFURA_API_KEY: ${{ secrets.InfuraApiKey }}
# HARDHAT_VAR_ARBISCAN_API_KEY: ${{ secrets.ArbiscanApiKey }}
# HARDHAT_VAR_BSCSCAN_API_KEY: ${{ secrets.BscscanApiKey }}
# HARDHAT_VAR_ETHERSCAN_API_KEY: ${{ secrets.EtherscanApiKey }}
# HARDHAT_VAR_OPTIMISM_API_KEY: ${{ secrets.OptimismApiKey }}
# HARDHAT_VAR_POLYGONSCAN_API_KEY: ${{ secrets.PolygonscanApiKey }}
# HARDHAT_VAR_SNOWTRACE_API_KEY: ${{ secrets.SnowtraceApiKey }}

on:
workflow_dispatch:
Expand All @@ -24,17 +12,17 @@ on:
- main

jobs:
ci:
prebuild:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Setup node"
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install Rust 1.81.0
uses: actions-rs/toolchain@v1
with:
Expand All @@ -46,10 +34,10 @@ jobs:
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: "Install the dependencies"
run: "yarn install"

- name: "Lint the code"
run: "yarn lint"

Expand All @@ -61,10 +49,66 @@ jobs:
- name: "Compile the contracts and generate the TypeChain bindings"
run: "yarn typechain"

- name: "Test the contracts and generate the coverage report"
run: "yarn test:integration"
- name: "Run prebuild"
run: "yarn test:integration prebuild"

- name: "Upload build artifacts"
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
packages/ciphernode/target/debug/enclave
packages/ciphernode/target/debug/fake_encrypt
packages/ciphernode/target/debug/pack_e3_params
test:
needs: prebuild
runs-on: "ubuntu-latest"
strategy:
matrix:
test-suite: [base, persist, net]
fail-fast: false

steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Setup node"
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install Rust 1.81.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81.0
override: true

- name: Cache node modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: "Install the dependencies"
run: "yarn install"

- name: "Download build artifacts"
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: packages/ciphernode/target/debug/

- name: "Set executable permissions"
run: |
chmod +x packages/ciphernode/target/debug/enclave
chmod +x packages/ciphernode/target/debug/fake_encrypt
chmod +x packages/ciphernode/target/debug/pack_e3_params
- name: "Run ${{ matrix.test-suite }} tests"
run: "yarn test:integration ${{ matrix.test-suite }} --no-prebuild"

- name: "Add test summary"
run: |
echo "## Test results" >> $GITHUB_STEP_SUMMARY
echo "## Test results for ${{ matrix.test-suite }}" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "yarn evm:lint",
"typechain": "yarn evm:typechain",
"test": "yarn evm:test && yarn ciphernode:test",
"test:integration": "./tests/basic_integration/test.sh",
"test:integration": "./tests/integration/test.sh",
"coverage": "yarn evm:coverage",
"enclave": "cd packages/ciphernode && ./scripts/launch.sh",
"ciphernode:lint": "cd packages/ciphernode && cargo fmt -- --check",
Expand Down
3 changes: 0 additions & 3 deletions tests/basic_integration/lib/pack_e3_params.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions tests/basic_integration/fns.sh → tests/integration/fns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ heading() {
echo ""
}

strip_ansi() {
sed 's/\x1b\[[0-9;]*m//g'
}

waiton() {
local file_path="$1"
until [ -f "$file_path" ]; do
Expand Down Expand Up @@ -102,7 +106,7 @@ launch_ciphernode() {
mkdir -p "$log_dir"
$ENCLAVE_BIN start -v \
--tag "$name" \
--config "$SCRIPT_DIR/lib/$name/config.yaml" 2>&1 | tee "$log_file" & echo $! > "/tmp/enclave.${ID}_${name}.pid"
--config "$SCRIPT_DIR/lib/$name/config.yaml" 2>&1 | tee >(strip_ansi > "$log_file") & echo $! > "/tmp/enclave.${ID}_${name}.pid"
}

set_private_key() {
Expand Down Expand Up @@ -136,7 +140,7 @@ launch_aggregator() {
--tag "$name" \
--config "$SCRIPT_DIR/lib/$name/config.yaml" \
--pubkey-write-path "$SCRIPT_DIR/output/pubkey.bin" \
--plaintext-write-path "$SCRIPT_DIR/output/plaintext.txt" 2>&1 | tee "$log_file" & echo $! > "/tmp/enclave.${ID}_${name}.pid"
--plaintext-write-path "$SCRIPT_DIR/output/plaintext.txt" 2>&1 | tee >(strip_ansi > "$log_file") & echo $! > "/tmp/enclave.${ID}_${name}.pid"
}

kill_proc() {
Expand Down Expand Up @@ -165,6 +169,5 @@ metallica
trap 'cleanup $?' ERR INT TERM

$SCRIPT_DIR/lib/clean_folders.sh "$SCRIPT_DIR"
$SCRIPT_DIR/lib/prebuild.sh


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/integration/lib/pack_e3_params.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

./packages/ciphernode/target/debug/pack_e3_params "$@"
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/usr/bin/env sh

echo ""
echo "PREBUILDING BINARIES..."
echo ""
cd packages/ciphernode && cargo build --bin fake_encrypt --bin enclave --bin pack_e3_params;
echo ""
echo "FINISHED PREBUILDING BINARIES"
echo ""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/integration/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#!/usr/bin/env bash

set -eu # Exit immediately if a command exits with a non-zero status

# This script deliberately does nothing as prebuild has been managed by the outer process
# See test.sh
#
echo "Prebuild finished"
4 changes: 4 additions & 0 deletions tests/basic_integration/test.sh → tests/integration/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set -eu # Exit immediately if a command exits with a non-zero status

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [[ "$*" != *"--no-prebuild"* ]]; then
"$THIS_DIR/lib/prebuild.sh"
fi

if [ $# -eq 0 ]; then
"$THIS_DIR/persist.sh"
"$THIS_DIR/base.sh"
Expand Down

0 comments on commit 55c4f66

Please sign in to comment.