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

Add react native unit tests to ci #1870

Merged
merged 11 commits into from
Aug 7, 2019
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
38 changes: 32 additions & 6 deletions cloudbuild.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,74 @@
steps:
#
# Core tests
#
# install dependencies
- name: 'node:10'
entrypoint: 'yarn'
id: 'yarn'
args: ['install']
# build
- name: 'node:10'
entrypoint: 'yarn'
id: 'build'
args: ['build-ci']
waitFor: ['yarn']
# run unit tests
- name: 'node:10'
entrypoint: 'yarn'
id: 'test'
args: ['test-ci']
waitFor: ['build']
env: ['BROWSERSTACK_USERNAME=deeplearnjs1']
secretEnv: ['BROWSERSTACK_KEY']
# Run integration tests of other packages against core
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-integration'
args: ['test-integration']
waitFor: ['build']
env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY']
secretEnv: ['BROWSERSTACK_KEY']
# bundle size check
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-bundle-size'
args: ['test-bundle-size']
waitFor: ['yarn']
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-webgpu'
dir: 'tfjs-webgpu/'
args: ['test-ci']
waitFor: ['yarn']
# test doc snippets
- name: 'node:10'
entrypoint: 'yarn'
args: ['test-snippets']
id: 'test-snippets'
waitFor: ['yarn']
# test Async backends
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-async-backends'
args: ['test-async-backends-ci']
waitFor: ['build']
#
# WebGPU tests
#
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-webgpu'
dir: 'tfjs-webgpu/'
args: ['test-ci']
waitFor: ['-'] # start step immediately
#
# React-Native tests
#
- name: 'node:10'
entrypoint: 'yarn'
id: 'test-react-native'
dir: 'tfjs-react-native/'
args: ['test-ci']
waitFor: ['-'] # start step immediately
env: ['BROWSERSTACK_USERNAME=deeplearnjs1']
secretEnv: ['BROWSERSTACK_KEY']

# General configuration
secrets:
- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc
secretEnv:
Expand Down
24 changes: 18 additions & 6 deletions tfjs-react-native/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,50 @@ const baseConfig = {
frameworks: ['jasmine', 'karma-typescript'],
files: [
'./src/**/*.ts',
'./test/**/*.ts',
],
preprocessors: {
'src/**/*.ts': ['karma-typescript'],
'test/**/*.ts': ['karma-typescript'],
},
karmaTypescriptConfig,
reporters: ['verbose', 'karma-typescript'],
};

const browserstackConfig = {
...baseConfig,
reporters: ['dots'],
singleRun: true,
hostname: 'bs-local.com',
browserStack: {
username: process.env.BROWSERSTACK_USERNAME,
accessKey: process.env.BROWSERSTACK_KEY
},
captureTimeout: 120000,
reportSlowerThan: 500,
browserNoActivityTimeout: 180000,
};

module.exports = function(config) {
const args = [];

if (config.grep) {
args.push('--grep', config.grep);
}

let extraConfig = config.browserstack ? browserstackConfig : baseConfig;

config.set({
...baseConfig,
basePath: '',
frameworks: ['jasmine', 'karma-typescript'],
preprocessors: {'**/*.ts': ['karma-typescript']},
karmaTypescriptConfig,
reporters: ['progress', 'karma-typescript'],
port: 9876,
colors: true,
autoWatch: false,
browsers: ['Chrome'],
singleRun: true,
client: {
jasmine: {random: false},
args: args,
},
...extraConfig,
customLaunchers: {
// For browserstack configs see:
// https://www.browserstack.com/automate/node
Expand Down
8 changes: 4 additions & 4 deletions tfjs-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"link-local": "yalc link",
"unlink-local": "yalc remove",
"lint": "tslint -p . -t verbose",
"test": "karma start"
"test": "karma start",
"test-ci": "./scripts/test-ci.sh"
},
"devDependencies": {
"@react-native-community/async-storage": "^1.4.2",
"@tensorflow/tfjs-core": "1.2.3",
"@tensorflow/tfjs-core": "^1.2.7",
"@types/base64-js": "^1.2.5",
"@types/jasmine": "~2.5.53",
"@types/react-native": "^0.60.2",
Expand All @@ -29,7 +30,6 @@
"jasmine": "~3.1.0",
"jasmine-core": "~3.1.0",
"karma": "~4.2.0",
"karma-browserify": "~6.0.0",
"karma-browserstack-launcher": "~1.4.0",
"karma-chrome-launcher": "~2.2.0",
"karma-jasmine": "~1.1.0",
Expand All @@ -52,7 +52,7 @@
},
"peerDependencies": {
"@react-native-community/async-storage": "^1.4.2",
"@tensorflow/tfjs-core": ">=1.2.3",
"@tensorflow/tfjs-core": ">=1.2.7",
"expo-gl": "^5.0.1",
"react-native": ">=0.59.0"
}
Expand Down
23 changes: 23 additions & 0 deletions tfjs-react-native/scripts/test-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================

set -e

yarn
yarn lint
yarn build
karma start --browserstack --browsers=bs_chrome_mac

39 changes: 6 additions & 33 deletions tfjs-react-native/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.5.1.tgz#c496b4969eea5b91da1a5919a611046360b0c51f"
integrity sha512-Ssfx2uLYPnsuqIvDCuUOEZT6jh5AVy0U0mr2eHxNO2Syor1nfOrR/n4hTOFcBWc1wamDTGCqo+UHJpxURVXd2Q==

"@tensorflow/[email protected].3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.3.tgz#90cc7bb593ba67548d683ff045823872a05c43dc"
integrity sha512-jLYUJYzI/b+058yKz9SjX6KwTac4hKFRh1FMI8jQpN289z9MSfKBq8BzpKd7n7ml7b55ae157Qta5pFmLwRVZw==
"@tensorflow/tfjs-core@^1.2.7":
version "1.2.7"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.7.tgz#522328de16470aa9f7c15b91e4b68616f425002a"
integrity sha512-RsXavYKMc0MOcCmOyD7HE8am1tWlDGXl0nJbsdib7ubmvMuH6KnrZ302eTYV7k1RMq+/ukkioJmCcw13hopuHQ==
dependencies:
"@types/offscreencanvas" "~2019.3.0"
"@types/seedrandom" "2.4.27"
Expand Down Expand Up @@ -677,7 +677,7 @@ content-type@~1.0.4:
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==

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

hat@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/hat/-/hat-0.0.3.tgz#bb014a9e64b3788aed8005917413d4ff3d502d8a"
integrity sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=

hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
Expand Down Expand Up @@ -1610,11 +1605,6 @@ jasmine@~3.1.0:
glob "^7.0.6"
jasmine-core "~3.1.0"

js-string-escape@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
integrity sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=

"js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -1645,18 +1635,6 @@ jsonfile@^4.0.0:
optionalDependencies:
graceful-fs "^4.1.6"

karma-browserify@~6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/karma-browserify/-/karma-browserify-6.0.0.tgz#423b719fe80d064ad5ec36f8eb15c399305b9aba"
integrity sha512-G3dGjoy1/6P8I6qTp799fbcAxs4P+1JcyEKUzy9g1/xMakqf9FFPwW2T9iEtCbWoH5WIKD3z+YwGL5ysBhzrsg==
dependencies:
convert-source-map "^1.1.3"
hat "^0.0.3"
js-string-escape "^1.0.0"
lodash "^4.17.10"
minimatch "^3.0.0"
os-shim "^0.1.3"

karma-browserstack-launcher@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.4.0.tgz#22f92e969d2db6cfc00e578708bda39378d5f2ab"
Expand Down Expand Up @@ -1813,7 +1791,7 @@ lodash.memoize@~3.0.3:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
integrity sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=

lodash@^4.17.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14:
lodash@^4.17.0, lodash@^4.17.11, lodash@^4.17.14:
version "4.17.14"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==
Expand Down Expand Up @@ -2109,11 +2087,6 @@ os-locale@^1.4.0:
dependencies:
lcid "^1.0.0"

os-shim@^0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917"
integrity sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=

os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
Expand Down