Skip to content

Commit

Permalink
Gradle version testing (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
laves authored Feb 9, 2024
1 parent 200be94 commit 14cd24e
Show file tree
Hide file tree
Showing 30 changed files with 725 additions and 386 deletions.
65 changes: 55 additions & 10 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ on:
push:
branches: [ main ]
paths:
- '.github/workflows/example.yml'
- 'example/**'
- '**'
- '!example/README.md'
- '!README.md'
- '!test/**'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- '.github/workflows/example.yml'
- 'example/**'
- '**'
- '!example/README.md'
- '!README.md'
- '!test/**'

jobs:
build-android:
Expand All @@ -22,6 +24,22 @@ jobs:
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
include:
- node-version: 16.x
gradle-version: 6.5
agp-version: 4.1.3
java-version: 11
rn-version: 0.65.3
- node-version: 18.x
gradle-version: 7.5
agp-version: 7.4.2
java-version: 11
rn-version: 0.71.12
- node-version: 20.x
gradle-version: 8.2
agp-version: 8.2.2
java-version: 17
rn-version: 0.72.10

steps:
- uses: actions/checkout@v3
Expand All @@ -31,12 +49,37 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
- name: Use JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Use Gradle ${{ matrix.gradle-version }}
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ matrix.gradle-version }}

- name: Inject AGP version
run: echo agpVersion="${{ matrix.agp-version }}" >> local.properties
working-directory: example/android

- name: Install dependencies
run: yarn bootstrap

- name: Change React Native versions
run: yarn upgrade react-native@${{ matrix.rn-version }}
working-directory: example

- name: Copy project files
if: ${{ (matrix.gradle-version == '8.2') || (matrix.gradle-version == '6.5')}}
run: sh copy.sh
working-directory: resources/.test/gradle_${{ matrix.gradle-version }}

- name: Generate gradle wrapper
run: gradle wrapper --gradle-version ${{ matrix.gradle-version }} --distribution-type all
working-directory: example/android

- name: Build bundle
run: yarn example android-bundle

Expand All @@ -45,7 +88,7 @@ jobs:
working-directory: example/android

build-ios:
runs-on: macos-latest
runs-on: macos-12

strategy:
matrix:
Expand All @@ -59,8 +102,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
- name: Setup Cocoapods 1.14.3
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.14.3

- name: Install dependencies
run: yarn bootstrap
Expand All @@ -76,4 +121,4 @@ jobs:
-scheme VoiceProcessorExample
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO
working-directory: example/ios
working-directory: example/ios
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:
paths:
- '**'
- '!README.md'
- '!example/README.md'
- '!example/**'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- '**'
- '!README.md'
- '!example/README.md'
- '!example/**'

defaults:
run:
Expand Down
13 changes: 12 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:7.4.2"
}
}

Expand All @@ -28,6 +28,17 @@ def getExtOrIntegerDefault(name) {
}

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "ai.picovoice.reactnative.voiceprocessor"
}

if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
buildFeatures {
buildConfig = true
}
}

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
Expand Down
11 changes: 10 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ def reactNativeArchitectures() {
}

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "ai.picovoice.reactnative.voiceprocessorexample"
}

if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
buildFeatures {
buildConfig = true
}
}
compileSdk rootProject.ext.compileSdkVersion

namespace "ai.picovoice.reactnative.voiceprocessorexample"
defaultConfig {
applicationId "ai.picovoice.reactnative.voiceprocessorexample"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down
13 changes: 0 additions & 13 deletions example/android/app/src/debug/AndroidManifest.xml

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ai.picovoice.reactnative.voiceprocessorexample">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ public void onCreate() {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
}

This file was deleted.

16 changes: 15 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@ buildscript {
google()
mavenCentral()
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def agpVersion = localProperties.getProperty('agpVersion')
if (agpVersion == null) {
agpVersion = '7.4.2'
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "com.android.tools.build:gradle:$agpVersion"
classpath 'com.facebook.react:react-native-gradle-plugin'
}
}
Loading

0 comments on commit 14cd24e

Please sign in to comment.