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

WIP: Draft: fix CI integration on iOS #425

Closed
wants to merge 25 commits into from
Closed
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
107 changes: 96 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,100 @@
---
language: node_js
node_js:
- 8

cache:
directories:
- node_modules
matrix:
include:
- language: objective-c
osx_image: xcode10.3

install:
- yarn
branches:
only:
- master

script:
- yarn run lint
- yarn run test
cache:
directories:
- node_modules
- $TRAVIS_HOME/.cache/sccache
- $TRAVIS_HOME/.cargo/
- $TRAVIS_HOME/.rustup/
- target

install:
- brew tap wix/brew
- brew install applesimutils
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
- nvm install 8
- nvm use 8
- nvm alias default 8
- npm install -g yarn
- npm install -g react-native-cli
- npm install -g detox-cli
- gem install xcpretty
- curl https://sh.rustup.rs -sSf | sh -s -- -y
- source $HOME/.cargo/env
- rustup target add i386-apple-ios
- rustup target add x86_64-apple-ios
- rustup target add armv7-apple-ios
- rustup target add armv7s-apple-ios
- rustup target add aarch64-apple-ios
- travis_wait mvn install
- yarn
- cd rust/signer && make ios && cd ../..

script:
- detox build -c ios.sim.release
- detox test -c ios.sim.release

# TODO Android part need to be complete with NDK set
# - language: android
## env:
## - REACT_NATIVE_VERSION=0.59.4
# android:
# components:
# - tools
# - platform-tools
# - build-tools-28.0.3
# - android-28
# - extra-google-google_play_services
# - extra-google-m2repository
# - extra-android-m2repository
## - sys-img-x86-android-26
# - sys-img-x86-android-28
#
# cache:
# directories:
# - node_modules
# - $TRAVIS_HOME/.cache/sccache
# - $TRAVIS_HOME/.cargo/
# - $TRAVIS_HOME/.rustup/
# - target
#
# install:
# - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
# - export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
# - nvm install 8
# - nvm use 8
# - nvm alias default 8
# - npm install -g yarn
# - npm install -g react-native-cli
# - npm install -g detox-cli
# - travis_wait 10 mvn install
# - yes | sdkmanager "build-tools;28.0.3"
# - yarn
#
# script:
# - detox build -c android.emu.release
# - detox test -c android.emu.release

- language: node_js
node_js: 8

cache:
directories:
- node_modules

install:
- yarn

script:
- yarn run lint
- yarn run test
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,34 @@ Corresponding data:
}
```

#### Integration Test

Parity Signer is integrated with [Detox](https://github.com/wix/Detox) E2E testing. And Detox has very detailed [documentation](https://github.com/wix/Detox/blob/master/docs/README.md).

First make sure `detox-cli` is installed as global dependency with

```
npm install -g detox-cli
```

##### Complete Test
just run `yarn e2e:ios` or `yarn e2e:android`.

##### Develop and Test
Details please refer to Detox official [Documentation](https://github.com/wix/Detox/blob/master/docs/Guide.DevelopingWhileWritingTests.md)

Once you have run `yarn ios` you do not need to build it, just run:
```shell
yarn test-e2e:ios
```
This command will open another simulator with the pre-defined configurations.

Re-run tests without re-installing the app
```
yarn test-e2e:ios --reuse
```
On Android is same, just replace `ios` with `android`, since Detox's Android support is in progress, when there is an error just build it again with `yarn build-e2e:android`

### Troubleshooting

#### `No dimension set for key window` on Android < 5.0
Expand Down
19 changes: 17 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 28
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -107,7 +108,7 @@ android {

defaultConfig {
applicationId "io.parity.signer"
minSdkVersion 16
minSdkVersion 18
missingDimensionStrategy 'react-native-camera', 'general'
targetSdkVersion 28
versionCode 308
Expand All @@ -119,6 +120,8 @@ android {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
}
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
release {
Expand Down Expand Up @@ -146,6 +149,8 @@ android {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// Detox-specific additions to pro-guard
// proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
// applicationVariants are e.g. debug, release
Expand Down Expand Up @@ -179,6 +184,16 @@ dependencies {
} else {
implementation 'org.webkit:android-jsc:+'
}
androidTestImplementation('com.wix:detox:+') { transitive = true }
androidTestImplementation 'junit:junit:4.12'
}

configurations.all {
resolutionStrategy {
// the line below is required for Detox since version 14.5.0;
// it should removed as soon as the project compiles without it
force 'androidx.annotation:annotation:1.0.0'
}
}

// Run this once to be able to run the application with BUCK
Expand Down
24 changes: 24 additions & 0 deletions android/app/src/androidTest/java/io/parity/signer/DetoxTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.parity.signer;

import com.wix.detox.Detox;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {

@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void runDetoxTests() {
Detox.runTests(mActivityRule);
}
}
20 changes: 16 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
minSdkVersion = 18
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
kotlinVersion = '1.3.41'
}

repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.4.2')

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -35,6 +35,10 @@ allprojects {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
// All of Detox' artifacts are provided via the npm module
url "$rootDir/../node_modules/detox/Detox-android"
}
}
}

Expand All @@ -47,4 +51,12 @@ subprojects {
}
}
}
}
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
}
}
}
}
6 changes: 6 additions & 0 deletions e2e/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
15 changes: 15 additions & 0 deletions e2e/firstTest.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import testIDs from "./testIDs";

describe('Load test', () => {
beforeEach(async () => {
await device.reloadReactNative();
});

it('should have account list screen', async () => {
await expect(element(by.id(testIDs.TacScreen.tacView))).toBeVisible();
await element(by.id(testIDs.TacScreen.agreePrivacyButton)).tap();
await element(by.id(testIDs.TacScreen.agreeTacButton)).tap();
await element(by.id(testIDs.TacScreen.nextButton)).tap();
await expect(element(by.id(testIDs.AccountListScreen.accountList))).toBeVisible();
});
});
25 changes: 25 additions & 0 deletions e2e/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');

// Set the default timeout
jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);

// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => {
await detox.init(config);
});

beforeEach(async () => {
await adapter.beforeEach();
});

afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
13 changes: 13 additions & 0 deletions e2e/testIDs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const testIDs = {
TacScreen: {
tacView: 'tac_view',
agreeTacButton: 'tac_agree',
agreePrivacyButton: 'tac_privacy',
nextButton: 'tac_next'
},
AccountListScreen: {
accountList: 'accountList',
}
};

export default testIDs;
Loading