forked from InsurNiffy/niff-Stellar-shurance
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (168 loc) · 6.5 KB
/
Copy pathfrontend-ci.yml
File metadata and controls
198 lines (168 loc) · 6.5 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
name: Frontend CI
# Runs on every push/PR that touches the frontend directory.
on:
push:
branches:
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yml'
pull_request:
branches:
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yml'
permissions:
contents: read
jobs:
# ── 1. Lint ──────────────────────────────────────────────────────────────────
lint:
name: ESLint
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint (fail on warnings)
run: npm run lint
# ── 2. Typecheck ─────────────────────────────────────────────────────────────
typecheck:
name: TypeScript typecheck
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
env:
# Build-time env vars required by next.config.mjs validation
NEXT_PUBLIC_API_URL: https://api.example.com
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
# ── 3. Build ─────────────────────────────────────────────────────────────────
build:
name: Next.js build
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
env:
NEXT_PUBLIC_API_URL: https://api.example.com
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# ── 4. Unit tests ─────────────────────────────────────────────────────────────
test:
name: Jest unit tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
env:
NEXT_PUBLIC_API_URL: https://api.example.com
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
# ── 5. Dependency audit ───────────────────────────────────────────────────────
audit:
name: npm audit
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Audit npm dependencies (fail on high/critical)
run: npm audit --audit-level=high
# ── 6. CSP allowlist drift guard ─────────────────────────────────────────────
csp-check:
name: CSP allowlist
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
env:
NEXT_PUBLIC_API_URL: https://api.example.com
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Check CSP allowlist
run: npm run check-csp
# ── 7. No deleted-route imports guard ────────────────────────────────────────
no-deleted-routes:
name: No deleted route references
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Ensure no files link to the deleted /policy routes
run: |
# The /policy/* routes were removed in favour of /policies/*.
# Any new reference to these paths is a regression.
PATTERNS=(
"href=['\"/]/policy['\"/]"
"href=['\"/]/policy/"
"push\(['\"/]/policy['\"/]\)"
"push\(['\"/]/policy/"
"ctaHref.*['\"/]/policy['\"/]"
"from.*QuoteAPI"
"import.*QuoteAPI"
)
found=0
for pattern in "${PATTERNS[@]}"; do
matches=$(grep -rn --include="*.ts" --include="*.tsx" "$pattern" frontend/src/ 2>/dev/null || true)
if [ -n "$matches" ]; then
echo "::error::Deleted route/export reference detected — $pattern"
echo "$matches"
found=$((found + 1))
fi
done
if [ "$found" -gt 0 ]; then
echo "::error::$found deleted reference(s) found. Update them to use /policies before merging."
exit 1
fi
echo "✅ No deleted route references detected"