Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflow-scripts/okhttp3-compat.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import org.gradle.api.GradleException
import org.gradle.api.artifacts.component.ModuleComponentIdentifier

// Keep the normal build on the version in the catalog. This init script is only
// used by the compatibility job, so its compile and test classpaths use OkHttp 3.
// This catches new OkHttp 4-only calls before they need reverting (e.g. #60318).
gradle.beforeProject { project ->
if (project.path != ':packages:react-native:ReactAndroid') {
return
}

def okhttpVersion = '3.14.9'
project.configurations.configureEach { configuration ->
configuration.resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.squareup.okhttp3') {
details.useVersion(okhttpVersion)
details.because('Check ReactAndroid source compatibility with OkHttp 3')
}
}
}

project.plugins.withId('com.android.library') {
project.tasks.register('verifyOkHttp3Compatibility') { task ->
task.group = 'verification'
task.description = 'Compiles and tests ReactAndroid against OkHttp 3.14.9.'
task.dependsOn('testDebugUnitTest')
task.doLast {
[
'debugCompileClasspath',
'debugRuntimeClasspath',
'debugUnitTestCompileClasspath',
'debugUnitTestRuntimeClasspath',
].each { name ->
def configuration = project.configurations.getByName(name)
def modules = configuration.incoming.resolutionResult.allComponents
.collect { it.id }
.findAll { it instanceof ModuleComponentIdentifier && it.group == 'com.squareup.okhttp3' }
if (modules.isEmpty() || modules.any { it.version != okhttpVersion }) {
throw new GradleException("Expected OkHttp ${okhttpVersion} on ${project.path}:${name}, found: ${modules}")
}
project.logger.lifecycle("Verified ${project.path}:${name}: ${modules}")
}
}
}
}
}
35 changes: 35 additions & 0 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,41 @@ jobs:
release-type: dry-run
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

test_android_okhttp3:
runs-on: 8-core-ubuntu
needs: check_code_changes
if: |
needs.check_code_changes.outputs.any_code_change == 'true' &&
needs.check_code_changes.outputs.should_test_android == 'true'
container:
image: reactnativecommunity/react-native-android:latest
env:
LC_ALL: C.UTF8
TERM: 'dumb'
GRADLE_OPTS: '-Dorg.gradle.daemon=false'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Install node dependencies
uses: ./.github/actions/yarn-install
- name: Setup gradle
uses: ./.github/actions/setup-gradle
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
- name: Compile and test ReactAndroid with OkHttp 3.14.9
run: |
./gradlew --init-script .github/workflow-scripts/okhttp3-compat.gradle \
:packages:react-native:ReactAndroid:verifyOkHttp3Compatibility
- name: Upload test results
if: ${{ always() }}
uses: ./.github/actions/upload-artifact
with:
name: android-okhttp3-results
path: packages/react-native/ReactAndroid/build/reports/tests/testDebugUnitTest/
if-no-files-found: ignore

test_e2e_android_rntester:
needs: build_android
if: ${{ needs.build_android.result == 'success' }}
Expand Down
Loading