Skip to content

Commit d50b490

Browse files
Test Native Build (#981)
* add native build * make gradlew executable * clear gradle cache * fix yaml * setup java 17 * bumg capacitor cli from vue sample * WIP * bump gradle and fix min target * test * test * more WIP * java setup * split sample build into new file * restrict new job content to read * migrate to workflow * removes branch filter * debug workflow * move back to old style * wrong version * use different ref * move to one workflow logic * correct build key * same folder * permission * wrong path * code cleanup * use specific version * fix nits * incorrect env name * other upload name * prettier ci name * use generic iphone * temporary remove xcpretty * add build exit code * ci: trigger workflow
1 parent b0454ae commit d50b490

File tree

7 files changed

+248
-136
lines changed

7 files changed

+248
-136
lines changed

.github/workflows/buildandtest.yml

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ env:
1414
${{ github.workspace }}/dist
1515
1616
BUILD_CACHE_KEY: ${{ github.sha }}
17+
permissions:
18+
contents: read
19+
actions: read
1720

1821
jobs:
1922
job_install_deps:
@@ -32,7 +35,7 @@ jobs:
3235
id: compute_lockfile_hash
3336
run: echo "hash=${{ hashFiles('yarn.lock') }}" >> "$GITHUB_OUTPUT"
3437
- name: Check dependency cache
35-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
38+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
3639
id: cache_dependencies
3740
with:
3841
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
@@ -56,12 +59,12 @@ jobs:
5659
- name: Set up Node
5760
uses: actions/setup-node@v5
5861
- name: Check dependency cache
59-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
62+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
6063
with:
6164
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
6265
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
6366
- name: Check build cache
64-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
67+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
6568
id: cache_built_packages
6669
with:
6770
path: ${{ env.CACHED_BUILD_PATHS }}
@@ -94,54 +97,6 @@ jobs:
9497
# `job_build` can't see `job_install_deps` and what it returned)
9598
dependency_cache_key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
9699

97-
job_sample_test:
98-
name: Sample Build Test
99-
needs: job_build
100-
# macos required for the xcode build.
101-
runs-on: macos-latest
102-
strategy:
103-
matrix:
104-
include:
105-
- bump: 'v6'
106-
- bump: 'v7'
107-
- bump: 'sample-vue'
108-
steps:
109-
- name: Check out current commit (${{ github.sha }})
110-
uses: actions/checkout@v4
111-
- run: corepack enable
112-
- name: Set up Node
113-
uses: actions/setup-node@v5
114-
- name: Check dependency cache
115-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
116-
with:
117-
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
118-
key: ${{ needs.job_build.outputs.dependency_cache_key }}
119-
- name: Check build cache
120-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
121-
with:
122-
path: ${{ env.CACHED_BUILD_PATHS }}
123-
key: ${{ env.BUILD_CACHE_KEY }}
124-
- name: Install yalc
125-
run: yarn global add yalc
126-
- name: Install Ionic
127-
run: yarn global add @ionic/cli
128-
129-
- name: Download Sentry Capacitor package
130-
uses: actions/download-artifact@v4
131-
with:
132-
name: yalc-package
133-
path: ~/.yalc/packages/@sentry/capacitor/ # Ensure this path matches where yalc expects to find the package
134-
135-
- name: Publish test broken node.
136-
working-directory: example/broken_node_module
137-
run: |
138-
yarn install
139-
yarn build
140-
yalc publish
141-
142-
- name: Build Sample ${{ matrix.bump }}
143-
run: yarn run bump:${{ matrix.bump }}
144-
145100
job_unit_test:
146101
name: Test
147102
needs: job_build
@@ -155,12 +110,12 @@ jobs:
155110
- name: Set up Node
156111
uses: actions/setup-node@v5
157112
- name: Check dependency cache
158-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
113+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
159114
with:
160115
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
161116
key: ${{ needs.job_build.outputs.dependency_cache_key }}
162117
- name: Check build cache
163-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
118+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
164119
with:
165120
path: ${{ env.CACHED_BUILD_PATHS }}
166121
key: ${{ env.BUILD_CACHE_KEY }}
@@ -178,12 +133,12 @@ jobs:
178133
- name: Set up Node
179134
uses: actions/setup-node@v5
180135
- name: Check dependency cache
181-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
136+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
182137
with:
183138
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
184139
key: ${{ needs.job_build.outputs.dependency_cache_key }}
185140
- name: Check build cache
186-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
141+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # V4.2.4
187142
with:
188143
path: ${{ env.CACHED_BUILD_PATHS }}
189144
key: ${{ env.BUILD_CACHE_KEY }}
@@ -195,3 +150,11 @@ jobs:
195150
name: ${{ github.sha }}
196151
path: |
197152
${{ github.workspace }}/sentry-capacitor-*
153+
154+
job_sample_build:
155+
name: Sample Build
156+
needs: job_build
157+
uses: ./.github/workflows/sample-build.yml
158+
with:
159+
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
160+
build_cache_key: ${{ github.sha }}

.github/workflows/sample-build.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: 'Sample Build'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dependency_cache_key:
7+
required: true
8+
type: string
9+
build_cache_key:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
actions: read
16+
17+
env:
18+
CACHED_DEPENDENCY_PATHS: |
19+
${{ github.workspace }}/node_modules
20+
CACHED_BUILD_PATHS: |
21+
${{ github.workspace }}/dist
22+
BUILD_CACHE_KEY: ${{ inputs.build_cache_key }}
23+
24+
jobs:
25+
job_sample_build:
26+
name: Sample Build (${{ matrix.bump }})
27+
runs-on: macos-latest
28+
strategy:
29+
matrix:
30+
include:
31+
- bump: 'v6'
32+
SAMPLE_DIR: 'example/ionic-angular-v6'
33+
JAVA_VERSION: '17'
34+
- bump: 'v7'
35+
SAMPLE_DIR: 'example/ionic-angular-v7'
36+
JAVA_VERSION: '21'
37+
- bump: 'sample-vue'
38+
SAMPLE_DIR: 'example/ionic-vue3'
39+
JAVA_VERSION: '17'
40+
steps:
41+
- name: Check out current commit (${{ github.sha }})
42+
uses: actions/checkout@v4
43+
- run: corepack enable
44+
- name: Set up Node
45+
uses: actions/setup-node@v5
46+
- name: Check dependency cache
47+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
48+
with:
49+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
50+
key: ${{ inputs.dependency_cache_key }}
51+
- name: Check build cache
52+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
53+
with:
54+
path: ${{ env.CACHED_BUILD_PATHS }}
55+
key: ${{ env.BUILD_CACHE_KEY }}
56+
- name: Install yalc
57+
run: yarn global add yalc
58+
- name: Install Ionic
59+
run: yarn global add @ionic/cli
60+
61+
- name: Download Sentry Capacitor package
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: yalc-package
65+
path: ~/.yalc/packages/@sentry/capacitor/
66+
67+
- name: Publish test broken node.
68+
working-directory: example/broken_node_module
69+
run: |
70+
yarn install
71+
yarn build
72+
yalc publish
73+
74+
- name: Build Sample ${{ matrix.bump }}
75+
run: yarn run bump:${{ matrix.bump }}
76+
77+
- name: Set up Java ${{ matrix.JAVA_VERSION }}
78+
uses: actions/setup-java@v4
79+
with:
80+
distribution: temurin
81+
java-version: ${{ matrix.JAVA_VERSION }}
82+
83+
- name: Make gradlew executable
84+
working-directory: ${{ matrix.SAMPLE_DIR }}/android
85+
run: chmod +x ./gradlew
86+
87+
- name: Configure Android build compatibility
88+
working-directory: ${{ matrix.SAMPLE_DIR }}/android
89+
run: |
90+
echo "android.useFullClasspathForDexingTransform=true" >> gradle.properties
91+
echo "android.enableR8.fullMode=false" >> gradle.properties
92+
93+
- name: Android build (Gradle)
94+
working-directory: ${{ matrix.SAMPLE_DIR }}/android
95+
env:
96+
GRADLE_OPTS: -Dorg.gradle.daemon=false
97+
run: ./gradlew --no-daemon assembleDebug
98+
99+
- name: Upload Android APK
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: ${{ matrix.bump }}-android-apk
103+
if-no-files-found: warn
104+
path: |
105+
${{ matrix.SAMPLE_DIR }}/android/app/build/outputs/apk/debug/*.apk
106+
107+
- name: Install xcpretty
108+
run: sudo gem install xcpretty --no-document
109+
110+
- name: iOS pod install
111+
working-directory: ${{ matrix.SAMPLE_DIR }}/ios/App
112+
run: pod install --repo-update
113+
114+
- name: iOS build (xcodebuild)
115+
working-directory: ${{ matrix.SAMPLE_DIR }}/ios/App
116+
run: |
117+
xcodebuild -workspace App.xcworkspace \
118+
-scheme App \
119+
-configuration Debug \
120+
-sdk iphonesimulator \
121+
-destination 'platform=iOS Simulator,name=iPhone 16' \
122+
build | xcpretty && exit ${PIPESTATUS[0]}
123+
124+
- name: Upload iOS build logs
125+
uses: actions/upload-artifact@v4
126+
with:
127+
name: ${{ matrix.bump }}-ios-build-logs
128+
if-no-files-found: warn
129+
path: |
130+
~/Library/Logs/Diagnostics/*

example/ionic-vue3/android/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
4+
55
repositories {
66
google()
77
mavenCentral()
@@ -22,6 +22,15 @@ allprojects {
2222
google()
2323
mavenCentral()
2424
}
25+
// Force a Kotlin stdlib version compatible with AGP 8 and D8
26+
configurations.all { config ->
27+
resolutionStrategy.eachDependency { details ->
28+
if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name.startsWith('kotlin-stdlib')) {
29+
details.useVersion '1.9.24'
30+
details.because 'Ensure Kotlin stdlib is compatible with current Android build tools'
31+
}
32+
}
33+
}
2534
}
2635

2736
task clean(type: Delete) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#Wed Sep 17 07:55:22 BRT 2025
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
4-
networkTimeout=10000
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

example/ionic-vue3/android/variables.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ext {
22
minSdkVersion = 22
3-
compileSdkVersion = 33
4-
targetSdkVersion = 33
3+
compileSdkVersion = 34
4+
targetSdkVersion = 34
55
androidxActivityVersion = '1.7.0'
66
androidxAppCompatVersion = '1.6.1'
77
androidxCoordinatorLayoutVersion = '1.2.0'
@@ -13,4 +13,4 @@ ext {
1313
androidxJunitVersion = '1.1.5'
1414
androidxEspressoCoreVersion = '3.5.1'
1515
cordovaAndroidVersion = '10.1.1'
16-
}
16+
}

example/ionic-vue3/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"lint": "eslint ."
1616
},
1717
"dependencies": {
18-
"@capacitor/android": "5.6.0",
19-
"@capacitor/app": "5.0.6",
20-
"@capacitor/core": "5.6.0",
21-
"@capacitor/haptics": "5.0.6",
22-
"@capacitor/ios": "5.6.0",
23-
"@capacitor/keyboard": "5.0.7",
24-
"@capacitor/status-bar": "5.0.6",
18+
"@capacitor/android": "^6.0.0",
19+
"@capacitor/app": "^6.0.0",
20+
"@capacitor/core": "^6.0.0",
21+
"@capacitor/haptics": "^6.0.0",
22+
"@capacitor/ios": "^6.0.0",
23+
"@capacitor/keyboard": "^6.0.0",
24+
"@capacitor/status-bar": "^6.0.0",
2525
"@ionic/vue": "^7.0.0",
2626
"@ionic/vue-router": "^7.0.0",
2727
"@sentry/capacitor": "file:.yalc/@sentry/capacitor",
@@ -34,7 +34,7 @@
3434
"vue-router": "^4.2.0"
3535
},
3636
"devDependencies": {
37-
"@capacitor/cli": "5.6.0",
37+
"@capacitor/cli": "^6.0.0",
3838
"@vitejs/plugin-legacy": "^5.0.0",
3939
"@vitejs/plugin-vue": "^4.0.0",
4040
"@vue/eslint-config-typescript": "^12.0.0",

0 commit comments

Comments
 (0)