22# Covers frontend linting/build, backend build/test, and Soroban contract build/test.
33name : CI
44
5+ concurrency :
6+ group : ${{ github.workflow }}-${{ github.ref }}
7+ cancel-in-progress : true
8+
59on :
610 push :
7- branches : [ main, develop ]
11+ branches : [main, develop]
812 pull_request :
9- branches : [ main, develop ]
13+ branches : [main, develop]
1014
1115jobs :
1216 frontend :
@@ -19,14 +23,13 @@ jobs:
1923 - name : Setup Node.js
2024 uses : actions/setup-node@v4
2125 with :
22- node-version : ' 20 '
23- cache : ' npm'
26+ node-version : " 20 "
27+ cache : " npm"
2428 cache-dependency-path : package-lock.json
2529
2630 - name : Install dependencies
2731 run : npm ci
2832
29-
3033 - name : Lint
3134 run : npm run lint
3235 working-directory : frontend
3639 working-directory : frontend
3740
3841 - name : Run Frontend Tests
39- run : npm test
42+ run : npm run test:coverage
4043 working-directory : frontend
4144
4245 - name : Build
4851 runs-on : ubuntu-latest
4952 services :
5053 postgres :
51- image : postgres:15
54+ image : postgres:16-alpine@sha256:e013e867e712fec275706a6c51c966f0bb0c93cfa8f51000f85a15f9865a28cb
5255 env :
5356 POSTGRES_USER : postgres
5457 POSTGRES_PASSWORD : password
6871 - name : Setup Node.js
6972 uses : actions/setup-node@v4
7073 with :
71- node-version : ' 20 '
72- cache : ' npm'
74+ node-version : " 20 "
75+ cache : " npm"
7376 cache-dependency-path : package-lock.json
7477
7578 - name : Install dependencies
@@ -111,6 +114,40 @@ jobs:
111114 env :
112115 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
113116
117+ backend-docker :
118+ name : Backend Docker Image CI
119+ runs-on : ubuntu-latest
120+ steps :
121+ - name : Checkout code
122+ uses : actions/checkout@v4
123+
124+ - name : Check changed files
125+ id : filter
126+ uses : dorny/paths-filter@v3
127+ with :
128+ filters : |
129+ backend:
130+ - 'backend/**'
131+ - 'docker-compose.yml'
132+
133+ - name : Build Docker Image
134+ if : steps.filter.outputs.backend == 'true' || github.event_name == 'push'
135+ run : docker build -f backend/Dockerfile backend -t flowfi-backend:test
136+
137+ - name : Docker Compose Build
138+ if : steps.filter.outputs.backend == 'true' || github.event_name == 'push'
139+ run : docker compose build
140+
141+ - name : Boot and Check Health
142+ if : steps.filter.outputs.backend == 'true' || github.event_name == 'push'
143+ run : |
144+ docker compose up -d postgres
145+ sleep 10
146+ docker compose run --rm -e DATABASE_URL=postgresql://flowfi:flowfi_dev_password@postgres:5432/flowfi backend npx -y prisma db push --accept-data-loss
147+ docker compose up -d backend
148+ sleep 15
149+ curl --fail http://localhost:3001/health || (docker compose logs backend && exit 1)
150+
114151 contracts :
115152 name : Soroban Contracts CI
116153 runs-on : ubuntu-latest
@@ -128,7 +165,7 @@ jobs:
128165 - name : Rust Cache
129166 uses : Swatinem/rust-cache@v2
130167 with :
131- workspaces : " contracts -> target"
168+ workspace : " contracts -> target"
132169
133170 - name : Check Formatting
134171 run : cargo fmt --all -- --check
@@ -167,26 +204,56 @@ jobs:
167204 - name : Install Stellar CLI
168205 run : |
169206 curl -fsSL https://github.com/stellar/stellar-cli/raw/main/install.sh | sh -s -- --install-deps
207+ echo "$HOME/.stellar-cli/bin" >> $GITHUB_PATH
170208 shell : bash
171209
172210 - name : Optimize WASM files
173211 run : |
174212 set -euo pipefail
175- WASMS=$(find contracts/target -type f -name "*.wasm" -print)
213+
214+ # Target the precise release build directory
215+ RELEASE_DIR="contracts/target/wasm32-unknown-unknown/release"
216+
217+ # Use your strict selection logic to target un-optimized raw binaries only
218+ WASMS=$(find "$RELEASE_DIR" -maxdepth 1 -type f -name "*.wasm" ! -name "*.optimized.wasm")
219+
176220 if [ -z "$WASMS" ]; then
177- echo "No wasm files found"
221+ echo "Error: No raw WASM files found in $RELEASE_DIR "
178222 exit 1
179223 fi
224+
180225 for w in $WASMS; do
181- out="${w%%.wasm}.optimized.wasm"
182- echo "Optimizing $w -> $out"
226+ filename=$(basename "$w")
227+ out="$RELEASE_DIR/${filename%.wasm}.optimized.wasm"
228+ echo "Optimizing $filename -> $(basename "$out")"
183229 stellar contract optimize --wasm "$w" --wasm-out "$out"
184230 done
185231 shell : bash
186232
233+ - name : Check WASM size budget
234+ run : |
235+ set -euo pipefail
236+
237+ RELEASE_DIR="contracts/target/wasm32-unknown-unknown/release"
238+ WASM_SIZE_LIMIT=200000 # 200KB budget for optimized WASM
239+
240+ for wasm in "$RELEASE_DIR"/*.optimized.wasm; do
241+ if [ -f "$wasm" ]; then
242+ size=$(stat -c%s "$wasm")
243+ filename=$(basename "$wasm")
244+ echo "Optimized WASM size: $filename = $size bytes"
245+
246+ if [ "$size" -gt "$WASM_SIZE_LIMIT" ]; then
247+ echo "Error: $filename exceeds size budget of $WASM_SIZE_LIMIT bytes"
248+ exit 1
249+ fi
250+ fi
251+ done
252+ shell : bash
253+
187254 - name : Upload optimized WASM artifacts
188255 uses : actions/upload-artifact@v4
189256 with :
190257 name : optimized-wasm
191- path : |
192- contracts/target/**/**/*.optimized.wasm
258+ path : contracts/target/wasm32-unknown-unknown/release/*.optimized.wasm
259+ if-no-files-found : error
0 commit comments