-
-
Notifications
You must be signed in to change notification settings - Fork 589
333 lines (285 loc) · 9.93 KB
/
ci.yml
File metadata and controls
333 lines (285 loc) · 9.93 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
name: CI Pipeline
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
jobs:
# Detect if changes are translation-only (src/locales/ files)
detect-changes:
runs-on: ubuntu-latest
outputs:
translation_only: ${{ steps.check.outputs.translation_only }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if translation-only
id: check
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
else
CHANGED=$(git diff --name-only HEAD~1)
fi
echo "Changed files:"
echo "$CHANGED"
# Check if ALL changed files are under src/locales/
TRANSLATION_ONLY="true"
while IFS= read -r file; do
if [ -z "$file" ]; then
continue
fi
case "$file" in
src/locales/*) ;;
*) TRANSLATION_ONLY="false"; break ;;
esac
done <<< "$CHANGED"
echo "translation_only=$TRANSLATION_ONLY" >> "$GITHUB_OUTPUT"
echo "Translation only: $TRANSLATION_ONLY"
# Job for linting, type checking, unit testing
build-and-test:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Check out code
uses: actions/checkout@v3
# Cache node_modules
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22.21.0'
cache: 'yarn'
- name: Install Yarn
run: npm install -g yarn
# Step 3: Install dependencies and iOS Pods
- name: Install dependencies
run: yarn install
# Step 4: Validate l10n files
- name: Validate l10n files
run: node scripts/validate-l10n.js
# Step 5: Run linters (ESLint)
- name: Run ESLint
run: yarn lint
# Step 5: Run TypeScript type checks
- name: Run TypeScript type check
run: yarn typecheck
# Step 6: Run unit tests (Jest)
- name: Run unit tests
run: yarn test --coverage
# Job for Android build
build-android:
runs-on: ubuntu-latest
needs: [build-and-test, detect-changes]
if: needs.detect-changes.outputs.translation_only != 'true'
steps:
- name: Check out code
uses: actions/checkout@v3
# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22.21.0'
cache: 'yarn'
# Cache node_modules
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Create dummy google-services.json for CI
run: |
cat > android/app/google-services.json << 'EOL'
{
"project_info": {
"project_number": "000000000000",
"project_id": "dummy-project-for-ci",
"storage_bucket": "dummy-project-for-ci.appspot.com"
},
"client": [{
"client_info": {
"mobilesdk_app_id": "1:000000000000:android:0000000000000000",
"android_client_info": {
"package_name": "com.pocketpalai"
}
},
"api_key": [{
"current_key": "dummy-api-key-for-ci-builds"
}]
}]
}
EOL
- name: Create dummy .env file for CI
run: |
cat > .env << 'EOL'
FIREBASE_FUNCTIONS_URL=https://dummy-firebase-url.com
# PalsHub/Supabase Configuration
SUPABASE_URL=https://dummy-supabase-url.supabase.co
SUPABASE_ANON_KEY=dummy-anon-key-for-ci-builds
PALSHUB_API_BASE_URL=https://dummy-palshub-api.com
# App Configuration
APP_URL=pocketpal://app
# Feature Flags (true/false)
ENABLE_PALSHUB_INTEGRATION=true
ENABLE_AUTHENTICATION=true
ENABLE_OFFLINE_MODE=true
# Google Sign-In Configuration
GOOGLE_IOS_CLIENT_ID=dummy-ios-client-id.apps.googleusercontent.com
GOOGLE_WEB_CLIENT_ID=dummy-web-client-id.apps.googleusercontent.com
EOL
- name: Create dummy release keystore for CI
working-directory: android/app
run: |
# Generate a dummy keystore for CI builds
keytool -genkeypair -v \
-storetype PKCS12 \
-keystore pocketpal-release-key.keystore \
-alias pocketpal_key_alias \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-storepass dummy-ci-password \
-keypass dummy-ci-password \
-dname "CN=CI Build, OU=CI, O=PocketPal, L=CI, S=CI, C=US"
- name: Build Android Release
working-directory: android
env:
APP_RELEASE_STORE_PASSWORD: dummy-ci-password
APP_RELEASE_KEY_PASSWORD: dummy-ci-password
run: ./gradlew assembleRelease
- name: Upload Android APK
uses: actions/upload-artifact@v4
with:
name: android-release-apk
path: android/app/build/outputs/apk/release/app-release.apk
# Job for iOS build
build-ios:
runs-on: macos-15 # macOS 15 with Xcode 16
needs: [build-and-test, detect-changes]
if: needs.detect-changes.outputs.translation_only != 'true'
steps:
- name: Check out code
uses: actions/checkout@v3
# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22.21.0'
cache: 'yarn'
# Cache node_modules
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Create Env.xcconfig
run: |
cat > ios/Config/Env.xcconfig << 'EOL'
// This file contains environment-specific build settings.
GOOGLE_WEB_CLIENT_ID = dummy-web-client-id.apps.googleusercontent.com
REVERSED_GOOGLE_IOS_CLIENT_ID = com.googleusercontent.apps.dummy-ios-client-id
EOL
- name: Create dummy .env file for CI
run: |
cat > .env << 'EOL'
FIREBASE_FUNCTIONS_URL=https://dummy-firebase-url.com
# PalsHub/Supabase Configuration
SUPABASE_URL=https://dummy-supabase-url.supabase.co
SUPABASE_ANON_KEY=dummy-anon-key-for-ci-builds
PALSHUB_API_BASE_URL=https://dummy-palshub-api.com
# App Configuration
APP_URL=pocketpal://app
# Feature Flags (true/false)
ENABLE_PALSHUB_INTEGRATION=true
ENABLE_AUTHENTICATION=true
ENABLE_OFFLINE_MODE=true
# Google Sign-In Configuration
GOOGLE_IOS_CLIENT_ID=dummy-ios-client-id.apps.googleusercontent.com
GOOGLE_WEB_CLIENT_ID=dummy-web-client-id.apps.googleusercontent.com
EOL
- name: Create dummy GoogleService-Info.plist for CI
run: |
cat > ios/GoogleService-Info.plist << 'EOL'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>dummy-client-id.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.dummy-client-id</string>
<key>API_KEY</key>
<string>dummy-api-key-for-ci-builds</string>
<key>GCM_SENDER_ID</key>
<string>000000000000</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>ai.pocketpal</string>
<key>PROJECT_ID</key>
<string>dummy-project-for-ci</string>
<key>STORAGE_BUCKET</key>
<string>dummy-project-for-ci.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false/>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<key>IS_APPINVITE_ENABLED</key>
<false/>
<key>IS_GCM_ENABLED</key>
<true/>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:000000000000:ios:0000000000000000</string>
</dict>
</plist>
EOL
- name: Install CocoaPods dependencies
run: |
cd ios
pod install
cd ..
- name: Install xcpretty
run: gem install xcpretty
- name: Build iOS Release
run: |
cd ios
# List available simulators for debugging
xcrun simctl list devices available
set -o pipefail && xcodebuild \
-workspace PocketPal.xcworkspace \
-scheme PocketPal \
-configuration Release \
-sdk iphonesimulator \
-destination 'generic/platform=iOS Simulator' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
ONLY_ACTIVE_ARCH=NO \
| xcpretty