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 all 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
11 changes: 5 additions & 6 deletions fhevm-engine/coprocessor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ cleanup:

.PHONY: init_db
init_db:
docker compose up -d
docker compose up -d db migration
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:
$(MAKE) cleanup
$(MAKE) init_db

.PHONY: run
run:
docker compose up -d

.PHONY: clean_run
clean_run:
$(MAKE) recreate_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