Skip to content

Commit

Permalink
Integration tests with ephemeral runners via GitHub ops (privacy-scal…
Browse files Browse the repository at this point in the history
…ing-explorations#1319)

### Description

This PR introduces github-ops functionality to
zkevm-circuits/integration-tests, allowing execution on ephemeral AWS
hosted runners. Execution mode is parameterized based on event trigger
type and prover type selection.

### 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

### Contents

- .github/workflows/integration.yml
- integration-tests/run.sh
- integration-tests/README.md

```
This PR contains:
- A new job that initializes prover and instance type workflow variables 
- run.sh updated to Compose V2
- Updated README.md file to reflect the updated docker compose commands
```

### Design choices
As per new integration tests execution mode, we run the tests manually,
on schedule or on specific GitHub events (PR, push to main). Depending
on workflow setup, test is executed either with real or mock prover,
thus different AWS instance is selected to accommodate increased
resource requirements for real prover. For this reason, we introduced a
new job that initializes instance type and prover type variables as job
outputs to be used for subsequent jobs (integration-tests).

---------

Co-authored-by: testuser-at-490752553772 <[email protected]>
  • Loading branch information
ntampakas and testuser-at-490752553772 authored Mar 15, 2023
1 parent d808fc9 commit 5c72f27
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 48 deletions.
75 changes: 33 additions & 42 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Integration Tests

on:
merge_group:
schedule:
- cron: '50 1 * * SUN'
pull_request:
Expand All @@ -19,56 +20,40 @@ on:
- real_prover
- mock_prover

jobs:
consecutiveness:
if: github.event_name == 'schedule' ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'trigger-integration-tests')


runs-on: ubuntu-latest
steps:
- uses: mktcode/consecutive-workflow-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

wakeuprunner:
jobs:
set-outputs:
if: github.event.pull_request.draft == false

needs: [consecutiveness]
name: Wake up self-hosted runner
runs-on: pse-runner

runs-on: ubuntu-latest
outputs:
instancetype: ${{ steps.set-outputs.outputs.instancetype }}
provertype: ${{ steps.set-outputs.outputs.provertype }}
steps:
- uses: actions/checkout@v2
- run: |
.github/integrationTestsScripts/wakeUpRunner.sh
- id: set-outputs
name: Select instance and prover type
run: |
if [ "${{ github.event.inputs.provertype }}" = "real_prover" ] || [ "${{ github.event_name }}" = "schedule" ]; then
echo "instancetype=r6i.32xlarge" >> "$GITHUB_OUTPUT"
echo "provertype=real_prover" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.inputs.provertype }}" = "mock_prover" ] || [ -z ${{ github.event.inputs.provertype }} ]; then
echo "instancetype=c5.9xlarge" >> "$GITHUB_OUTPUT"
echo "provertype=mock_prover" >> "$GITHUB_OUTPUT"
else
exit 1
fi
integration-tests:
if: github.event.pull_request.draft == false

needs: [wakeuprunner]
name: Integration Tests
runs-on: integration-tests-runner
runs-on: ["${{github.run_id}}", self-hosted, "${{needs.set-outputs.outputs.instancetype}}"]
needs: set-outputs

defaults:
run:
working-directory: ./integration-tests
steps:
- name: Set provertype to mock_prover for push & pull_request_labelled
run: |
echo "provertype=mock_prover" >> $GITHUB_ENV
if: github.event_name == 'push' ||
github.event_name == 'pull_request'
- name: Set provertype to workflow_dispatch choice
run: |
echo "provertype=${{ inputs.provertype }}" >> $GITHUB_ENV
if: github.event_name == 'workflow_dispatch'
- name: Set provertype to real_prover for scheduled runs
run: |
echo "provertype=real_prover" >> $GITHUB_ENV
if: github.event_name == 'schedule'
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
Expand All @@ -88,7 +73,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Cargo cache
uses: actions/cache@v3
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand All @@ -97,14 +82,20 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Run an initial build in a separate step to split the build time from execution time
# Run an initial build in a separate step to split the build time from execution time
- name: Build bins
run: cargo build --bin gen_blockchain_data
- name: Build tests
run: for testname in rpc circuit_input_builder circuits; do cargo test --profile release --test $testname --features $testname --no-run; done
- run: ./run.sh --steps "setup"
working-directory: integration-tests
- run: ./run.sh --steps "gendata"
working-directory: integration-tests
- run: ./run.sh --steps "tests" --tests "rpc"
working-directory: integration-tests
- run: ./run.sh --steps "tests" --tests "circuit_input_builder"
- run: RUST_TEST_THREADS=1 ./run.sh --steps "tests" --tests "circuits::${{ env.provertype }}"
working-directory: integration-tests
- run: RUST_TEST_THREADS=1 ./run.sh --steps "tests" --tests "circuits::${{ needs.set-outputs.outputs.provertype }}"
working-directory: integration-tests
- run: ./run.sh --steps "cleanup"
working-directory: integration-tests
6 changes: 3 additions & 3 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ is used like this:
$ ./run.sh --help
Usage: ./run.sh [OPTIONS]
Options:
--sudo Use sudo for docker-compose commands.
--sudo Use sudo for docker compose commands.
--steps ARG Space separated list of steps to do.
Default: "setup gendata tests cleanup".
--tests ARG Space separated list of tests to run.
Expand All @@ -21,7 +21,7 @@ $ ./run.sh --help

## Steps
1. Setup: Start the docker container that runs a fresh geth in dev mode, via
docker-compose.
docker compose.
2. Gendata: Run the `gen_blockchain_data` binary found in
`src/bin/gen_blockchain_data.rs` which compiles the contracts, deploys them,
and executes transactions; in order to generate blocks with a variety of
Expand All @@ -45,6 +45,6 @@ themselves are defined in `lib.rs`.
## Requirements

The following software needs to be installed to run the integration tests script:
- docker-compose
- docker compose
- Rust toolchain
- `solc` version 0.7.x or 0.8.x
6 changes: 3 additions & 3 deletions integration-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ usage() {
cat >&2 << EOF
Usage: $0 [OPTIONS]
Options:
--sudo Use sudo for docker-compoes commands.
--sudo Use sudo for docker compose commands.
--steps ARG Space separated list of steps to do.
Default: "${ARG_DEFAULT_STEPS}".
--tests ARG Space separated list of tests to run.
Expand Down Expand Up @@ -76,9 +76,9 @@ done

docker_compose_cmd() {
if [ -n "$ARG_SUDO" ]; then
sudo docker-compose $@
sudo docker compose $@
else
docker-compose $@
docker compose $@
fi
}

Expand Down

0 comments on commit 5c72f27

Please sign in to comment.