Skip to content

Commit

Permalink
ci: add github actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelelliot committed Jan 23, 2024
1 parent f92ace7 commit 0cb9327
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Tests

on:
push:
pull_request:
branches: [main]

env:
CLI_VERSION: 0.16.9
SANDBOX_VERSION: 0.16.9

jobs:
unit:
name: "Integration tests"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Create docker network
run: docker network create aztec_network

- name: Start ethereum service
run: |
docker run --rm -d --hostname ethereum --name ethereum \
--network=aztec_network \
-p 8545:8545 \
--entrypoint anvil \
ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f \
-p 8545 --host 0.0.0.0 --chain-id 31337 --silent
- name: Start aztec service
run: |
docker run --rm -d --hostname aztec --name aztec \
--network=aztec_network \
-p 8079:8079 \
-p 8080:8080 \
-e DEBUG \
-e HOST_WORKDIR=$PWD \
-e ETHEREUM_HOST=http://ethereum:8545 \
-e CHAIN_ID=31337 \
-e ARCHIVER_POLLING_INTERVAL_MS=50 \
-e P2P_BLOCK_CHECK_INTERVAL_MS=50 \
-e SEQ_TX_POLLING_INTERVAL_MS=50 \
-e WS_BLOCK_CHECK_INTERVAL_MS=50 \
-e PXE_BLOCK_POLLING_INTERVAL_MS=50 \
-e ARCHIVER_VIEM_POLLING_INTERVAL_MS=500 \
aztecprotocol/aztec-sandbox:$SANDBOX_VERSION
- name: Wait for services to start
id: wait_for_aztec_service
run: |
PXE_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aztec)
echo "Waiting for aztec service to start at $PXE_IP..."
while ! nc -z $PXE_IP 8080; do
sleep 1
done
echo "PXE_URL=http://$PXE_IP:8080" >> "$GITHUB_ENV"
- name: Install dependencies
run: npm install

- name: Compile contracts
run: ./scripts/compile-ci.sh

- name: Deploy contracts and run tests
run: SKIP_COMPILE=1 ./scripts/test.sh
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Aztec Sandbox](https://img.shields.io/badge/Aztec_Sandbox-0.16.9-darkviolet)](https://github.com/AztecProtocol/aztec-packages)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-green)](https://opensource.org/license/apache-2-0)
[![Tests](https://github.com/michaelelliot/zkpassport-aztec-sandbox/actions/workflows/test.yml/badge.svg)](https://github.com/michaelelliot/zkpassport-aztec-sandbox/actions/workflows/test.yml)

A prototype for private token transfers on Aztec Network featuring integrated
compliance mechanisms like per transaction send limits, transaction send
Expand Down
24 changes: 24 additions & 0 deletions scripts/compile-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e

function compile_contract() {
echo "Compiling $1..."
mkdir -p cache
mkdir -p "$HOME/.aztec/cache"
mkdir -p src/interfaces
docker run --rm --user 1001:127 \
--network=aztec_network \
--workdir $PWD \
-e PXE_URL=$PXE_URL \
-e XDG_CACHE_HOME=/cache \
-v $PWD/src/contracts/$1:$PWD/src/contracts/$1 \
-v $HOME/.aztec/cache:/cache \
-v $PWD:$PWD aztecprotocol/cli:$CLI_VERSION \
compile -ts target src/contracts/$1 --compiler wasm
mv src/contracts/$1/target/*.{json,ts} src/interfaces/
rm -d src/contracts/$1/target
}

compile_contract slow_tree
compile_contract zkpassport_token

0 comments on commit 0cb9327

Please sign in to comment.