Skip to content

Commit 0bd07ee

Browse files
committed
feat(coprocessor): compile in parallel to DB init in CI
1 parent 65f340b commit 0bd07ee

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,50 @@ jobs:
9898
username: ${{ secrets.CGR_USERNAME }}
9999
password: ${{ secrets.CGR_PASSWORD }}
100100

101-
- name: Init database
102-
run: make init_db
103-
working-directory: coprocessor/fhevm-engine/tfhe-worker
104-
105101
- name: Use Node.js
106102
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
107103
with:
108104
node-version: 20.x
109105

110-
- name: Start localstack
106+
- name: Start database services (background)
111107
run: |
112-
docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:4.14.0
108+
nohup docker compose up -d --build db-migration > /tmp/db-init.log 2>&1 &
109+
working-directory: coprocessor/fhevm-engine/tfhe-worker
110+
111+
- name: Start localstack
112+
run: docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:4.14.0
113113

114114
- name: Clean previous coverage data
115115
run: cargo llvm-cov clean --workspace --profile coverage
116116
working-directory: coprocessor/fhevm-engine
117117

118+
- name: Compile tests with coverage instrumentation
119+
run: |
120+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
121+
SQLX_OFFLINE=true \
122+
cargo llvm-cov --no-run --no-report --workspace --profile coverage
123+
working-directory: coprocessor/fhevm-engine
124+
125+
- name: Wait for database migration
126+
run: |
127+
while ! docker container inspect db-migration > /dev/null 2>&1; do
128+
echo "Waiting for db-migration container to be created..."
129+
sleep 2
130+
done
131+
EXIT_CODE=$(docker wait db-migration)
132+
if [ "$EXIT_CODE" != "0" ]; then
133+
echo "Database migration failed with exit code $EXIT_CODE"
134+
docker logs db-migration
135+
cat /tmp/db-init.log
136+
exit 1
137+
fi
138+
echo "Database migration completed"
139+
118140
- name: Run tests with coverage
119141
run: |
120142
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
121143
TEST_GLOBAL_LOCALSTACK=1 \
144+
SQLX_OFFLINE=true \
122145
cargo llvm-cov --no-report --workspace --profile coverage
123146
working-directory: coprocessor/fhevm-engine
124147

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ jobs:
168168
username: ${{ secrets.CGR_USERNAME }}
169169
password: ${{ secrets.CGR_PASSWORD }}
170170

171-
- name: Init database
172-
run: make init_db
171+
- name: Start database services (background)
172+
run: |
173+
nohup docker compose up -d --build db-migration > /tmp/db-init.log 2>&1 &
173174
working-directory: coprocessor/fhevm-engine/tfhe-worker
174175

175176
- name: Use Node.js
@@ -183,6 +184,31 @@ jobs:
183184
env:
184185
HARDHAT_NETWORK: hardhat
185186

187+
- name: Compile GPU test artifacts
188+
run: |
189+
SQLX_OFFLINE=true cargo test --no-run \
190+
-p tfhe-worker \
191+
-p sns-worker \
192+
-p zkproof-worker \
193+
--release \
194+
--features=gpu
195+
working-directory: coprocessor/fhevm-engine
196+
197+
- name: Wait for database migration
198+
run: |
199+
while ! docker container inspect db-migration > /dev/null 2>&1; do
200+
echo "Waiting for db-migration container to be created..."
201+
sleep 2
202+
done
203+
EXIT_CODE=$(docker wait db-migration)
204+
if [ "$EXIT_CODE" != "0" ]; then
205+
echo "Database migration failed with exit code $EXIT_CODE"
206+
docker logs db-migration
207+
cat /tmp/db-init.log
208+
exit 1
209+
fi
210+
echo "Database migration completed"
211+
186212
- name: Run GPU tests for the worker services.
187213
run: |
188214
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor

0 commit comments

Comments
 (0)