Skip to content

Commit 3068f2e

Browse files
authored
Merge pull request #21 from powersync-ja/expo-50-upgrade
[Update] Expo 50 and iOS test build job
2 parents d15f093 + 8bfab94 commit 3068f2e

File tree

30 files changed

+5920
-5416
lines changed

30 files changed

+5920
-5416
lines changed

.github/workflows/test.yaml

+54-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55

66
jobs:
77
test:
8-
name: Test
9-
runs-on: ubuntu-latest
8+
name: Test Android
9+
runs-on: ubuntu-xl
1010
env:
1111
AVD_NAME: ubuntu-avd-x86_64-31
1212
steps:
@@ -38,10 +38,10 @@ jobs:
3838
node-version: 18
3939
cache: 'yarn'
4040

41-
- name: Set up JDK 11
41+
- name: Set up JDK 17
4242
uses: actions/setup-java@v3
4343
with:
44-
java-version: 11
44+
java-version: 17
4545
distribution: 'adopt'
4646
cache: 'gradle'
4747

@@ -71,14 +71,62 @@ jobs:
7171
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
7272
script: echo "Generated AVD snapshot for caching."
7373

74-
- name: Run connected tests
74+
- name: Run connected Android tests
7575
uses: ReactiveCircus/[email protected]
7676
with:
7777
api-level: 31
7878
target: google_apis
7979
arch: x86_64
8080
avd-name: $AVD_NAME
81-
script: cd tests && yarn test --avdName $AVD_NAME
81+
script: cd tests && yarn test-android --avdName $AVD_NAME
8282
force-avd-creation: false
8383
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
8484
disable-animations: true
85+
86+
test-ios:
87+
name: Test iOS (Only build)
88+
runs-on: macOS-13
89+
steps:
90+
- uses: actions/checkout@v4
91+
with:
92+
persist-credentials: false
93+
94+
- uses: irgaly/xcode-cache@v1
95+
with:
96+
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
97+
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-
98+
99+
- name: CocoaPods Cache
100+
uses: actions/cache@v3
101+
id: cocoapods-cache
102+
with:
103+
path: |
104+
tests/ios/Pods/*
105+
key: ${{ runner.os }}-${{ hashFiles('tests/ios/Podfile.lock') }}
106+
107+
- name: Setup NodeJS
108+
uses: actions/setup-node@v2
109+
with:
110+
node-version: 18
111+
cache: 'yarn'
112+
113+
- name: Setup Yarn
114+
run: |
115+
npm install -g yarn
116+
echo "Yarn version: $(yarn -v)"
117+
118+
- name: Install Dependencies
119+
run: yarn install --frozen-lockfile
120+
121+
- name: Configure Test App
122+
run: |
123+
cd tests
124+
yarn install --frozen-lockfile
125+
126+
- name: Install Cocoapods
127+
run: |
128+
cd tests/ios && pod install
129+
130+
- name: Build iOS
131+
run: |
132+
cd tests && yarn build-ios

tests/android/app/build.gradle

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34

45
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
@@ -11,11 +12,11 @@ react {
1112
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
1213
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
1314
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
14-
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
15+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
1516

1617
// Use Expo CLI to bundle the app, this ensures the Metro config
1718
// works correctly with Expo projects.
18-
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
19+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
1920
bundleCommand = "export:embed"
2021

2122
/* Folders */
@@ -79,7 +80,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
7980
android {
8081
ndkVersion rootProject.ext.ndkVersion
8182

82-
compileSdkVersion rootProject.ext.compileSdkVersion
83+
buildToolsVersion rootProject.ext.buildToolsVersion
84+
compileSdk rootProject.ext.compileSdkVersion
8385

8486
namespace 'com.reactnativequicksqlite.tests'
8587
defaultConfig {
@@ -112,6 +114,11 @@ android {
112114
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
113115
}
114116
}
117+
packagingOptions {
118+
jniLibs {
119+
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
120+
}
121+
}
115122
}
116123

117124
// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -141,33 +148,22 @@ dependencies {
141148
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
142149
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
143150
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
144-
def frescoVersion = rootProject.ext.frescoVersion
145-
146-
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
147-
if (isGifEnabled || isWebpEnabled) {
148-
implementation("com.facebook.fresco:fresco:${frescoVersion}")
149-
implementation("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}")
150-
}
151151

152152
if (isGifEnabled) {
153153
// For animated gif support
154-
implementation("com.facebook.fresco:animated-gif:${frescoVersion}")
154+
implementation("com.facebook.fresco:animated-gif:${reactAndroidLibs.versions.fresco.get()}")
155155
}
156156

157157
if (isWebpEnabled) {
158158
// For webp support
159-
implementation("com.facebook.fresco:webpsupport:${frescoVersion}")
159+
implementation("com.facebook.fresco:webpsupport:${reactAndroidLibs.versions.fresco.get()}")
160160
if (isWebpAnimatedEnabled) {
161161
// Animated webp support
162-
implementation("com.facebook.fresco:animated-webp:${frescoVersion}")
162+
implementation("com.facebook.fresco:animated-webp:${reactAndroidLibs.versions.fresco.get()}")
163163
}
164164
}
165165

166-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
167-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
168-
exclude group:'com.squareup.okhttp3', module:'okhttp'
169-
}
170-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
166+
implementation("com.facebook.react:flipper-integration")
171167

172168
if (hermesEnabled.toBoolean()) {
173169
implementation("com.facebook.react:hermes-android")
@@ -176,5 +172,5 @@ dependencies {
176172
}
177173
}
178174

179-
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
175+
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
180176
applyNativeModulesAppBuildGradle(project)

tests/android/app/src/debug/java/com/reactnativequicksqlite/tests/ReactNativeFlipper.java

-75
This file was deleted.

tests/android/app/src/main/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
</queries>
1414
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
1515
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
16-
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="49.0.0"/>
16+
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="50.0.0"/>
1717
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
1818
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
19-
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
19+
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
2020
<intent-filter>
2121
<action android:name="android.intent.action.MAIN"/>
2222
<category android:name="android.intent.category.LAUNCHER"/>

tests/android/app/src/main/java/com/reactnativequicksqlite/tests/MainActivity.java

-65
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.reactnativequicksqlite.tests
2+
3+
import android.os.Build
4+
import android.os.Bundle
5+
6+
import com.facebook.react.ReactActivity
7+
import com.facebook.react.ReactActivityDelegate
8+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
9+
import com.facebook.react.defaults.DefaultReactActivityDelegate
10+
11+
import expo.modules.ReactActivityDelegateWrapper
12+
13+
class MainActivity : ReactActivity() {
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
// Set the theme to AppTheme BEFORE onCreate to support
16+
// coloring the background, status bar, and navigation bar.
17+
// This is required for expo-splash-screen.
18+
setTheme(R.style.AppTheme);
19+
super.onCreate(null)
20+
}
21+
22+
/**
23+
* Returns the name of the main component registered from JavaScript. This is used to schedule
24+
* rendering of the component.
25+
*/
26+
override fun getMainComponentName(): String = "main"
27+
28+
/**
29+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
30+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
31+
*/
32+
override fun createReactActivityDelegate(): ReactActivityDelegate {
33+
return ReactActivityDelegateWrapper(
34+
this,
35+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
36+
object : DefaultReactActivityDelegate(
37+
this,
38+
mainComponentName,
39+
fabricEnabled
40+
){})
41+
}
42+
43+
/**
44+
* Align the back button behavior with Android S
45+
* where moving root activities to background instead of finishing activities.
46+
* @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
47+
*/
48+
override fun invokeDefaultOnBackPressed() {
49+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
50+
if (!moveTaskToBack(false)) {
51+
// For non-root activities, use the default implementation to finish them.
52+
super.invokeDefaultOnBackPressed()
53+
}
54+
return
55+
}
56+
57+
// Use the default back button implementation on Android S
58+
// because it's doing more than [Activity.moveTaskToBack] in fact.
59+
super.invokeDefaultOnBackPressed()
60+
}
61+
}

0 commit comments

Comments
 (0)