Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up CI for bob / rn compatibility matrix and handle non-standard codegen output dirs #163

Merged
merged 28 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a9059e
Set up CI for bob / rn compatibility matrix
Johennes Nov 13, 2024
3c62eb6
Shorten job name
Johennes Nov 13, 2024
54e1b43
Further shorten names
Johennes Nov 13, 2024
06a92cc
Appease prettier
Johennes Nov 13, 2024
2419811
Add missing \
Johennes Nov 13, 2024
d616f84
Allow mutable yarn installs
Johennes Nov 13, 2024
5d6c630
Install cargo-ndk if needed
Johennes Nov 13, 2024
f91d93e
Fix if statement
Johennes Nov 13, 2024
6df9a36
Install rust toolchains
Johennes Nov 13, 2024
fd0c748
Install Java 17
Johennes Nov 13, 2024
580acb8
Appease prettier once more
Johennes Nov 13, 2024
003c812
Add further bob versions
Johennes Nov 13, 2024
b408f62
Add bob 0.42.1
Johennes Nov 13, 2024
257884d
Remove 0.42.1
Johennes Nov 15, 2024
299e25d
Remove unused --ios-name parameter
Johennes Nov 15, 2024
90bbaca
Allow package.json mixins
Johennes Nov 15, 2024
3799a4f
Add package.json mixin to test matrix
Johennes Nov 15, 2024
3672ef4
Change fixtures path
Johennes Nov 15, 2024
0b08caa
Fix empty mixin name
Johennes Nov 15, 2024
88fb39c
Always use package.json mixin
Johennes Nov 15, 2024
8fd9c2d
Revert to standard paths and org scope
Johennes Nov 15, 2024
125cf24
Add missing slash
Johennes Nov 15, 2024
0cdd977
Switch back to custom codegen paths
Johennes Nov 15, 2024
2016643
Add badge
Johennes Nov 15, 2024
d75dc6f
Use 'latest'
Johennes Nov 15, 2024
f233d50
Rename PKG_JSON_MIXIN
Johennes Nov 20, 2024
bf3e7b9
Document cron expression
Johennes Nov 25, 2024
59bc61e
Handle non-standard codegen output dirs (#165)
Johennes Nov 26, 2024
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
59 changes: 59 additions & 0 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Compat

on:
schedule:
- cron: "0 0 * * *"
Johennes marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: ["main"]

env:
CARGO_TERM_COLOR: always

jobs:
integration-tests-generation:
strategy:
matrix:
runner:
- macos-latest
- ubuntu-latest
bob-version:
- 0.42.2
- 0.42.3
- latest
rn-version:
- 0.76.0
- latest
Comment on lines +19 to +25
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this.


runs-on: ${{ matrix.runner }}
name: "bob ${{ matrix.bob-version }} / rn ${{ matrix.rn-version }} / ${{ matrix.runner == 'macos-latest' && 'ios' || 'android' }}"

steps:
- uses: actions/checkout@v4

- name: Install cargo-ndk
if: ${{ matrix.runner != 'macos-latest' }}
run: |
cargo install cargo-ndk

- name: Install JDK
if: ${{ matrix.runner != 'macos-latest' }}
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- name: Install Rust toolchains
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.runner == 'macos-latest' && 'aarch64-apple-ios-sim' || 'aarch64-linux-android' }}

- name: Generate & build turbo module
run: |
./scripts/test-turbo-modules.sh \
--slug '@my-org/my-lib' \
--ubrn-config integration/fixtures/compat/ubrn.config.yaml \
--builder-bob-version ${{ matrix.bob-version }} \
--rn-version ${{ matrix.rn-version }} \
--packgage-json-mixin integration/fixtures/compat/package.json \
--${{ matrix.runner == 'macos-latest' && 'ios' || 'android' }} \
../turbo-module
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![CI](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/ci.yml/badge.svg)](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/ci.yml)
[![build-bob compatibility](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/compat.yml/badge.svg)](https://github.com/jhugman/uniffi-bindgen-react-native/actions/workflows/compat.yml)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻


# uniffi-bindgen-react-native
[UniFFI](https://mozilla.github.io/uniffi-rs/latest/) is a multi-language bindings generator for Rust.
Expand Down
8 changes: 8 additions & 0 deletions integration/fixtures/compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"codegenConfig": {
"outputDir": {
"ios": "ios/tmp",
"android": "android/tmp"
}
}
}
4 changes: 4 additions & 0 deletions integration/fixtures/compat/ubrn.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rust:
repo: https://github.com/ianthetechie/uniffi-starter
branch: main
manifestPath: rust/foobar/Cargo.toml
49 changes: 18 additions & 31 deletions scripts/test-turbo-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ reset_args() {
RN_VERSION=latest
PROJECT_SLUG=my-test-library
FORCE_NEW_DIR=false
IOS_NAME=MyTestLibrary
SKIP_IOS=true
SKIP_ANDROID=true
UBRN_CONFIG=
PKG_JSON_MIXIN=
Johennes marked this conversation as resolved.
Show resolved Hide resolved
APP_TSX=
}

Expand All @@ -25,10 +25,10 @@ usage() {
echo " -A, --android Build for Android."
echo " -I, --ios Build for iOS."
echo " -C, --ubrn-config Use a ubrn config file."
echo " -P, --packgage-json-mixin Merge another JSON file into package.json"
echo " -T, --app-tsx Use a App.tsx file."
echo
echo " -s, --slug PROJECT_SLUG Specify the project slug (default: my-test-library)."
echo " -i, --ios-name IOS_NAME Specify the iOS project name (default: MyTestLibrary)."
echo
echo " -u, --builder-bob-version VERSION Specify the version of builder-bob to use (default: latest)."
echo " -r, --rn-version VERSION Specify the version of React Native to use (default: latest)."
Expand All @@ -49,7 +49,6 @@ cleanup() {
diagnostics() {
echo "-- PROJECT_DIR = $PROJECT_DIR"
echo "-- PROJECT_SLUG = $PROJECT_SLUG"
echo "-- IOS_NAME = $IOS_NAME"
}

error() {
Expand Down Expand Up @@ -98,14 +97,14 @@ parse_cli_options() {
PROJECT_SLUG="$2"
shift
;;
-i|--ios-name)
IOS_NAME="$2"
shift
;;
-C|--ubrn-config)
UBRN_CONFIG=$(join_paths "$PWD" "$2")
shift
;;
-P|--packgage-json-mixin)
PKG_JSON_MIXIN=$(join_paths "$PWD" "$2")
shift
;;
-T|--app-tsx)
APP_TSX=$(join_paths "$PWD" "$2")
shift
Expand Down Expand Up @@ -169,10 +168,6 @@ create_library() {
rm -rf "$base" || error "Failed to remove existing directory $base"
fi

local example_type
if [ "$BOB_VERSION" == "latest" ] ; then
example_type=vanilla
fi
echo "-- Creating library $PROJECT_SLUG with create-react-native-library@$BOB_VERSION"
npm_config_yes=true npx "create-react-native-library@$BOB_VERSION" \
--react-native-version "$RN_VERSION" \
Expand All @@ -184,7 +179,7 @@ create_library() {
--repo-url "https://github.com/jhugman/$PROJECT_SLUG" \
--languages cpp \
--type module-new \
--example $example_type \
--example vanilla \
--local false \
"$base"
exit_dir
Expand All @@ -193,15 +188,15 @@ create_library() {
install_dependencies() {
enter_dir "$PROJECT_DIR"
# touch yarn.lock
yarn || error "Failed to install dependencies"
yarn --no-immutable || error "Failed to install dependencies"
# rm yarn.lock
exit_dir
}

install_example_dependencies() {
enter_dir "$PROJECT_DIR/example"
# touch yarn.lock
yarn || error "Failed to install example dependencies"
yarn --no-immutable || error "Failed to install example dependencies"
# rm yarn.lock
# rm -Rf .yarn
exit_dir
Expand Down Expand Up @@ -303,6 +298,10 @@ generate_turbo_module_for_compiling() {
clean_turbo_modules
"$UBRN_BIN" checkout --config "$UBRN_CONFIG"
cp "$UBRN_CONFIG" ./ubrn.config.yaml
if [ -f "$PKG_JSON_MIXIN" ] ; then
jq -s '.[0] * .[1]' ./package.json "$PKG_JSON_MIXIN" > ./package.json.new
mv ./package.json.new ./package.json
fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat.

if [ -f "$APP_TSX" ] ; then
cp "$APP_TSX" ./example/src/App.tsx
fi
Expand All @@ -329,8 +328,8 @@ build_android_example() {
echo "-- Running ubrn build android"
"$UBRN_BIN" build android --config "$UBRN_CONFIG" --and-generate --targets aarch64-linux-android
exit_dir
enter_dir "$PROJECT_DIR/example/android"
./gradlew build || error "Failed to build Android example"
enter_dir "$PROJECT_DIR/example"
yarn build:android || error "Failed to build Android example"
exit_dir
}

Expand All @@ -342,19 +341,9 @@ build_ios_example() {
enter_dir "$PROJECT_DIR/example/ios"
echo "pod 'uniffi-bindgen-react-native', :path => '../../node_modules/uniffi-bindgen-react-native'" >> Podfile
pod install || error "Cannot run Podfile"

# Find the UDID of the first booted device, or fall back to the first available device
udid=$(xcrun simctl list --json devices | jq -r '.devices[][] | select(.state == "Booted") | .udid')
if [ "$udid" == "null" ]; then
udid=$(xcrun simctl list --json devices | jq -r '.devices[][] | select(.isAvailable == true) | .udid' | head -n 1)
xcrun simctl boot "$udid"
fi

if [ "$udid" == "null" ]; then
error "No available iOS simulator found"
fi

xcodebuild -workspace "${IOS_NAME}Example.xcworkspace" -scheme "${IOS_NAME}Example" -configuration Debug -destination "id=$udid" || error "Failed to build iOS example"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see how you're getting rid of IOS_NAME now.

exit_dir
enter_dir "$PROJECT_DIR/example"
yarn build:ios --extra-params "ARCHS=$(uname -m)" || error "Failed to build iOS example"
exit_dir
}

Expand Down Expand Up @@ -479,7 +468,6 @@ run_for_builder_bob() {
--builder-bob-version "$builder_bob_version" \
--slug react-native-dummy-lib-for-ios \
--ios \
--ios-name DummyLibForIos \
"$working_dir/react-native-dummy-lib-for-ios"
fi

Expand All @@ -502,7 +490,6 @@ run_for_builder_bob() {
--builder-bob-version "$builder_bob_version" \
--ios \
--app-tsx "$app_tsx" \
--ios-name ReactNativeDummyLibForIos \
--slug @my-org/react-native-dummy-lib-for-ios \
"$working_dir/@my-org/react-native-dummy-lib-for-ios"
fi
Expand Down
Loading