Skip to content

Commit aefb105

Browse files
authored
Merge pull request #167 from bakarezainab/CI-and-Soroban-test-automation
CI and Soroban test automation
2 parents 1c56e0d + 715ec8a commit aefb105

5 files changed

Lines changed: 171 additions & 58 deletions

File tree

.github/workflows/ci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Continuous Integration workflow for FlowFi
2+
# Covers frontend linting/build, backend build/test, and Soroban contract build/test.
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ main, develop ]
8+
pull_request:
9+
branches: [ main, develop ]
10+
11+
jobs:
12+
frontend:
13+
name: Frontend CI
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
cache-dependency-path: frontend/package-lock.json
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
working-directory: frontend
29+
30+
- name: Lint
31+
run: npm run lint
32+
working-directory: frontend
33+
34+
- name: Build
35+
run: npm run build
36+
working-directory: frontend
37+
38+
backend:
39+
name: Backend CI
40+
runs-on: ubuntu-latest
41+
services:
42+
postgres:
43+
image: postgres:15
44+
env:
45+
POSTGRES_USER: user
46+
POSTGRES_PASSWORD: password
47+
POSTGRES_DB: flowfi_test
48+
ports:
49+
- 5432:5432
50+
options: >-
51+
--health-cmd pg_isready
52+
--health-interval 10s
53+
--health-timeout 5s
54+
--health-retries 5
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: '20'
64+
cache: 'npm'
65+
cache-dependency-path: backend/package-lock.json
66+
67+
- name: Install dependencies
68+
run: npm ci
69+
working-directory: backend
70+
71+
- name: Generate Prisma Client
72+
run: npx prisma generate
73+
working-directory: backend
74+
75+
- name: Build
76+
run: npm run build
77+
working-directory: backend
78+
79+
- name: Run Backend Tests
80+
run: npm test
81+
working-directory: backend
82+
env:
83+
DATABASE_URL: postgresql://user:password@localhost:5432/flowfi_test
84+
85+
contracts:
86+
name: Soroban Contracts CI
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout code
90+
uses: actions/checkout@v4
91+
92+
- name: Setup Rust toolchain
93+
uses: dtolnay/rust-toolchain@stable
94+
with:
95+
toolchain: stable
96+
targets: wasm32-unknown-unknown
97+
98+
- name: Rust Cache
99+
uses: Swatinem/rust-cache@v2
100+
with:
101+
workspaces: "contracts -> target"
102+
103+
- name: Build Contracts
104+
run: cargo build --target wasm32-unknown-unknown --release
105+
working-directory: contracts
106+
107+
- name: Run Contract Tests
108+
run: cargo test
109+
working-directory: contracts

.github/workflows/security.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: '20'
24-
cache: 'npm'
25-
26-
- name: Install dependencies
27-
run: npm ci
28-
29-
- name: Run npm audit
30-
run: npm audit --audit-level=moderate || true
31-
32-
- name: Check for known vulnerabilities in frontend
33-
run: |
34-
cd frontend
35-
npm audit --audit-level=moderate || true
36-
37-
- name: Check for known vulnerabilities in backend
38-
run: |
39-
cd backend
40-
npm audit --audit-level=moderate || true
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run npm audit
30+
run: npm audit --audit-level=moderate
31+
32+
- name: Check for known vulnerabilities in frontend
33+
run: |
34+
cd frontend
35+
npm audit --audit-level=moderate
36+
37+
- name: Check for known vulnerabilities in backend
38+
run: |
39+
cd backend
40+
npm audit --audit-level=moderate
4141
4242
codeql-analysis:
4343
name: CodeQL Analysis

CONTRIBUTING.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,47 @@ This repository uses GitHub Actions for continuous integration. Workflows are lo
286286
- CodeQL analysis for JavaScript/TypeScript
287287
- View workflow: [Security Checks](.github/workflows/security.yml)
288288

289+
- **CI** (`.github/workflows/ci.yml`)
290+
- Runs on: push to `main`/`develop` and pull requests
291+
- Performs:
292+
- Frontend: lint and build
293+
- Backend: prisma generation, build, and tests
294+
- Soroban Contracts: build (wasm) and tests
295+
- View workflow: [CI](.github/workflows/ci.yml)
296+
289297
### Running CI Checks Locally
290298

291-
Before pushing, ensure your changes pass:
299+
Before pushing, ensure your changes pass all the same checks that run in GitHub Actions.
300+
301+
#### 1. Frontend Checks
302+
```bash
303+
cd frontend
304+
npm run lint # Runs ESLint
305+
npm run build # Verifies the build
306+
```
292307

308+
#### 2. Backend Checks
293309
```bash
294-
# Frontend linting
295-
cd frontend && npm run lint
310+
cd backend
311+
npm run prisma:generate # Ensure Prisma client is up to date
312+
npm run build # Verifies TypeScript compilation
313+
npm run test # Runs backend vitest suite
314+
```
315+
*Note: Backend tests require a running PostgreSQL instance and `DATABASE_URL` environment variable.*
296316

297-
# Backend tests
298-
cd backend && npm run test
317+
#### 3. Smart Contract Checks
318+
```bash
319+
cd contracts
320+
cargo build --target wasm32-unknown-unknown --release # Verifies contract build
321+
cargo test # Runs contract tests
322+
```
299323

300-
# Security verification
324+
#### 4. Security Verification
325+
```bash
326+
# From the repository root
301327
npm run verify-security
302328
```
303329

304-
For more details, see the [Security Workflow](.github/workflows/security.yml).
305330

306331
---
307332

frontend/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"lucide-react": "^0.575.0",
1414
"next": "16.1.6",
1515
"next-themes": "^0.4.6",
16-
"react": "19.2.3",
17-
"react-dom": "19.2.3",
18-
"react-hot-toast": "^2.6.0"
16+
"react": "19.2.4",
17+
"react-dom": "19.2.4",
18+
"lucide-react": "^0.575.0"
1919
},
2020
"devDependencies": {
2121
"@tailwindcss/postcss": "^4",
@@ -27,4 +27,4 @@
2727
"tailwindcss": "^4",
2828
"typescript": "^5"
2929
}
30-
}
30+
}

package-lock.json

Lines changed: 2 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)