-
Notifications
You must be signed in to change notification settings - Fork 149
225 lines (189 loc) · 8.24 KB
/
Copy pathfrontend.yml
File metadata and controls
225 lines (189 loc) · 8.24 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
name: Frontend CI
on:
pull_request:
branches: [main]
paths:
- "Dechat/dex_with_fiat_frontend/**"
- ".github/workflows/frontend.yml"
push:
branches: [main]
paths:
- "Dechat/dex_with_fiat_frontend/**"
permissions:
contents: read
jobs:
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: Dechat/dex_with_fiat_frontend
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install pnpm
uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
with:
version: 8
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
cache: "pnpm"
cache-dependency-path: Dechat/dex_with_fiat_frontend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- name: Type check
run: pnpm tsc --noEmit
- name: Lint
run: pnpm lint
build:
name: Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: Dechat/dex_with_fiat_frontend
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install pnpm
uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
with:
version: 8
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
cache: "pnpm"
cache-dependency-path: Dechat/dex_with_fiat_frontend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
env:
NEXT_PUBLIC_STELLAR_CONTRACT_ID: ${{ secrets.NEXT_PUBLIC_STELLAR_CONTRACT_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_XLM_SAC_ID: ${{ secrets.NEXT_PUBLIC_XLM_SAC_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_STELLAR_RPC_URL: ${{ secrets.NEXT_PUBLIC_STELLAR_RPC_URL || 'https://soroban-testnet.stellar.org' }}
NEXT_PUBLIC_STELLAR_NETWORK: ${{ secrets.NEXT_PUBLIC_STELLAR_NETWORK || 'TESTNET' }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'PLACEHOLDER' }}
PAYSTACK_SECRET_KEY: ${{ secrets.PAYSTACK_SECRET_KEY || 'PLACEHOLDER' }}
PAYOUT_PROVIDER: ${{ secrets.PAYOUT_PROVIDER || 'paystack' }}
- name: Unit tests with coverage (shard 1/4)
run: pnpm test:coverage:shard:1
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Unit tests with coverage (shard 2/4)
run: pnpm test:coverage:shard:2
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Unit tests with coverage (shard 3/4)
run: pnpm test:coverage:shard:3
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Unit tests with coverage (shard 4/4)
run: pnpm test:coverage:shard:4
env:
NODE_OPTIONS: --max-old-space-size=8192
- name: Merge coverage reports
run: pnpm test:coverage:merge
env:
NODE_OPTIONS: --max-old-space-size=4096
# NOTE: coverage.thresholds are not currently configured in vitest.config.ts,
# so this step does not fail the pipeline on low coverage. The target numbers
# below (stmt 70%, branch 65%, fn 70%, lines 70%) are informational only until
# a threshold gate is deliberately reintroduced.
- name: Generate coverage report artifact
id: coverage_report
if: always() && github.event_name == 'pull_request'
run: |
if [ ! -f coverage/coverage-summary.json ]; then
echo "No coverage summary found, skipping report generation."
echo "generated=false" >> "$GITHUB_OUTPUT"
exit 0
fi
node -e "
const fs = require('fs');
const summary = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8'));
const total = summary.total;
const report = {
pr_number: ${{ github.event.pull_request.number }},
head_sha: '${{ github.event.pull_request.head.sha }}',
statements: total.statements.pct,
branches: total.branches.pct,
functions: total.functions.pct,
lines: total.lines.pct,
targets: { statements: 70, branches: 65, functions: 70, lines: 70 },
};
fs.writeFileSync('frontend-coverage-report.json', JSON.stringify(report));
"
echo "generated=true" >> "$GITHUB_OUTPUT"
# PRs from forks get a read-only GITHUB_TOKEN under the `pull_request` event, so
# this job can't post a comment directly. The report is handed off as an artifact
# to coverage-comment.yml, which runs via `workflow_run` in the base repo's
# context (write-capable token) and only ever reads this JSON — it never checks
# out or executes any code from the PR.
- name: Upload coverage report artifact
if: always() && steps.coverage_report.outputs.generated == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: frontend-coverage-report
path: Dechat/dex_with_fiat_frontend/frontend-coverage-report.json
retention-days: 7
e2e:
name: Playwright E2E Tests
runs-on: ubuntu-latest
needs: [build, lint]
defaults:
run:
working-directory: Dechat/dex_with_fiat_frontend
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install pnpm
uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
with:
version: 8
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
cache: "pnpm"
cache-dependency-path: Dechat/dex_with_fiat_frontend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('Dechat/dex_with_fiat_frontend/pnpm-lock.yaml') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium firefox webkit
- name: Install Playwright OS dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps chromium firefox webkit
- name: Build for E2E
run: pnpm build
env:
NEXT_PUBLIC_STELLAR_CONTRACT_ID: ${{ secrets.NEXT_PUBLIC_STELLAR_CONTRACT_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_XLM_SAC_ID: ${{ secrets.NEXT_PUBLIC_XLM_SAC_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_STELLAR_RPC_URL: ${{ secrets.NEXT_PUBLIC_STELLAR_RPC_URL || 'https://soroban-testnet.stellar.org' }}
NEXT_PUBLIC_STELLAR_NETWORK: ${{ secrets.NEXT_PUBLIC_STELLAR_NETWORK || 'TESTNET' }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'PLACEHOLDER' }}
PAYSTACK_SECRET_KEY: ${{ secrets.PAYSTACK_SECRET_KEY || 'PLACEHOLDER' }}
PAYOUT_PROVIDER: ${{ secrets.PAYOUT_PROVIDER || 'paystack' }}
- name: Run Playwright E2E tests
run: pnpm test:e2e
env:
NEXT_PUBLIC_STELLAR_CONTRACT_ID: ${{ secrets.NEXT_PUBLIC_STELLAR_CONTRACT_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_XLM_SAC_ID: ${{ secrets.NEXT_PUBLIC_XLM_SAC_ID || 'PLACEHOLDER' }}
NEXT_PUBLIC_STELLAR_RPC_URL: ${{ secrets.NEXT_PUBLIC_STELLAR_RPC_URL || 'https://soroban-testnet.stellar.org' }}
NEXT_PUBLIC_STELLAR_NETWORK: ${{ secrets.NEXT_PUBLIC_STELLAR_NETWORK || 'TESTNET' }}
- name: Upload Playwright report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: always()
with:
name: playwright-report
path: Dechat/dex_with_fiat_frontend/playwright-report/
retention-days: 7