Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 8a6d4d5

Browse files
tafsiridsmilkov
authored andcommitted
Add react native unit tests to ci (#1870)
cla: yes Add react native unit tests to CI
1 parent bfff620 commit 8a6d4d5

File tree

5 files changed

+83
-49
lines changed

5 files changed

+83
-49
lines changed

cloudbuild.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,74 @@
11
steps:
2+
#
3+
# Core tests
4+
#
5+
# install dependencies
26
- name: 'node:10'
37
entrypoint: 'yarn'
48
id: 'yarn'
59
args: ['install']
10+
# build
611
- name: 'node:10'
712
entrypoint: 'yarn'
813
id: 'build'
914
args: ['build-ci']
1015
waitFor: ['yarn']
16+
# run unit tests
1117
- name: 'node:10'
1218
entrypoint: 'yarn'
1319
id: 'test'
1420
args: ['test-ci']
1521
waitFor: ['build']
1622
env: ['BROWSERSTACK_USERNAME=deeplearnjs1']
1723
secretEnv: ['BROWSERSTACK_KEY']
24+
# Run integration tests of other packages against core
1825
- name: 'node:10'
1926
entrypoint: 'yarn'
2027
id: 'test-integration'
2128
args: ['test-integration']
2229
waitFor: ['build']
2330
env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY']
2431
secretEnv: ['BROWSERSTACK_KEY']
32+
# bundle size check
2533
- name: 'node:10'
2634
entrypoint: 'yarn'
2735
id: 'test-bundle-size'
2836
args: ['test-bundle-size']
2937
waitFor: ['yarn']
30-
- name: 'node:10'
31-
entrypoint: 'yarn'
32-
id: 'test-webgpu'
33-
dir: 'tfjs-webgpu/'
34-
args: ['test-ci']
35-
waitFor: ['yarn']
38+
# test doc snippets
3639
- name: 'node:10'
3740
entrypoint: 'yarn'
3841
args: ['test-snippets']
3942
id: 'test-snippets'
4043
waitFor: ['yarn']
44+
# test Async backends
4145
- name: 'node:10'
4246
entrypoint: 'yarn'
4347
id: 'test-async-backends'
4448
args: ['test-async-backends-ci']
4549
waitFor: ['build']
50+
#
51+
# WebGPU tests
52+
#
53+
- name: 'node:10'
54+
entrypoint: 'yarn'
55+
id: 'test-webgpu'
56+
dir: 'tfjs-webgpu/'
57+
args: ['test-ci']
58+
waitFor: ['-'] # start step immediately
59+
#
60+
# React-Native tests
61+
#
62+
- name: 'node:10'
63+
entrypoint: 'yarn'
64+
id: 'test-react-native'
65+
dir: 'tfjs-react-native/'
66+
args: ['test-ci']
67+
waitFor: ['-'] # start step immediately
68+
env: ['BROWSERSTACK_USERNAME=deeplearnjs1']
69+
secretEnv: ['BROWSERSTACK_KEY']
70+
71+
# General configuration
4672
secrets:
4773
- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc
4874
secretEnv:

tfjs-react-native/karma.conf.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,50 @@ const baseConfig = {
4242
frameworks: ['jasmine', 'karma-typescript'],
4343
files: [
4444
'./src/**/*.ts',
45-
'./test/**/*.ts',
4645
],
4746
preprocessors: {
4847
'src/**/*.ts': ['karma-typescript'],
49-
'test/**/*.ts': ['karma-typescript'],
5048
},
5149
karmaTypescriptConfig,
5250
reporters: ['verbose', 'karma-typescript'],
5351
};
5452

53+
const browserstackConfig = {
54+
...baseConfig,
55+
reporters: ['dots'],
56+
singleRun: true,
57+
hostname: 'bs-local.com',
58+
browserStack: {
59+
username: process.env.BROWSERSTACK_USERNAME,
60+
accessKey: process.env.BROWSERSTACK_KEY
61+
},
62+
captureTimeout: 120000,
63+
reportSlowerThan: 500,
64+
browserNoActivityTimeout: 180000,
65+
};
66+
5567
module.exports = function(config) {
5668
const args = [];
69+
5770
if (config.grep) {
5871
args.push('--grep', config.grep);
5972
}
6073

74+
let extraConfig = config.browserstack ? browserstackConfig : baseConfig;
75+
6176
config.set({
62-
...baseConfig,
6377
basePath: '',
64-
frameworks: ['jasmine', 'karma-typescript'],
65-
preprocessors: {'**/*.ts': ['karma-typescript']},
6678
karmaTypescriptConfig,
6779
reporters: ['progress', 'karma-typescript'],
6880
port: 9876,
6981
colors: true,
7082
autoWatch: false,
7183
browsers: ['Chrome'],
72-
singleRun: true,
7384
client: {
7485
jasmine: {random: false},
7586
args: args,
7687
},
88+
...extraConfig,
7789
customLaunchers: {
7890
// For browserstack configs see:
7991
// https://www.browserstack.com/automate/node

tfjs-react-native/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
"link-local": "yalc link",
1717
"unlink-local": "yalc remove",
1818
"lint": "tslint -p . -t verbose",
19-
"test": "karma start"
19+
"test": "karma start",
20+
"test-ci": "./scripts/test-ci.sh"
2021
},
2122
"devDependencies": {
2223
"@react-native-community/async-storage": "^1.4.2",
23-
"@tensorflow/tfjs-core": "1.2.3",
24+
"@tensorflow/tfjs-core": "^1.2.7",
2425
"@types/base64-js": "^1.2.5",
2526
"@types/jasmine": "~2.5.53",
2627
"@types/react-native": "^0.60.2",
@@ -29,7 +30,6 @@
2930
"jasmine": "~3.1.0",
3031
"jasmine-core": "~3.1.0",
3132
"karma": "~4.2.0",
32-
"karma-browserify": "~6.0.0",
3333
"karma-browserstack-launcher": "~1.4.0",
3434
"karma-chrome-launcher": "~2.2.0",
3535
"karma-jasmine": "~1.1.0",
@@ -52,7 +52,7 @@
5252
},
5353
"peerDependencies": {
5454
"@react-native-community/async-storage": "^1.4.2",
55-
"@tensorflow/tfjs-core": ">=1.2.3",
55+
"@tensorflow/tfjs-core": ">=1.2.7",
5656
"expo-gl": "^5.0.1",
5757
"react-native": ">=0.59.0"
5858
}

tfjs-react-native/scripts/test-ci.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Google LLC. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# =============================================================================
16+
17+
set -e
18+
19+
yarn
20+
yarn lint
21+
yarn build
22+
karma start --browserstack --browsers=bs_chrome_mac
23+

tfjs-react-native/yarn.lock

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.5.1.tgz#c496b4969eea5b91da1a5919a611046360b0c51f"
88
integrity sha512-Ssfx2uLYPnsuqIvDCuUOEZT6jh5AVy0U0mr2eHxNO2Syor1nfOrR/n4hTOFcBWc1wamDTGCqo+UHJpxURVXd2Q==
99

10-
"@tensorflow/[email protected].3":
11-
version "1.2.3"
12-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.%3Cspan%20class="x x-first x-last">3.tgz#90cc7bb593ba67548d683ff045823872a05c43dc"
13-
integrity sha512-jLYUJYzI/b+058yKz9SjX6KwTac4hKFRh1FMI8jQpN289z9MSfKBq8BzpKd7n7ml7b55ae157Qta5pFmLwRVZw==
10+
"@tensorflow/tfjs-core@^1.2.7":
11+
version "1.2.7"
12+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.%3Cspan%20class="x x-first x-last">7.tgz#522328de16470aa9f7c15b91e4b68616f425002a"
13+
integrity sha512-RsXavYKMc0MOcCmOyD7HE8am1tWlDGXl0nJbsdib7ubmvMuH6KnrZ302eTYV7k1RMq+/ukkioJmCcw13hopuHQ==
1414
dependencies:
1515
"@types/offscreencanvas" "~2019.3.0"
1616
"@types/seedrandom" "2.4.27"
@@ -677,7 +677,7 @@ content-type@~1.0.4:
677677
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
678678
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==
679679

680-
convert-source-map@^1.1.3, convert-source-map@^1.6.0:
680+
convert-source-map@^1.6.0:
681681
version "1.6.0"
682682
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20"
683683
integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==
@@ -1324,11 +1324,6 @@ hash.js@^1.0.0, hash.js@^1.0.3:
13241324
inherits "^2.0.3"
13251325
minimalistic-assert "^1.0.1"
13261326

1327-
hat@^0.0.3:
1328-
version "0.0.3"
1329-
resolved "https://registry.yarnpkg.com/hat/-/hat-0.0.3.tgz#bb014a9e64b3788aed8005917413d4ff3d502d8a"
1330-
integrity sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=
1331-
13321327
hmac-drbg@^1.0.0:
13331328
version "1.0.1"
13341329
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -1610,11 +1605,6 @@ jasmine@~3.1.0:
16101605
glob "^7.0.6"
16111606
jasmine-core "~3.1.0"
16121607

1613-
js-string-escape@^1.0.0:
1614-
version "1.0.1"
1615-
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
1616-
integrity sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=
1617-
16181608
"js-tokens@^3.0.0 || ^4.0.0":
16191609
version "4.0.0"
16201610
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -1645,18 +1635,6 @@ jsonfile@^4.0.0:
16451635
optionalDependencies:
16461636
graceful-fs "^4.1.6"
16471637

1648-
karma-browserify@~6.0.0:
1649-
version "6.0.0"
1650-
resolved "https://registry.yarnpkg.com/karma-browserify/-/karma-browserify-6.0.0.tgz#423b719fe80d064ad5ec36f8eb15c399305b9aba"
1651-
integrity sha512-G3dGjoy1/6P8I6qTp799fbcAxs4P+1JcyEKUzy9g1/xMakqf9FFPwW2T9iEtCbWoH5WIKD3z+YwGL5ysBhzrsg==
1652-
dependencies:
1653-
convert-source-map "^1.1.3"
1654-
hat "^0.0.3"
1655-
js-string-escape "^1.0.0"
1656-
lodash "^4.17.10"
1657-
minimatch "^3.0.0"
1658-
os-shim "^0.1.3"
1659-
16601638
karma-browserstack-launcher@~1.4.0:
16611639
version "1.4.0"
16621640
resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.4.0.tgz#22f92e969d2db6cfc00e578708bda39378d5f2ab"
@@ -1813,7 +1791,7 @@ lodash.memoize@~3.0.3:
18131791
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
18141792
integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=
18151793

1816-
lodash@^4.17.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14:
1794+
lodash@^4.17.0, lodash@^4.17.11, lodash@^4.17.14:
18171795
version "4.17.14"
18181796
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
18191797
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==
@@ -2109,11 +2087,6 @@ os-locale@^1.4.0:
21092087
dependencies:
21102088
lcid "^1.0.0"
21112089

2112-
os-shim@^0.1.3:
2113-
version "0.1.3"
2114-
resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917"
2115-
integrity sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=
2116-
21172090
os-tmpdir@~1.0.2:
21182091
version "1.0.2"
21192092
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"

0 commit comments

Comments
 (0)