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

Feature react native tracer provider #53

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e15ec11
EMBR-3907 package setup
jpmunz Jun 17, 2024
42e8ba5
EMBR-4049 cleanup workspaces
jpmunz Jun 25, 2024
344ca37
EMBR-4049 try with corepack enable
jpmunz Jun 27, 2024
372edcb
EMBR-4049 remove docs, constraint on RN peer dependency
jpmunz Jul 3, 2024
272dd49
Merge branch 'master' into jpmunz/EMBR-4049-workspaces-cleanup
jpmunz Jul 3, 2024
b53f4fd
EMBR-4049 cleanup test file
jpmunz Jul 3, 2024
50a0b5a
Merge branch 'master' into jpmunz/EMBR-4049-workspaces-cleanup
jpmunz Jul 8, 2024
4d52426
EMBR-4049 remove link scripts
jpmunz Jul 8, 2024
5195262
EMBR-4049 yarn install, add files back to core
jpmunz Jul 8, 2024
8349bee
EMBR-4049 fix contraints
jpmunz Jul 8, 2024
1b81e19
EMBR-4049 add back top-level build
jpmunz Jul 8, 2024
f8c6b89
EMBR-4049 update core podspec to reference package.json
jpmunz Jul 8, 2024
4a029ae
EMBR-4049 add back react-native.config.js
jpmunz Jul 8, 2024
380298b
Merge pull request #35 from embrace-io/jpmunz/EMBR-3907-add-trace-pro…
jpmunz Jul 8, 2024
4912e1e
EMBR-4246 integration test setup
jpmunz Jul 8, 2024
8b845ab
Merge pull request #47 from embrace-io/jpmunz/EMBR-4246-tracer-provid…
jpmunz Jul 8, 2024
05297d0
rename native-tests -> native-src
jpmunz Jul 8, 2024
df5127a
Merge pull request #48 from embrace-io/jpmunz/rn-tracer-provider-andr…
jpmunz Jul 8, 2024
11261f2
EMBR-4245 more cleanup
jpmunz Jul 8, 2024
39343f5
EMBR-4245 linting
jpmunz Jul 8, 2024
88767e3
EMBR-4049 typescript needs to be available for each package for build…
jpmunz Jul 9, 2024
3b3aec9
Merge branch 'jpmunz/EMBR-4049-workspaces-cleanup' into feature-react…
jpmunz Jul 9, 2024
782b919
EMBR-4049 don't enforce file structure, too inconsistent
jpmunz Jul 9, 2024
efac649
Merge branch 'jpmunz/EMBR-4049-workspaces-cleanup' into feature-react…
jpmunz Jul 9, 2024
3691dff
EBMR-4247 JS layer for tracer provider (#49)
jpmunz Jul 11, 2024
dfe9810
Merge branch 'master' into feature-react-native-tracer-provider
jpmunz Jul 11, 2024
ed6e4a4
Merge branch 'master' into feature-react-native-tracer-provider
jpmunz Jul 12, 2024
59778bd
EMBR-4289 test updates after integration with android (#50)
jpmunz Jul 15, 2024
bcd5fc8
EMBR-4290 update JS tracer provider with extra guards (#51)
jpmunz Jul 15, 2024
795faef
backport changes from EMBR-4253
jpmunz Jul 15, 2024
a6f8533
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Sep 18, 2024
6f49325
update versions
jpmunz Sep 18, 2024
0ecf157
update version in packages/react-native-tracer-provider/package.json
jpmunz Sep 18, 2024
b4491d7
update yarn.lock
jpmunz Sep 18, 2024
2f39c04
fix test failure
jpmunz Sep 18, 2024
e4d4188
fix yarn build
jpmunz Sep 18, 2024
749902c
EMBR-3908 integrate android tracer provider (#54)
jpmunz Sep 19, 2024
7cbd156
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Sep 20, 2024
d9b2096
fix android lint
jpmunz Sep 20, 2024
55d72d5
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Sep 24, 2024
d2368ee
EMBR-3908 integrate iOS tracer provider (#140)
jpmunz Sep 24, 2024
c0385c7
update workflows to reference main
jpmunz Sep 24, 2024
0010432
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Sep 26, 2024
70820c9
bump to 5.0.0 for initial version
jpmunz Sep 26, 2024
b263ebc
EMBR-5129 fix tests due to opentelemetry upgrade, consistent represen…
jpmunz Sep 27, 2024
788536a
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Sep 27, 2024
5919b9b
EMBR-5135 fix ios tests in tracer provider package (#157)
jpmunz Oct 8, 2024
491a18b
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Oct 8, 2024
843b6c4
EMBR-4229 integration tests for using the otel navigation library (#158)
jpmunz Oct 8, 2024
02aa89e
EMBR-5028 apply file change strategy to android test workflow
jpmunz Oct 8, 2024
0d94c89
move useEmbraceNativeTracerProvider to its own file
jpmunz Oct 15, 2024
734a8fa
Merge branch 'main' into feature-react-native-tracer-provider
jpmunz Oct 16, 2024
8d4e716
remove extra android resource files
jpmunz Oct 16, 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
54 changes: 54 additions & 0 deletions .github/workflows/android.unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Android Unit Tests

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]
jdk-version: ["17"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node (${{ matrix.node-version }})
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Enables corepack
run: corepack enable

- uses: dorny/paths-filter@v2
id: changed_files
with:
list-files: shell
filters: |
android:
- 'packages/**/gradle.properties'
- 'packages/**/*.gradle'
- 'packages/**/*.kt'
- 'packages/**/*.java'

- name: Install Root Node Modules
run: yarn install
if: steps.changed_files.outputs.android == 'true'

- name: Install JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
if: steps.changed_files.outputs.android == 'true'

- name: Run Android Unit Tests
run: yarn run android:test $(./scopes-from-file-changes.ts ${{ steps.changed_files.outputs.android_files }})
if: steps.changed_files.outputs.android == 'true'
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build
dist
Pods
14 changes: 10 additions & 4 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ yarn lint
yarn test
```

## Manual integration testing
## Manual integration testing (TODO update after changes to integration testing workflow)

The [example app](examples/react-native-test-suite/) allows you to test out the React Native Embrace SDK in a representative app.

Expand Down Expand Up @@ -74,7 +74,7 @@ pushd ios; pod install; popd;
yarn ios --mode=Release
```

## Testing against new Embrace Android SDK versions
## Testing against new Embrace Android SDK versions (TODO update after changes to integration testing workflow)

You can test Embrace Android SDK changes by altering the dependency in the core package's [build.gradle](./packages/core/android/build.gradle).
And then either publish a local artifact or if you need CI to pass - publish a beta:
Expand All @@ -94,7 +94,7 @@ And then either publish a local artifact or if you need CI to pass - publish a b
4. Set the correct `embrace-android-sdk` version in `examples/react-native-test-suite/node_modules/embrace-io/android/build.gradle`
5. Run the app in the normal way

## Testing against new Embrace iOS SDK versions
## Testing against new Embrace iOS SDK versions (TODO update after changes to integration testing workflow)

### Local artifact

Expand All @@ -111,6 +111,12 @@ You can test local changes to the iOS SDK by updating the example app's `podspec
3. In `examples/react-native-test-suite/ios/Podfile`, add the following line `pod 'EmbraceIO-DEV'`
4. In `examples/react-native-test-suite/ios`, run the `pod update` command

## Updating native SDK dependencies

1. Bump the Android (SDK + Swazzler)/iOS dependencies to the latest available stable versions in `./yarn.config.cjs`
2. Run `yarn constraints --fix` to propagate this change to all package.json files
3. Run `yarn build` to update build files to the latest versions

## Automated integration testing

Automated integration testing is being actively developed to replace some of the manual testing outlined above, see [here](./integration-tests/README.md) for more details.
Expand All @@ -132,4 +138,4 @@ unreleased changes on `main` and a patch release will be cut from that new branc
7. Run an example app and point to the latest released packages to confirm basic behaviour
8. Update and publish the [Changelog](https://github.com/embrace-io/embrace-docs/blob/main/docs/react-native/changelog.md) for the release

NOTE: If you make a mistake while publishing you can remove the specific version w/ `npm unpublish <package-name>@<version>`, see [Unpublishing a single version of a package](https://docs.npmjs.com/unpublishing-packages-from-the-registry#unpublishing-a-single-version-of-a-package)
NOTE: If you make a mistake while publishing you can remove the specific version w/ `npm unpublish <package-name>@<version>`, see [Unpublishing a single version of a package](https://docs.npmjs.com/unpublishing-packages-from-the-registry#unpublishing-a-single-version-of-a-package)
74 changes: 46 additions & 28 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ verifications on the payloads that would have been sent to Embrace.
The harness uses WebdriverIO's [Testrunner](https://webdriver.io/docs/testrunner/) to spin up a [Appium](http://appium.io/docs/en/latest/intro/) client and server to perform the device automation. [Mockserver](https://www.mock-server.com/#what-is-mockserver) is
launched for the suite run so that requests sent from the device can be inspected.

```bash
npm install
```
```bash
npm install
```

For any future updates the [Appium Installer](https://webdriver.io/docs/appium) provides a handy setup wizard:

```bash
npx appium-installer
```
```bash
npx appium-installer
```

## Run tests

Make sure the test apps have the latest local @embrace-io/react-native changes:

```bash
npm run update-local-embrace
```
```bash
npm run update-local-embrace
```

Make sure the test apps are installed on the device/emulator before running tests. Note that building the debug variant
of the app may interfere with the tests as the debug menu gets in the way of UI elements.

Android can run in release mode:

```bash
cd basic-test-app
npx expo run:android --variant release
```
```bash
cd basic-test-app
npx expo run:android --variant release
```

For ios it doesn't apply the `--variant release` mode, so we can do it through xcode:

Expand All @@ -41,17 +41,17 @@ For ios it doesn't apply the `--variant release` mode, so we can do it through x
- Under the Run section, change the Build Configuration from Debug to Release.
- Press Cmd + R to build and run the app in release mode.

or simple run
or simply run

```bash
npx expo run:ios --configuration Release
```
```bash
npx expo run:ios --configuration Release
```

Run the test suite:

```bash
npm test
```
```bash
npm test
```

## Debugging tips

Expand All @@ -60,11 +60,11 @@ npm test
To help figure out the selectors to use for grabbing UI elements it can be useful to interact with Appium using
the Appium Inspector. First install the Appium server and drivers globally:

```bash
npm install -g appium
appium driver install uiautomator2 # android / ios
appium driver install xcuitest # ios
```
```bash
npm install -g appium
appium driver install uiautomator2 # android / ios
appium driver install xcuitest # ios
```

Then install [Appium Inspector](https://github.com/appium/appium-inspector)

Expand All @@ -73,12 +73,30 @@ Then install [Appium Inspector](https://github.com/appium/appium-inspector)
You can invoke the Mockserver and watch its output directly to get a look at the payloads it is receiving at different
endpoints (Note this may include some binary output that doesn't play nice with your terminal):

```bash
npx tsx helpers/invoke_embrace_server.ts
```
```bash
npx tsx helpers/invoke_embrace_server.ts
```

## CI

TODO for the moment the utility here is to be able to run tests locally during development, as a next task need to hook this up to
CI tools to verify a passing suite for new releases. Likely this means updating or creating a new `wdio.conf.ts` that
can be configured to point to a remote environment. See what capabilities are available for that [here](https://appium.io/docs/en/2.1/guides/caps/)

## Troubleshooting


### Appium gives 500 during test run

"Could not proxy command to remote server. Original error: Error: socket hang up"

Try:
```bash
# Android
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test

# iOS
xcrun simctl uninstall booted io.appium.uiautomator2.server
xcrun simctl uninstall booted io.appium.uiautomator2.server.test
```
2 changes: 1 addition & 1 deletion integration-tests/artifacts/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.tgz
*-local.tgz
Binary file not shown.
5 changes: 3 additions & 2 deletions integration-tests/basic-test-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ Use the following when creating `./ios/Embrace-Info.plist`:
Then build:

```bash
npx expo run:ios
pushd ios; pod install; popd
npx expo run:ios
```

## Pull in local @embrace-io/react-native changes

Because RN doesn't support symlinked packages whenever any changes are made under
packages/core (or any other local package that the test app depends on) they need to be copied into
the app's node_modules/, there is a script in integration-tests that manages this
the app's node_modules/, there is a script in integration-tests that manages this
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<data android:scheme="https"/>
</intent>
</queries>
<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">
<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" android:networkSecurityConfig="@xml/network_security_config">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
13 changes: 6 additions & 7 deletions integration-tests/basic-test-app/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default function TabLayout() {
<Tabs.Screen
name="index"
options={{
title: "Home",
title: "HOME",
tabBarAccessibilityLabel: "HOME",
tabBarIcon: ({color, focused}) => (
<TabBarIcon
name={focused ? "home" : "home-outline"}
Expand All @@ -27,14 +28,12 @@ export default function TabLayout() {
}}
/>
<Tabs.Screen
name="explore"
name="second"
options={{
title: "Explore",
title: "SECOND SCREEN",
tabBarAccessibilityLabel: "SECOND SCREEN",
tabBarIcon: ({color, focused}) => (
<TabBarIcon
name={focused ? "code-slash" : "code-slash-outline"}
color={color}
/>
<TabBarIcon name={"radio"} color={color} />
),
}}
/>
Expand Down
Loading
Loading