Skip to content

Commit 6f75980

Browse files
authored
ci(coprocessor): only test fhevm-listener on contract event change (#323)
1 parent fed934e commit 6f75980

3 files changed

Lines changed: 95 additions & 2 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Coprocessor Cargo tests for contract change
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref }}
8+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
9+
10+
jobs:
11+
check-changes:
12+
permissions:
13+
actions: 'read'
14+
contents: 'read'
15+
pull-requests: 'read'
16+
runs-on: ubuntu-latest
17+
outputs:
18+
changes-rust-files: ${{ steps.filter.outputs.rust-files }}
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
22+
id: filter
23+
with:
24+
filters: |
25+
rust-files:
26+
- .github/workflows/coprocessor-cargo-listener-tests.yml
27+
- host-contracts/contracts/*Events.sol
28+
- host-contracts/contracts/shared/**
29+
cargo-tests:
30+
needs: check-changes
31+
if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }}
32+
permissions:
33+
contents: read
34+
checks: write
35+
packages: read
36+
runs-on: large_ubuntu_16
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
40+
with:
41+
persist-credentials: 'false'
42+
lfs: true
43+
44+
- name: Checkout LFS objects
45+
run: git lfs checkout
46+
47+
- name: Setup Rust
48+
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
49+
with:
50+
toolchain: stable
51+
52+
- name: Install cargo dependencies
53+
run: |
54+
sudo apt-get install -y protobuf-compiler && \
55+
cargo install sqlx-cli
56+
57+
- name: Install foundry
58+
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c
59+
60+
- name: Cache cargo
61+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
62+
with:
63+
path: |
64+
~/.cargo/registry
65+
~/.cargo/git
66+
target
67+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
restore-keys: ${{ runner.os }}-cargo-
69+
70+
- name: Login to GitHub Container Registry
71+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Init database
78+
run: make init_db
79+
working-directory: coprocessor/fhevm-engine/coprocessor
80+
81+
- name: Use Node.js
82+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
83+
with:
84+
node-version: 20.x
85+
86+
- name: Start localstack
87+
run: |
88+
docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:latest
89+
90+
- name: Run tests
91+
run: |
92+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor TXN_SENDER_TEST_GLOBAL_LOCALSTACK=1 cargo test --release -- --test-threads=1
93+
working-directory: coprocessor/fhevm-engine/fhevm-listener

.github/workflows/coprocessor-cargo-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
- .github/workflows/coprocessor-cargo-tests.yml
2727
- coprocessor/fhevm-engine/**
2828
- coprocessor/proto/**
29-
- host-contracts/contracts/**
3029
cargo-tests:
3130
needs: check-changes
3231
if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }}

.github/workflows/coprocessor-host-listener-docker-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ jobs:
3434
- coprocessor/fhevm-engine/fhevm-listner/**
3535
- coprocessor/fhevm-engine/Cargo.toml
3636
- coprocessor/fhevm-engine/Cargo.lock
37-
- host-contracts/contracts/**
37+
- host-contracts/contracts/*Events.sol
38+
- host-contracts/contracts/shared/**
3839
build:
3940
name: coprocessor-host-listener-docker-build/build
4041
needs: check-changes

0 commit comments

Comments
 (0)