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

Add RN CLI tests for RN 0.64 (non-Hermes) #1448

Merged
merged 16 commits into from
Jun 29, 2021
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
85 changes: 83 additions & 2 deletions .buildkite/react-native-cli-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
72 changes: 68 additions & 4 deletions test/react-native-cli/TESTING.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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`:
```
<key>NSAllowsArbitraryLoads</key>
<true/>
```
1. Open the workspace and add `CrashyCrashy.h` and `CrashyCrashy.m` to the project.
1. Set the Bugsnag development team on the project.
11 changes: 11 additions & 0 deletions test/react-native-cli/features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
3 changes: 3 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore lockfiles as they can influence test runs
package-lock.json
yarn.lock
66 changes: 66 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.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/\(.*\)$' -> '<PROJECT_ROOT>/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\)$' -> '<PROJECT_ROOT>/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
3 changes: 3 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
63 changes: 63 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.gitignore
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/react-native-cli/features/fixtures/rn0_64/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading