Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

ci: add cargo tests #280

Merged
merged 18 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/cargo-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Rust tests

on:
pull_request:
branches:
- main
paths:
- .github/workflows/cargo-tests.yml
- fhevm-engine/**
- proto/**

jobs:
cargo-tests:
permissions:
contents: "read"
id-token: "write"
packages: "write"
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.82.0]

steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
lfs: true

- name: Checkout LFS objects
run: git lfs checkout

- name: Set up Rust
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true

- name: Install cargo dependencies
run: |
sudo apt-get install -y protobuf-compiler && \
cargo install sqlx-cli

- name: Cache cargo
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Init database
run: make init_db
working-directory: fhevm-engine/coprocessor

- name: Run tests
run: |
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor cargo test --release -- --test-threads=1
working-directory: fhevm-engine
5 changes: 0 additions & 5 deletions fhevm-engine/coprocessor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ init_db:
sleep 3
$(DB_URL) sqlx db create
$(DB_URL) sqlx migrate run
$(DB_URL) cargo test setup_test_user -- --nocapture --ignored

.PHONY: run
run:
docker compose up -d

.PHONY: recreate_db
recreate_db:
Expand Down
64 changes: 32 additions & 32 deletions fhevm-engine/coprocessor/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ services:
db:
condition: service_healthy

coprocessor:
container_name: coprocessor
image: ghcr.io/zama-ai/fhevm-coprocessor:v0.6.0
environment:
DATABASE_URL: postgresql://postgres:postgres@db:5432/coprocessor
ports:
- '50051:50051'
volumes:
- ./coprocessor.key:/usr/share/coprocessor.key
command:
- --run-bg-worker
- --run-server
- --server-addr=0.0.0.0:50051
- --coprocessor-private-key=/usr/share/coprocessor.key
depends_on:
migration:
condition: service_completed_successfully
# coprocessor:
# container_name: coprocessor
# image: ghcr.io/zama-ai/fhevm-coprocessor:v0.6.0
# environment:
# DATABASE_URL: postgresql://postgres:postgres@db:5432/coprocessor
# ports:
# - '50051:50051'
# volumes:
# - ./coprocessor.key:/usr/share/coprocessor.key
# command:
# - --run-bg-worker
# - --run-server
# - --server-addr=0.0.0.0:50051
# - --coprocessor-private-key=/usr/share/coprocessor.key
# depends_on:
# migration:
# condition: service_completed_successfully

geth:
container_name: geth
image: ghcr.io/zama-ai/go-ethereum-coprocessor-dev:v0.1.1
environment:
FHEVM_COPROCESSOR_API_KEY: a1503fb6-d79b-4e9e-826d-44cf262f3e05
FHEVM_COPROCESSOR_URL: coprocessor:50051
COPROCESSOR_CONTRACT_ADDRESS: 0x6819e3aDc437fAf9D533490eD3a7552493fCE3B1
ACL_CONTRACT_ADDRESS: 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2
volumes:
- ./geth:/geth
ports:
- '8745:8545'
depends_on:
coprocessor:
condition: service_started
# geth:
# container_name: geth
# image: ghcr.io/zama-ai/go-ethereum-coprocessor-dev:v0.1.1
# environment:
# FHEVM_COPROCESSOR_API_KEY: a1503fb6-d79b-4e9e-826d-44cf262f3e05
# FHEVM_COPROCESSOR_URL: coprocessor:50051
# COPROCESSOR_CONTRACT_ADDRESS: 0x6819e3aDc437fAf9D533490eD3a7552493fCE3B1
# ACL_CONTRACT_ADDRESS: 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2
# volumes:
# - ./geth:/geth
# ports:
# - '8745:8545'
# depends_on:
# coprocessor:
# condition: service_started

volumes:
db:
Expand Down
2 changes: 2 additions & 0 deletions fhevm-engine/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.82.0"
Loading