diff --git a/.buildkite/react-native-cli-pipeline.yml b/.buildkite/react-native-cli-pipeline.yml index fa58e4a27..03369ce57 100644 --- a/.buildkite/react-native-cli-pipeline.yml +++ b/.buildkite/react-native-cli-pipeline.yml @@ -72,8 +72,19 @@ steps: env: REACT_NATIVE_VERSION: "rn0_63_expo_ejected" + - label: ':runner: RN 0.64 CLI tests' + depends_on: "cli-maze-image" + timeout_in_minutes: 20 + plugins: + docker-compose#v3.7.0: + run: react-native-cli-tool-maze-runner + use-aliases: true + command: ["features/cli-tests"] + env: + REACT_NATIVE_VERSION: "rn0_64" + # - # Built app test fixtures + # Built app test fixtures - Android # - label: ':docker: Build RN Android Builder image' key: 'android-builder-image' @@ -161,6 +172,24 @@ steps: artifact_paths: - build/rn0_63_expo_ejected.apk + - label: ':android: Init and build RN 0.64 apk' + key: 'rn-0-64-apk' + depends_on: + - 'android-builder-image' + timeout_in_minutes: 15 + env: + DEBUG: true + REACT_NATIVE_VERSION: rn0_64 + plugins: + - docker-compose#v3.7.0: + run: react-native-cli-android-builder + command: ["features/build-app-tests/build-android-app.feature"] + artifact_paths: + - build/rn0_64.apk + + # + # Built app test fixtures - iOS + # - label: ':ios: Init and build RN 0.60 ipa' key: 'rn-0-60-ipa' timeout_in_minutes: 30 @@ -216,8 +245,19 @@ steps: commands: - test/react-native-cli/scripts/init-and-build-test.sh rn0_63_expo_ejected + - label: ':ios: Init and build RN 0.64 ipa' + key: 'rn-0-64-ipa' + timeout_in_minutes: 30 + agents: + queue: 'opensource-mac-cocoa-11' + env: + DEBUG: true + artifact_paths: build/rn0_64.ipa + commands: + - test/react-native-cli/scripts/init-and-build-test.sh rn0_64 + # - # Init, build and notify end-to-end tests + # Init, build and notify end-to-end tests - Android # - label: ':runner: RN 0.60 Android end-to-end tests' depends_on: "rn-0-60-apk" @@ -314,6 +354,28 @@ steps: concurrency: 9 concurrency_group: 'browserstack-app' + - label: ':runner: RN 0.64 Android end-to-end tests' + depends_on: "rn-0-64-apk" + timeout_in_minutes: 10 + plugins: + artifacts#v1.2.0: + download: "build/rn0_64.apk" + docker-compose#v3.7.0: + pull: react-native-cli-maze-runner + run: react-native-cli-maze-runner + use-aliases: true + command: + - --app=build/rn0_64.apk + - --farm=bs + - --device=ANDROID_11_0 + - --a11y-locator + - features/run-app-tests + concurrency: 9 + concurrency_group: 'browserstack-app' + + # + # Init, build and notify end-to-end tests - iOS + # - label: ':runner: RN 0.60 iOS end-to-end tests' depends_on: "rn-0-60-ipa" timeout_in_minutes: 10 @@ -408,3 +470,22 @@ steps: - features/run-app-tests concurrency: 9 concurrency_group: 'browserstack-app' + + - label: ':runner: RN 0.64 iOS end-to-end tests' + depends_on: "rn-0-64-ipa" + timeout_in_minutes: 10 + plugins: + artifacts#v1.2.0: + download: "build/rn0_64.ipa" + docker-compose#v3.7.0: + pull: react-native-cli-maze-runner + run: react-native-cli-maze-runner + use-aliases: true + command: + - --app=build/rn0_64.ipa + - --farm=bs + - --device=IOS_14 + - --a11y-locator + - features/run-app-tests + concurrency: 9 + concurrency_group: 'browserstack-app' diff --git a/test/react-native-cli/TESTING.md b/test/react-native-cli/TESTING.md index d7948b701..e4ca5283b 100644 --- a/test/react-native-cli/TESTING.md +++ b/test/react-native-cli/TESTING.md @@ -1,6 +1,6 @@ ### React-native CLI testing -The react-native CLI come in three parts: +The react-native CLI tests come in three parts: - CLI tests, that don't require any remote connections or special setup - Testing an app build, which requires your local machine to be set up for building iOS and Android applications @@ -12,11 +12,11 @@ The CLI tests target the command line interface by providing a set of responses ##### Setting up -1. Run through the initial setup +1. Run through the initial setup in [TESTING.md](../../TESTING.md) 1. Run `npm pack packages/react-native-cli/` to pack the react-native-cli package 1. Copy the resulting package, `bugsnag-react-native-cli-{VERSION}.tgz` into the target fixture, e.g.: ```shell script - cp bugsnag-react-native-cli-*.tgz test/react-native-cli/features/fixtures/rn0_60/ + cp bugsnag-react-native-cli-*.tgz test/react-native-cli/features/fixtures/rn0_64 ``` ##### Running @@ -26,7 +26,7 @@ The CLI tests target the command line interface by providing a set of responses 1. Install maze-runner with `bundle install` 1. Run the full set of cli tests targeting a specific react-native version (`rn0_61` for example): ```shell script - REACT_NATIVE_VERSION=rn0_61 bundle exec maze-runner features/cli-tests + REACT_NATIVE_VERSION=rn0_64 bundle exec maze-runner features/cli-tests ``` #### Build tests @@ -94,3 +94,67 @@ particular, these commands need the `BrowserStackLocal` binary (available --bs-local=~/BrowserStackLocal \ features/run-app-tests ``` + +#### Creating a new test fixture + +When each new version of React Native is released, a new test fixture project "shell" should be created. The inner +workings of the app (that exercise the test scenarios) are then copied in dynamically by the build process. There are +several steps to follow to create the project shell: + +1. Add a new service to docker-compose.yml for the new fixture + +1. Create a new React Native project of the desired version. E.g: + ``` + npx react-native init rn0_64 --version 0.64 + ``` +1. Remove the following files/folders, if they exist: +Remove +- \_\_tests\_\_ +- .eslintrc.js + +1. Create a `.dockerignore` file: + ``` + # Ignore lockfiles as they can influence test runs + package-lock.json + yarn.lock + ``` + +1. Add the following to `.gitignore`: + ``` + # Ignore lockfiles as they can influence test runs + package-lock.json + yarn.lock + ``` + +1. Copy the following files from an existing fixture: + - `App.js` (overwriting) + - `ios/rn0_xx/CrashyCrashy.h` + - `ios/rn0_xx/CrashyCrashy.m` + +1. Android (using existing test fixtures as a guide): + + 1. In app/src/main/AndroidManifest.xml, add: + ``` + android:usesCleartextTraffic="true" + ``` + 1. Add CrashyModule.java and CrashyPackage.java from an existing test fixture, updating the package name + + 1. In MainApplication.java, add: + ``` + packages.add(new CrashyPackage()); + ``` + +1. Disable Flipper by removing the following from the `Podfile` and running `pod install`. + Flipper doesn't benefit the test fixture and removing it significantly speeds up the build. + ``` + use_flipper!() + ``` + +1. For iOS: + 1. Add to `rn_0_xx/Info.plist`: + ``` + NSAllowsArbitraryLoads + + ``` + 1. Open the workspace and add `CrashyCrashy.h` and `CrashyCrashy.m` to the project. + 1. Set the Bugsnag development team on the project. diff --git a/test/react-native-cli/features/fixtures/docker-compose.yml b/test/react-native-cli/features/fixtures/docker-compose.yml index 584662428..0301468ba 100755 --- a/test/react-native-cli/features/fixtures/docker-compose.yml +++ b/test/react-native-cli/features/fixtures/docker-compose.yml @@ -44,6 +44,17 @@ services: aliases: - maze-runner + rn0_64: + build: + context: rn0_64 + dockerfile: ../Dockerfile + environment: + DEBUG: + networks: + default: + aliases: + - maze-runner + rn0_63_expo_ejected: build: context: rn0_63_expo_ejected diff --git a/test/react-native-cli/features/fixtures/rn0_64/.buckconfig b/test/react-native-cli/features/fixtures/rn0_64/.buckconfig new file mode 100644 index 000000000..934256cb2 --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/test/react-native-cli/features/fixtures/rn0_64/.dockerignore b/test/react-native-cli/features/fixtures/rn0_64/.dockerignore new file mode 100644 index 000000000..02f7caec5 --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.dockerignore @@ -0,0 +1,3 @@ +# Ignore lockfiles as they can influence test runs +package-lock.json +yarn.lock diff --git a/test/react-native-cli/features/fixtures/rn0_64/.flowconfig b/test/react-native-cli/features/fixtures/rn0_64/.flowconfig new file mode 100644 index 000000000..315f2747b --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.flowconfig @@ -0,0 +1,66 @@ +[ignore] +; We fork some components by platform +.*/*[.]android.js + +; Ignore "BUCK" generated dirs +/\.buckd/ + +; Ignore polyfills +node_modules/react-native/Libraries/polyfills/.* + +; Flow doesn't support platforms +.*/Libraries/Utilities/LoadingView.js + +[untyped] +.*/node_modules/@react-native-community/cli/.*/.* + +[include] + +[libs] +node_modules/react-native/interface.js +node_modules/react-native/flow/ + +[options] +emoji=true + +esproposal.optional_chaining=enable +esproposal.nullish_coalescing=enable + +exact_by_default=true + +module.file_ext=.js +module.file_ext=.json +module.file_ext=.ios.js + +munge_underscores=true + +module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' +module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState + +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn +signature-verification-failure=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import + +[version] +^0.137.0 diff --git a/test/react-native-cli/features/fixtures/rn0_64/.gitattributes b/test/react-native-cli/features/fixtures/rn0_64/.gitattributes new file mode 100644 index 000000000..45a3dcb2a --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.gitattributes @@ -0,0 +1,3 @@ +# Windows files should use crlf line endings +# https://help.github.com/articles/dealing-with-line-endings/ +*.bat text eol=crlf diff --git a/test/react-native-cli/features/fixtures/rn0_64/.gitignore b/test/react-native-cli/features/fixtures/rn0_64/.gitignore new file mode 100644 index 000000000..72c6e8111 --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.gitignore @@ -0,0 +1,63 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore +!debug.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# Bundle artifact +*.jsbundle + +# CocoaPods +/ios/Pods/ + +# Ignore lockfiles as they can influence test runs +package-lock.json +yarn.lock diff --git a/test/react-native-cli/features/fixtures/rn0_64/.prettierrc.js b/test/react-native-cli/features/fixtures/rn0_64/.prettierrc.js new file mode 100644 index 000000000..84196d95f --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + bracketSpacing: false, + jsxBracketSameLine: true, + singleQuote: true, + trailingComma: 'all', + arrowParens: 'avoid', +}; diff --git a/test/react-native-cli/features/fixtures/rn0_64/.watchmanconfig b/test/react-native-cli/features/fixtures/rn0_64/.watchmanconfig new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/react-native-cli/features/fixtures/rn0_64/App.js b/test/react-native-cli/features/fixtures/rn0_64/App.js new file mode 100644 index 000000000..2651b3979 --- /dev/null +++ b/test/react-native-cli/features/fixtures/rn0_64/App.js @@ -0,0 +1,108 @@ +import React from 'react'; +import Bugsnag from "@bugsnag/react-native"; +import { + SafeAreaView, + StyleSheet, + ScrollView, + View, + Text, + StatusBar, + Button, NativeModules +} from 'react-native'; + +import { + Colors +} from 'react-native/Libraries/NewAppScreen'; + +function jsNotify() { + try { // execute crashy code + iMadeThisUp(); + } catch (error) { + console.log('Bugsnag.notify JS error') + Bugsnag.notify(error); + } +} + +function nativeNotify() { + console.log('Bugsnag.notify native error') + NativeModules.CrashyCrashy.handledError() +} + +const App: () => React$Node = () => { + return ( + <> + + + + {global.HermesInternal == null ? null : ( + + Engine: Hermes + + )} + + React Native CLI end-to-end test app +