-
Notifications
You must be signed in to change notification settings - Fork 236
279 lines (237 loc) · 8.61 KB
/
Copy pathci.yml
File metadata and controls
279 lines (237 loc) · 8.61 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: CI
on:
pull_request:
branches:
- main
# Cancel in-progress runs for the same workflow and branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Restrict default GITHUB_TOKEN permissions (fix for issue #924)
permissions:
contents: read
pull-requests: read
jobs:
test-e2e:
runs-on: ubuntu-latest
# Skip E2E when secrets are absent
if: ${{ secrets.MAESTRO_API_KEY != '' && secrets.EXPO_TOKEN != '' }}
permissions:
contents: read
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-audit
- name: Build Android preview APK via EAS
run: eas build --platform android --profile preview --non-interactive --no-wait
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
GIT_WORKAROUND: 'true'
- name: Wait for EAS build
id: eas-build
run: |
BUILD_ID=$(eas build:list --platform android --limit 1 --json --non-interactive | jq -r '.[0].id')
echo "build_id=$BUILD_ID" >> "$GITHUB_OUTPUT"
echo "Waiting for EAS build $BUILD_ID to complete..."
while true; do
STATUS=$(eas build:view $BUILD_ID --json --non-interactive | jq -r '.status')
if [ "$STATUS" = 'finished' ]; then
echo "Build finished"
break
elif [ "$STATUS" = 'errored' ] || [ "$STATUS" = 'canceled' ]; then
echo "Build failed with status: $STATUS"
exit 1
fi
echo "Build status: $STATUS — waiting 60s..."
sleep 60
done
- name: Download APK artifact
run: |
BUILD_ID=${{ steps.eas-build.outputs.build_id }}
eas build:download --id $BUILD_ID --platform android --path ./app.apk --non-interactive
- name: Install Maestro CLI
run: curl -Ls "https://get.maestro.mobile.dev" | bash
- name: Run Maestro E2E tests
run: |
export PATH="$HOME/.maestro/bin:$PATH"
maestro test maestro/ --format junit --output maestro-results.xml || MAESTRO_EXIT=$?
echo "maestro_exit=$MAESTRO_EXIT" >> "$GITHUB_OUTPUT"
exit 0 # Don't fail yet — upload artifacts first
id: maestro
continue-on-error: true
- name: Upload Maestro results
if: always()
uses: actions/upload-artifact@v4
with:
name: maestro-results
path: |
maestro-results.xml
maestro/**/*.png
retention-days: 14
- name: Fail if Maestro tests failed
if: steps.maestro.outputs.maestro_exit != '0'
run: |
echo "Maestro E2E tests failed (exit code: ${{ steps.maestro.outputs.maestro_exit }})"
exit 1
ci:
runs-on: ubuntu-latest
permissions:
contents: read
env:
EXPO_PUBLIC_API_BASE_URL: https://api.teachlink.com
EXPO_PUBLIC_SOCKET_URL: wss://api.teachlink.com
EXPO_PUBLIC_APP_ENV: production
EXPO_PUBLIC_ENABLE_PUSH_NOTIFICATIONS: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', 'scripts/subset-fonts.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install subsetting dependencies
run: pip install -r requirements.txt
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-audit
- name: Cache subsetted fonts
id: cache-fonts
uses: actions/cache@v4
with:
path: |
assets/fonts/*.ttf
!assets/fonts/original/*.ttf
key: ${{ runner.os }}-fonts-${{ hashFiles('assets/fonts/original/*.ttf', 'scripts/subset-fonts.py', 'requirements.txt') }}
restore-keys: |
${{ runner.os }}-fonts-
- name: Run Font Subsetting
if: steps.cache-fonts.outputs.cache-hit != 'true'
run: python scripts/subset-fonts.py
- name: Cache TypeScript build info
uses: actions/cache@v4
with:
path: |
.tsbuildinfo
**/.tsbuildinfo
key: ${{ runner.os }}-typescript-${{ hashFiles('tsconfig.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-typescript-
- name: Cache Jest
uses: actions/cache@v4
with:
path: |
.jest-cache
coverage
key: ${{ runner.os }}-jest-${{ hashFiles('jest.config.js', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-jest-
- name: Cache Expo
uses: actions/cache@v4
with:
path: |
~/.expo
.expo
.expo-shared
key: ${{ runner.os }}-expo-${{ hashFiles('app.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-expo-
- name: Cache Metro bundler
uses: actions/cache@v4
with:
path: |
.metro-cache
node_modules/.cache/metro
key: ${{ runner.os }}-metro-${{ hashFiles('metro.config.js', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-metro-
- name: Cache ESLint
uses: actions/cache@v4
with:
path: .eslintcache
key: ${{ runner.os }}-eslint-${{ hashFiles('eslint.config.js', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-eslint-
- name: Check for console.* violations
run: |
VIOLATIONS=$(grep -rn "console\." src/ \
--include='*.ts' \
--include='*.tsx' \
--exclude='logger.ts' \
--exclude='logger.*.ts' \
--exclude='cli.ts' \
--exclude='*.test.ts' \
--exclude='*.test.tsx' \
--exclude='*.spec.ts' \
--exclude='*.spec.tsx' \
--exclude-dir='__tests__' \
|| true)
if [ -n "$VIOLATIONS" ]; then
echo ""
echo "? console.* usage detected. Use src/utils/logger instead."
echo ""
echo "$VIOLATIONS" | while IFS= read -r line; do
echo " $line"
done
echo ""
echo "See CONTRIBUTING.md for the logging level guide."
exit 1
fi
echo "? No console.* violations found."
- name: Lint
run: npm run lint -- --cache --max-warnings=$(node -p "require('./lint-budget.json').maxWarnings") --cache-location .eslintcache
- name: Enforce lint budget ratchet
run: npm run lint:budget
- name: Format check
run: npm run format:check
- name: Typecheck
run: npx tsc --noEmit --incremental
- name: Test
run: npm test -- --cache --cacheDirectory=.jest-cache
- name: Validate OpenAPI Spec
run: npm run validate:openapi
- name: Run contract tests
run: npm test -- --testPathPattern='openapi.contract|validation' --cache --cacheDirectory=.jest-cache
- name: Cache Expo build output
uses: actions/cache@v4
with:
path: |
dist
.expo/web
key: ${{ runner.os }}-expo-build-${{ hashFiles('app/**/*', 'src/**/*', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-expo-build-
- name: Build App (Web)
run: npx expo export --platform web
- name: Check Bundle Size
run: node scripts/checkBundleSize.js
- name: Check API Performance
run: node scripts/checkApiPerf.js
- name: Report cache statistics
if: always()
run: |
echo "## Cache Statistics" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Cache | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Node Modules | ${{ steps.cache-node-modules.outputs.cache-hit == 'true' && 'Hit' || 'Miss' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Fonts | ${{ steps.cache-fonts.outputs.cache-hit == 'true' && 'Hit' || 'Miss' }} |" >> $GITHUB_STEP_SUMMARY