Skip to content

Commit 1db3d6b

Browse files
wojteg1337Trancever
authored andcommitted
feat: add e2e setup with CircleCi integration (#24)
1 parent 87fc5b9 commit 1db3d6b

File tree

18 files changed

+518
-263
lines changed

18 files changed

+518
-263
lines changed

.circleci/config.yml

Lines changed: 62 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,70 @@
1-
# -------------------------
2-
# DEFAULTS
3-
# -------------------------
4-
defaults: &defaults
5-
working_directory: ~/react-native-image-editor
6-
environment:
7-
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
1+
version: 2.1
82

9-
# LINUX
10-
linux_defaults: &linux_defaults
11-
<<: *defaults
12-
docker:
13-
- image: circleci/node:8
14-
environment:
15-
- PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
3+
orbs:
4+
rn: react-native-community/[email protected]
165

17-
# ANDROID
18-
android_defaults: &android_defaults
19-
<<: *defaults
20-
docker:
21-
- image: circleci/android:api-27-node8-alpha
22-
resource_class: "large"
23-
environment:
24-
- TERM: "dumb"
25-
- ADB_INSTALL_TIMEOUT: 10
26-
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
27-
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
28-
- BUILD_THREADS: 2
29-
30-
# MACOS
31-
macos_defaults: &macos_defaults
32-
<<: *defaults
33-
resource_class: "large"
34-
macos:
35-
xcode: "10.1.0"
36-
37-
# -------------------------
38-
# ALIASES
39-
# -------------------------
40-
41-
aliases:
42-
# CACHE
43-
- &restore-yarn-cache
44-
keys:
45-
- yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
46-
- yarn-cache-{{ arch }}
47-
- &save-yarn-cache
48-
paths:
49-
- ~/.cache/yarn
50-
- ~/Library/Detox/ios
51-
key: yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
52-
53-
- &restore-gradle-cache
54-
keys:
55-
- gradle-cache-{{ checksum "android/build.gradle" }}-{{ checksum "example/android/build.gradle" }}-{{ checksum "example/android/app/build.gradle" }}
56-
- &save-gradle-cache
57-
paths:
58-
- ~/.gradle
59-
key: gradle-cache-{{ checksum "android/build.gradle" }}-{{ checksum "example/android/build.gradle" }}-{{ checksum "example/android/app/build.gradle" }}
60-
61-
# INSTALLATION
62-
- &yarn
63-
name: Yarn Install
64-
command: |
65-
yarn install --network-concurrency 1 --non-interactive --cache-folder ~/.cache/yarn & wait
66-
67-
# ANALYSE
68-
- &eslint
69-
name: ESLint Checks
70-
command: yarn test:eslint
71-
72-
- &flow
73-
name: Flow Checks
74-
command: yarn test:flow
75-
76-
# - &jest
77-
# name: Jest Unit Tests
78-
# command: yarn test:jest
79-
80-
# -------------------------
81-
# JOBS
82-
# -------------------------
83-
version: 2
846
jobs:
85-
# Set up a Linux environment for downstream jobs
86-
linux-checkout:
87-
<<: *linux_defaults
88-
steps:
89-
- checkout
90-
- restore-cache: *restore-yarn-cache
91-
- run: rm -rf node_modules
92-
- run: yarn cache clean
93-
- run: *yarn
94-
- save-cache: *save-yarn-cache
95-
- persist_to_workspace:
96-
root: .
97-
paths: .
98-
99-
eslint:
100-
<<: *linux_defaults
101-
steps:
102-
- attach_workspace:
103-
at: ~/react-native-image-editor
104-
- run: *eslint
105-
106-
flow:
107-
<<: *linux_defaults
108-
steps:
109-
- attach_workspace:
110-
at: ~/react-native-image-editor
111-
- run: *flow
112-
113-
# jest:
114-
# <<: *linux_defaults
115-
# steps:
116-
# - attach_workspace:
117-
# at: ~/react-native-image-editor
118-
# - run: *jest
119-
120-
android-compile:
121-
<<: *android_defaults
7+
checkout_code:
8+
executor: rn/linux_js
1229
steps:
123-
- attach_workspace:
124-
at: ~/react-native-image-editor
125-
- restore-cache: *restore-gradle-cache
126-
- run:
127-
name: Accept Android licences
128-
command: |-
129-
yes | sdkmanager --licenses || exit 0
130-
yes | sdkmanager --update || exit 0
131-
- run:
132-
name: Build Android Example App and Library
133-
command: |-
134-
cd example/android
135-
./gradlew clean assembleDebug
136-
- save-cache: *save-gradle-cache
137-
138-
ios-checkout:
139-
<<: *macos_defaults
140-
steps:
141-
- checkout
142-
- restore-cache: *restore-yarn-cache
143-
- run: rm -rf node_modules
144-
- run: yarn cache clean
145-
- run: *yarn
146-
- save-cache: *save-yarn-cache
147-
- persist_to_workspace:
148-
root: .
149-
paths: .
150-
151-
ios-compile:
152-
<<: *macos_defaults
10+
- checkout
11+
- persist_to_workspace:
12+
root: .
13+
paths: .
14+
analyse:
15+
executor: rn/linux_js
15316
steps:
154-
- attach_workspace:
155-
at: ~/react-native-image-editor
156-
- run:
157-
name: Build example app
158-
command: |-
159-
react-native run-ios --project-path example/ios
17+
- attach_workspace:
18+
at: .
19+
- rn/yarn_install
20+
- run:
21+
name: Lint JS Code (ESLint)
22+
command: yarn run test:eslint
23+
- run:
24+
name: Flow
25+
command: yarn run test:flow
26+
# TODO: uncomment after adding jest tests
27+
# - run:
28+
# name: Jest
29+
# command: yarn run test:jest
30+
- run:
31+
name: Build Android JavaScript Bundle
32+
command: yarn run test:detox:android:bundle:release
33+
- run:
34+
name: Build iOS JavaScript Bundle
35+
command: yarn run test:detox:ios:bundle:release
16036

161-
# -------------------------
162-
# WORKFLOWS
163-
# -------------------------
16437
workflows:
165-
version: 2
166-
Test:
38+
test:
16739
jobs:
168-
- linux-checkout
169-
- eslint:
170-
requires:
171-
- linux-checkout
172-
- flow:
173-
requires:
174-
- linux-checkout
175-
# - jest:
176-
# requires:
177-
# - linux-checkout
178-
- android-compile:
179-
requires:
180-
- linux-checkout
181-
# Disabled until we have macOS containers enabled
182-
# - ios-checkout
183-
# - ios-compile:
184-
# requires:
185-
# - ios-checkout
40+
- checkout_code
41+
- analyse:
42+
requires:
43+
- checkout_code
44+
- rn/android_build:
45+
name: build_android_debug
46+
project_path: "example/android"
47+
build_type: debug
48+
requires:
49+
- analyse
50+
- rn/android_build:
51+
name: build_android_release
52+
project_path: "example/android"
53+
build_type: release
54+
requires:
55+
- analyse
56+
- rn/android_test:
57+
detox_configuration: "android.emu.release"
58+
detox_loglevel: "trace"
59+
requires:
60+
- build_android_release
61+
- rn/ios_build_and_test:
62+
project_path: "example/ios/ImageEditorExample.xcodeproj"
63+
derived_data_path: "example/ios/build"
64+
device: "iPhone X"
65+
build_configuration: "Release"
66+
scheme: "ImageEditorExample"
67+
detox_configuration: "ios.sim.release"
68+
detox_loglevel: "trace"
69+
requires:
70+
- analyse

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ local.properties
4343
buck-out/
4444
\.buckd/
4545
*.keystore
46+
47+
# bundle
48+
.tmp/
4649

example/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ yarn-error.log
3939
# BUCK
4040
buck-out/
4141
\.buckd/
42-
*.keystore
42+
debug.keystore
43+
!release.keystore
4344

4445
# fastlane
4546
#

example/android/app/build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ import com.android.build.OutputFile
7373
*/
7474

7575
project.ext.react = [
76-
entryFile: "index.js"
76+
entryFile: "example/index.js",
77+
root: "../../../"
7778
]
7879

7980
apply from: "../../../node_modules/react-native/react.gradle"
@@ -103,6 +104,18 @@ android {
103104
targetSdkVersion rootProject.ext.targetSdkVersion
104105
versionCode 1
105106
versionName "1.0"
107+
testBuildType System.getProperty('testBuildType', 'debug') //this will later be used to control the test apk build type
108+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
109+
}
110+
signingConfigs {
111+
release {
112+
if (project.hasProperty('EXAMPLE_APP_STORE_FILE')) {
113+
storeFile file(EXAMPLE_APP_STORE_FILE)
114+
storePassword EXAMPLE_APP_STORE_PASSWORD
115+
keyAlias EXAMPLE_APP_KEY_ALIAS
116+
keyPassword EXAMPLE_APP_KEY_PASSWORD
117+
}
118+
}
106119
}
107120
splits {
108121
abi {
@@ -114,6 +127,7 @@ android {
114127
}
115128
buildTypes {
116129
release {
130+
signingConfig signingConfigs.release
117131
minifyEnabled enableProguardInReleaseBuilds
118132
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
119133
}
@@ -137,6 +151,8 @@ dependencies {
137151
implementation project(':rnImageEditor')
138152
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
139153
implementation "com.facebook.react:react-native:+" // From node_modules
154+
androidTestImplementation(project(path: ":detox"))
155+
androidTestImplementation 'junit:junit:4.12'
140156
}
141157

142158
// Run this once to be able to run the application with BUCK
2.2 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.imageeditorexample;
2+
3+
import com.wix.detox.Detox;
4+
5+
import org.junit.Rule;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
9+
import androidx.test.ext.junit.runners.AndroidJUnit4;
10+
import androidx.test.filters.LargeTest;
11+
import androidx.test.rule.ActivityTestRule;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
@LargeTest
15+
public class DetoxTest {
16+
17+
@Rule
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
Detox.runTests(mActivityRule);
23+
}
24+
}
File renamed without changes.
File renamed without changes.

example/android/build.gradle

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,43 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "28.0.3"
6-
minSdkVersion = 16
6+
minSdkVersion = 18
77
compileSdkVersion = 28
88
targetSdkVersion = 27
99
supportLibVersion = "28.0.0"
10+
// e2e
11+
ext.kotlinVersion = '1.3.0'
12+
1013
}
1114
repositories {
1215
google()
1316
jcenter()
1417
}
1518
dependencies {
1619
classpath 'com.android.tools.build:gradle:3.2.1'
17-
18-
// NOTE: Do not place your application dependencies here; they belong
19-
// in the individual module build.gradle files
20+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2021
}
2122
}
2223

2324
allprojects {
25+
task downloadDependencies() {
26+
description 'Download all dependencies to the Gradle cache'
27+
doLast {
28+
configurations.findAll().each { config ->
29+
if (config.name.contains("minReactNative") && config.canBeResolved) {
30+
print config.name
31+
print '\n'
32+
config.files
33+
}
34+
}
35+
}
36+
}
37+
2438
repositories {
2539
mavenLocal()
2640
google()
2741
jcenter()
2842
maven {
29-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
3043
url "$rootDir/../../node_modules/react-native/android"
3144
}
3245
}

example/android/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
19+
20+
EXAMPLE_APP_STORE_FILE=release.keystore
21+
EXAMPLE_APP_KEY_ALIAS=androiddebugkey
22+
EXAMPLE_APP_STORE_PASSWORD=android
23+
EXAMPLE_APP_KEY_PASSWORD=android

0 commit comments

Comments
 (0)