diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0861cc5c..9e4f72ec 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -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: @@ -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: @@ -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" @@ -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 diff --git a/package.json b/package.json index 1e3167ff..196ff0ad 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/basic_integration/lib/pack_e3_params.sh b/tests/basic_integration/lib/pack_e3_params.sh deleted file mode 100755 index 78502e2e..00000000 --- a/tests/basic_integration/lib/pack_e3_params.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -cd packages/ciphernode && RUSTFLAGS="-A warnings" cargo run --bin pack_e3_params -- "$@" diff --git a/tests/basic_integration/README.md b/tests/integration/README.md similarity index 100% rename from tests/basic_integration/README.md rename to tests/integration/README.md diff --git a/tests/basic_integration/base.sh b/tests/integration/base.sh similarity index 100% rename from tests/basic_integration/base.sh rename to tests/integration/base.sh diff --git a/tests/basic_integration/fns.sh b/tests/integration/fns.sh similarity index 94% rename from tests/basic_integration/fns.sh rename to tests/integration/fns.sh index f44fee0b..c239e302 100644 --- a/tests/basic_integration/fns.sh +++ b/tests/integration/fns.sh @@ -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 @@ -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() { @@ -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() { @@ -165,6 +169,5 @@ metallica trap 'cleanup $?' ERR INT TERM $SCRIPT_DIR/lib/clean_folders.sh "$SCRIPT_DIR" -$SCRIPT_DIR/lib/prebuild.sh diff --git a/tests/basic_integration/lib/ag/.gitignore b/tests/integration/lib/ag/.gitignore similarity index 100% rename from tests/basic_integration/lib/ag/.gitignore rename to tests/integration/lib/ag/.gitignore diff --git a/tests/basic_integration/lib/ag/config.yaml b/tests/integration/lib/ag/config.yaml similarity index 100% rename from tests/basic_integration/lib/ag/config.yaml rename to tests/integration/lib/ag/config.yaml diff --git a/tests/basic_integration/lib/clean_folders.sh b/tests/integration/lib/clean_folders.sh similarity index 100% rename from tests/basic_integration/lib/clean_folders.sh rename to tests/integration/lib/clean_folders.sh diff --git a/tests/basic_integration/lib/cn1/.gitignore b/tests/integration/lib/cn1/.gitignore similarity index 100% rename from tests/basic_integration/lib/cn1/.gitignore rename to tests/integration/lib/cn1/.gitignore diff --git a/tests/basic_integration/lib/cn1/config.yaml b/tests/integration/lib/cn1/config.yaml similarity index 100% rename from tests/basic_integration/lib/cn1/config.yaml rename to tests/integration/lib/cn1/config.yaml diff --git a/tests/basic_integration/lib/cn2/.gitignore b/tests/integration/lib/cn2/.gitignore similarity index 100% rename from tests/basic_integration/lib/cn2/.gitignore rename to tests/integration/lib/cn2/.gitignore diff --git a/tests/basic_integration/lib/cn2/config.yaml b/tests/integration/lib/cn2/config.yaml similarity index 100% rename from tests/basic_integration/lib/cn2/config.yaml rename to tests/integration/lib/cn2/config.yaml diff --git a/tests/basic_integration/lib/cn3/.gitignore b/tests/integration/lib/cn3/.gitignore similarity index 100% rename from tests/basic_integration/lib/cn3/.gitignore rename to tests/integration/lib/cn3/.gitignore diff --git a/tests/basic_integration/lib/cn3/config.yaml b/tests/integration/lib/cn3/config.yaml similarity index 100% rename from tests/basic_integration/lib/cn3/config.yaml rename to tests/integration/lib/cn3/config.yaml diff --git a/tests/basic_integration/lib/cn4/.gitignore b/tests/integration/lib/cn4/.gitignore similarity index 100% rename from tests/basic_integration/lib/cn4/.gitignore rename to tests/integration/lib/cn4/.gitignore diff --git a/tests/basic_integration/lib/cn4/config.yaml b/tests/integration/lib/cn4/config.yaml similarity index 100% rename from tests/basic_integration/lib/cn4/config.yaml rename to tests/integration/lib/cn4/config.yaml diff --git a/tests/basic_integration/lib/fake_encrypt.sh b/tests/integration/lib/fake_encrypt.sh similarity index 100% rename from tests/basic_integration/lib/fake_encrypt.sh rename to tests/integration/lib/fake_encrypt.sh diff --git a/tests/integration/lib/pack_e3_params.sh b/tests/integration/lib/pack_e3_params.sh new file mode 100755 index 00000000..48ed6dd6 --- /dev/null +++ b/tests/integration/lib/pack_e3_params.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./packages/ciphernode/target/debug/pack_e3_params "$@" diff --git a/tests/basic_integration/lib/prebuild.sh b/tests/integration/lib/prebuild.sh similarity index 52% rename from tests/basic_integration/lib/prebuild.sh rename to tests/integration/lib/prebuild.sh index 33c7ce39..8b8a957e 100755 --- a/tests/basic_integration/lib/prebuild.sh +++ b/tests/integration/lib/prebuild.sh @@ -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 "" diff --git a/tests/basic_integration/logs/.gitignore b/tests/integration/logs/.gitignore similarity index 100% rename from tests/basic_integration/logs/.gitignore rename to tests/integration/logs/.gitignore diff --git a/tests/basic_integration/net.sh b/tests/integration/net.sh similarity index 100% rename from tests/basic_integration/net.sh rename to tests/integration/net.sh diff --git a/tests/basic_integration/output/.gitignore b/tests/integration/output/.gitignore similarity index 100% rename from tests/basic_integration/output/.gitignore rename to tests/integration/output/.gitignore diff --git a/tests/basic_integration/persist.sh b/tests/integration/persist.sh similarity index 100% rename from tests/basic_integration/persist.sh rename to tests/integration/persist.sh diff --git a/tests/integration/prebuild.sh b/tests/integration/prebuild.sh new file mode 100755 index 00000000..ada361cb --- /dev/null +++ b/tests/integration/prebuild.sh @@ -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" diff --git a/tests/basic_integration/test.sh b/tests/integration/test.sh similarity index 78% rename from tests/basic_integration/test.sh rename to tests/integration/test.sh index 7e7ad3fd..992d7143 100755 --- a/tests/basic_integration/test.sh +++ b/tests/integration/test.sh @@ -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"