-
Notifications
You must be signed in to change notification settings - Fork 66
240 lines (208 loc) · 6.91 KB
/
ci.yml
File metadata and controls
240 lines (208 loc) · 6.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: CI
on:
push:
branches: [main, develop, "feat/**", "fix/**"]
pull_request:
branches: [main, develop]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: "20"
jobs:
# ── Backend ──────────────────────────────────────────────────────────────────
backend-lint:
name: Backend — Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: harvest-finance/backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: harvest-finance/backend/package-lock.json
- run: npm ci
- run: npm run lint
backend-test:
name: Backend — Unit + Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: harvest-finance/backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: harvest
POSTGRES_PASSWORD: harvest_test
POSTGRES_DB: harvest_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U harvest"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
NODE_ENV: test
DB_HOST: localhost
DB_PORT: 5432
DB_USER: harvest
DB_PASSWORD: harvest_test
DB_NAME: harvest_test
JWT_SECRET: ci-test-secret
JWT_REFRESH_SECRET: ci-test-refresh-secret
REDIS_HOST: localhost
REDIS_PORT: 6379
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: harvest-finance/backend/package-lock.json
- run: npm ci
- run: npm run build
- run: npm test -- --forceExit --passWithNoTests
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: backend-coverage
path: harvest-finance/backend/coverage/
backend-build:
name: Backend — Docker Build
runs-on: ubuntu-latest
needs: [backend-lint, backend-test]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build backend image
uses: docker/build-push-action@v6
with:
context: harvest-finance/backend
file: harvest-finance/backend/Dockerfile
push: false
tags: harvest-finance-backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ── Frontend ─────────────────────────────────────────────────────────────────
frontend-lint:
name: Frontend — Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: harvest-finance/frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: harvest-finance/frontend/package-lock.json
- run: npm ci
- run: npm run lint
frontend-test:
name: Frontend — Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: harvest-finance/frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: harvest-finance/frontend/package-lock.json
- run: npm ci
- run: npm test -- --passWithNoTests
- run: npm run test:vitest -- --run --passWithNoTests
frontend-build:
name: Frontend — Next.js Build
runs-on: ubuntu-latest
needs: [frontend-lint, frontend-test]
defaults:
run:
working-directory: harvest-finance/frontend
env:
NEXT_PUBLIC_API_URL: https://api.harvestfinance.io
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: harvest-finance/frontend/package-lock.json
- run: npm ci
- run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: frontend-build-${{ github.sha }}
path: harvest-finance/frontend/.next/
retention-days: 3
# ── Smart Contracts ───────────────────────────────────────────────────────────
contracts-test:
name: Contracts — Forge Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run forge tests
working-directory: contracts
run: forge test -vvv
- name: Forge coverage
working-directory: contracts
run: forge coverage --report lcov
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: contracts-coverage
path: contracts/lcov.info
# ── Smart Contract Fork Tests ─────────────────────────────────────────────────
contracts-fork-test:
name: Contracts — Mainnet Fork Tests
runs-on: ubuntu-latest
# Only run on main/develop pushes (not every feature PR) to conserve RPC calls
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run mainnet fork tests
working-directory: contracts
env:
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
run: make test-fork
# ── All-green gate ────────────────────────────────────────────────────────────
all-checks:
name: All Checks Passed
runs-on: ubuntu-latest
needs:
- backend-build
- frontend-build
- contracts-test
steps:
- run: echo "CI passed ✓"