Skip to content

Commit 4b1e2d1

Browse files
committed
fix(ci): Avoid unnecessary runner allocation by splitting platform matrix into separate jobs
1 parent 1b4777d commit 4b1e2d1

2 files changed

Lines changed: 344 additions & 209 deletions

File tree

.github/workflows/sample-application-expo.yml

Lines changed: 119 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -34,96 +34,65 @@ jobs:
3434
caller_event_name: ${{ github.event_name }}
3535
caller_ref: ${{ github.ref }}
3636

37-
build:
38-
name: Build ${{ matrix.platform }} ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks}}
39-
runs-on: ${{ matrix.runs-on }}
37+
build-ios:
38+
name: Build ios ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks }}
39+
runs-on: ["ghcr.io/cirruslabs/macos-tahoe-xcode:26.2.0", "runner_group_id:10"]
4040
needs: [diff_check, detect-changes]
41-
if: ${{ needs.diff_check.outputs.skip_ci != 'true' && needs.detect-changes.outputs.needs_sample_expo == 'true' }}
41+
if: >-
42+
${{
43+
needs.diff_check.outputs.skip_ci != 'true'
44+
&& needs.detect-changes.outputs.needs_sample_expo == 'true'
45+
&& (needs.detect-changes.outputs.sample_expo == 'true' || needs.detect-changes.outputs.needs_ios == 'true')
46+
}}
4247
env:
4348
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
4449
strategy:
45-
# we want that the matrix keeps running, default is to cancel them if it fails.
4650
fail-fast: false
4751
matrix:
4852
ios-use-frameworks: ['no-frameworks', 'dynamic-frameworks']
49-
platform: ['android', 'ios']
5053
build-type: ['dev', 'production']
51-
include:
52-
- platform: ios
53-
runs-on: ["ghcr.io/cirruslabs/macos-tahoe-xcode:26.2.0", "runner_group_id:10"]
54-
- platform: android
55-
runs-on: ubuntu-latest
56-
- platform: web
57-
runs-on: ubuntu-latest
58-
exclude:
59-
- platform: 'android'
60-
ios-use-frameworks: 'dynamic-frameworks'
6154
steps:
6255
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
6356

64-
- name: Check if platform is needed
65-
id: platform-check
66-
uses: ./.github/actions/platform-check
67-
with:
68-
platform: ${{ matrix.platform }}
69-
sample_changed: ${{ needs.detect-changes.outputs.sample_expo }}
70-
needs_ios: ${{ needs.detect-changes.outputs.needs_ios }}
71-
needs_android: ${{ needs.detect-changes.outputs.needs_android }}
72-
needs_web: ${{ needs.detect-changes.outputs.needs_web }}
73-
74-
- name: Enable Corepack (NPM)
75-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform != 'ios' }}
76-
run: npm i -g corepack
77-
7857
- name: Enable Corepack
79-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'ios' }}
8058
run: corepack enable
8159

8260
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
83-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
8461
with:
8562
package-manager-cache: false
8663
node-version: 20
8764
cache: 'yarn'
8865
cache-dependency-path: yarn.lock
8966

9067
- uses: ruby/setup-ruby@v1
91-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'ios' }}
9268
with:
9369
working-directory: samples/expo
9470
ruby-version: '3.3.0' # based on what is used in the sample
9571
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
9672
cache-version: 1 # cache the installed gems
9773

9874
- uses: actions/setup-java@v5
99-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
10075
with:
10176
java-version: '17'
10277
distribution: 'adopt'
10378

10479
- name: Gradle cache
105-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
10680
uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0
10781

10882
- name: Setup Global Xcode Tools
109-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'ios' }}
11083
run: which xcbeautify || brew install xcbeautify
11184

11285
- name: Install SDK Dependencies
113-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
11486
run: yarn install
11587

11688
- name: Build SDK
117-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
11889
run: yarn build
11990

12091
- name: Prebuild apps
121-
if: ${{ steps.platform-check.outputs.skip != 'true' && (matrix.platform == 'android' || matrix.platform == 'ios') }}
12292
working-directory: samples/expo
12393
run: npx expo prebuild
12494

12595
- name: Install App Pods
126-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'ios' }}
12796
working-directory: samples/expo/ios
12897
run: |
12998
[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
@@ -134,19 +103,7 @@ jobs:
134103
PRODUCTION=$ENABLE_PROD pod install
135104
cat Podfile.lock | grep $RN_SENTRY_POD_NAME
136105
137-
- name: Build Android App
138-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'android' }}
139-
working-directory: samples/expo/android
140-
env:
141-
# Increase memory for Expo SDK 55 lint tasks
142-
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g"
143-
run: |
144-
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
145-
echo "Building $CONFIG"
146-
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86
147-
148106
- name: Build iOS App
149-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'ios' }}
150107
working-directory: samples/expo/ios
151108
env:
152109
# Fix for Xcode 26+ with MetalToolchain: use default Xcode toolchain to avoid
@@ -171,21 +128,124 @@ jobs:
171128
| tee xcodebuild.log \
172129
| xcbeautify --quieter --is-ci --disable-colored-output
173130
174-
- name: Build Web App
175-
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'web' }}
131+
- name: Export Expo
176132
working-directory: samples/expo
177133
run: |
178-
npx expo export -p web
134+
npx expo export
135+
136+
- name: Upload logs
137+
if: ${{ always() }}
138+
uses: actions/upload-artifact@v7
139+
with:
140+
name: build-sample-expo-ios-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
141+
path: samples/expo/ios/*.log
142+
143+
build-android:
144+
name: Build android ${{ matrix.build-type }}
145+
runs-on: ubuntu-latest
146+
needs: [diff_check, detect-changes]
147+
if: >-
148+
${{
149+
needs.diff_check.outputs.skip_ci != 'true'
150+
&& needs.detect-changes.outputs.needs_sample_expo == 'true'
151+
&& (needs.detect-changes.outputs.sample_expo == 'true' || needs.detect-changes.outputs.needs_android == 'true')
152+
}}
153+
env:
154+
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
155+
strategy:
156+
fail-fast: false
157+
matrix:
158+
build-type: ['dev', 'production']
159+
steps:
160+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
161+
162+
- name: Enable Corepack (NPM)
163+
run: npm i -g corepack
164+
165+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
166+
with:
167+
package-manager-cache: false
168+
node-version: 20
169+
cache: 'yarn'
170+
cache-dependency-path: yarn.lock
171+
172+
- uses: actions/setup-java@v5
173+
with:
174+
java-version: '17'
175+
distribution: 'adopt'
176+
177+
- name: Gradle cache
178+
uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0
179+
180+
- name: Install SDK Dependencies
181+
run: yarn install
182+
183+
- name: Build SDK
184+
run: yarn build
185+
186+
- name: Prebuild apps
187+
working-directory: samples/expo
188+
run: npx expo prebuild
189+
190+
- name: Build Android App
191+
working-directory: samples/expo/android
192+
env:
193+
# Increase memory for Expo SDK 55 lint tasks
194+
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g"
195+
run: |
196+
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
197+
echo "Building $CONFIG"
198+
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86
179199
180200
- name: Export Expo
181-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
182201
working-directory: samples/expo
183202
run: |
184203
npx expo export
185204
186205
- name: Upload logs
187-
if: ${{ always() && steps.platform-check.outputs.skip != 'true' }}
206+
if: ${{ always() }}
188207
uses: actions/upload-artifact@v7
189208
with:
190-
name: build-sample-expo-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
191-
path: samples/expo/${{ matrix.platform }}/*.log
209+
name: build-sample-expo-android-${{ matrix.build-type }}-logs
210+
path: samples/expo/android/*.log
211+
212+
build-web:
213+
name: Build web
214+
runs-on: ubuntu-latest
215+
needs: [diff_check, detect-changes]
216+
if: >-
217+
${{
218+
needs.diff_check.outputs.skip_ci != 'true'
219+
&& needs.detect-changes.outputs.needs_sample_expo == 'true'
220+
&& (needs.detect-changes.outputs.sample_expo == 'true' || needs.detect-changes.outputs.needs_web == 'true')
221+
}}
222+
env:
223+
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
224+
steps:
225+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
226+
227+
- name: Enable Corepack (NPM)
228+
run: npm i -g corepack
229+
230+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
231+
with:
232+
package-manager-cache: false
233+
node-version: 20
234+
cache: 'yarn'
235+
cache-dependency-path: yarn.lock
236+
237+
- name: Install SDK Dependencies
238+
run: yarn install
239+
240+
- name: Build SDK
241+
run: yarn build
242+
243+
- name: Build Web App
244+
working-directory: samples/expo
245+
run: |
246+
npx expo export -p web
247+
248+
- name: Export Expo
249+
working-directory: samples/expo
250+
run: |
251+
npx expo export

0 commit comments

Comments
 (0)