Repository navigation
244 lines (203 loc) · 7.23 KB
/
Copy pathci.yml
File metadata and controls
244 lines (203 loc) · 7.23 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
241
242
243
244
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
types: [opened, synchronize, reopened, ready_for_review]
# Fork PRs use the same workflow; they run with read-only GITHUB_TOKEN and no repo secrets.
# If checks do not appear, a maintainer must approve workflow runs (Settings → Actions → Fork pull requests).
# We do not use pull_request_target with a full checkout of PR code here — that pattern can expose secrets to untrusted code.
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Default permissions for all jobs - principle of least privilege
permissions:
contents: read
jobs:
lint-and-typecheck:
name: Lint and Type Check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run type check
run: npm run type-check
security:
name: Security Scanning
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
# Vulnerability scanning with npm audit
- name: Run npm audit
run: npm audit --audit-level=high
# License compliance check (matches transitive licenses in production deps)
- name: Check license compliance
run: |
npx license-checker --production --onlyAllow "MIT;MIT*;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;CC0-1.0;CC-BY-3.0;CC-BY-4.0;Unlicense;0BSD;BlueOak-1.0.0;GPL-3.0-only;GPL-3.0-or-later;Hippocratic-2.1;MPL-2.0;LGPL-3.0-or-later;(BSD-3-Clause OR GPL-2.0);MIT AND ISC" --summary
# Secrets scanning with gitleaks
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
# Generate SBOM (Software Bill of Materials)
- name: Generate SBOM
run: npx @cyclonedx/cyclonedx-npm --output-file sbom.json --output-format json
- name: Upload SBOM artifact
uses: actions/upload-artifact@v7
with:
name: sbom
path: sbom.json
retention-days: 30
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run test:coverage
env:
CI: true
- name: Upload coverage reports
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: codecov-cursor-boston
fail_ci_if_error: false
verbose: true
- name: Check coverage threshold
run: |
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
echo "Current coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 50" | bc -l) )); then
echo "::warning::Coverage is below 50% threshold"
fi
continue-on-error: true
firestore-rules:
name: Firestore rules tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Firestore rules tests (emulator)
run: npm run test:rules
env:
CI: true
build:
name: Build
runs-on: ubuntu-latest
needs: [lint-and-typecheck, test, firestore-rules, security]
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate environment variables
run: npm run validate-env
env:
# Use placeholder values for CI - actual values not needed for build validation
NEXT_PUBLIC_FIREBASE_API_KEY: "test-api-key"
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: "test-project.firebaseapp.com"
NEXT_PUBLIC_FIREBASE_PROJECT_ID: "test-project-id"
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: "test-project.appspot.com"
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: "123456789"
NEXT_PUBLIC_FIREBASE_APP_ID: "1:123456789:web:abcdef"
NEXT_PUBLIC_FIREBASE_DATABASE_URL: "https://test-project.firebaseio.com"
- name: Build application
run: npm run build
env:
# Use placeholder values for CI build
NEXT_PUBLIC_FIREBASE_API_KEY: "test-api-key"
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: "test-project.firebaseapp.com"
NEXT_PUBLIC_FIREBASE_PROJECT_ID: "test-project-id"
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: "test-project.appspot.com"
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: "123456789"
NEXT_PUBLIC_FIREBASE_APP_ID: "1:123456789:web:abcdef"
NEXT_PUBLIC_FIREBASE_DATABASE_URL: "https://test-project.firebaseio.com"
docker:
name: Docker Build
runs-on: ubuntu-latest
needs: [lint-and-typecheck, test, firestore-rules, security]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
file: docker/Dockerfile
push: false
tags: cursor-boston:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NEXT_PUBLIC_FIREBASE_API_KEY=build-placeholder
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=build-placeholder.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=build-placeholder
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=build-placeholder.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=000000000000
NEXT_PUBLIC_FIREBASE_APP_ID=1:000000000000:web:placeholder
NEXT_PUBLIC_FIREBASE_DATABASE_URL=https://build-placeholder.firebaseio.com