generated from salesforce/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 6
222 lines (188 loc) · 6.36 KB
/
pr-checks.yml
File metadata and controls
222 lines (188 loc) · 6.36 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
name: PR Validation
# Trigger on pull requests to dev and pushes to dev (for verification)
on:
pull_request:
branches: [ dev ]
push:
branches: [ dev ]
# Cancel in-progress runs for the same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Job 1: Fast checks (lint, format, typecheck)
lint-and-typecheck:
name: Lint & Type Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run ESLint
run: npm run lint
- name: Check formatting
run: npm run format
- name: Run TypeScript type check
run: npm run typecheck
# Job 2: Unit tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint-and-typecheck # Only run if lint passes
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run tests
run: npm test -- --coverage --maxWorkers=2
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Job 3: Build validation matrix (parallel builds)
build-validation:
name: Build ${{ matrix.platform }} - ${{ matrix.variant }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: unit-tests # Only run if tests pass
strategy:
fail-fast: false # Don't cancel other builds if one fails
matrix:
include:
# Android builds (Linux runner)
- platform: Android
variant: Service Agent
os: ubuntu-latest
setup-script: node installandroid.js service
build-script: npm run build:android:service
cache-paths: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
cache-key: gradle
- platform: Android
variant: Employee Agent
os: ubuntu-latest
setup-script: node installandroid.js employee
build-script: npm run build:android:employee
cache-paths: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
cache-key: gradle
# iOS builds (macOS runner)
- platform: iOS
variant: Service Agent
os: macos-14
setup-script: node installios.js service
build-script: npm run build:ios:service
cache-paths: ios/Pods
cache-key: pods
- platform: iOS
variant: Employee Agent
os: macos-14
setup-script: node installios.js employee
build-script: npm run build:ios:employee
cache-paths: ios/Pods
cache-key: pods
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
# Java setup for Android builds
- name: Setup Java (Android only)
if: matrix.platform == 'Android'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
# Ruby setup for iOS builds (CocoaPods)
- name: Setup Ruby (iOS only)
if: matrix.platform == 'iOS'
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false
# Install CocoaPods for iOS
- name: Install CocoaPods (iOS only)
if: matrix.platform == 'iOS'
run: |
gem install cocoapods -v 1.15.2
pod --version
# Install XcodeGen for iOS
- name: Install XcodeGen (iOS only)
if: matrix.platform == 'iOS'
run: |
brew install xcodegen
xcodegen --version
# Cache Gradle for Android
- name: Cache Gradle dependencies (Android only)
if: matrix.platform == 'Android'
uses: actions/cache@v4
with:
path: ${{ matrix.cache-paths }}
key: ${{ runner.os }}-${{ matrix.cache-key }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-${{ matrix.cache-key }}-
# Cache CocoaPods for iOS
- name: Cache CocoaPods (iOS only)
if: matrix.platform == 'iOS'
uses: actions/cache@v4
with:
path: ${{ matrix.cache-paths }}
key: ${{ runner.os }}-${{ matrix.cache-key }}-${{ hashFiles('ios/Podfile.*.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.cache-key }}-
- name: Install npm dependencies
run: npm ci --legacy-peer-deps --ignore-scripts
- name: Run platform setup
run: ${{ matrix.setup-script }}
- name: Build ${{ matrix.platform }} - ${{ matrix.variant }}
run: ${{ matrix.build-script }}
# Upload build logs on failure for debugging
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.platform }}-${{ matrix.variant }}
path: |
android/app/build/outputs/**/*.log
ios/build/Logs/**
retention-days: 7
if-no-files-found: ignore
# Summary job - all checks must pass
all-checks-passed:
name: All Checks Passed ✓
runs-on: ubuntu-latest
needs: [lint-and-typecheck, unit-tests, build-validation]
if: always()
steps:
- name: Check if all jobs succeeded
run: |
if [[ "${{ needs.lint-and-typecheck.result }}" != "success" ]] || \
[[ "${{ needs.unit-tests.result }}" != "success" ]] || \
[[ "${{ needs.build-validation.result }}" != "success" ]]; then
echo "❌ One or more checks failed"
exit 1
fi
echo "✅ All PR checks passed!"