From 83b7eb464ff5976641ec7e16db17911b95a0c85e Mon Sep 17 00:00:00 2001 From: Na Li Date: Mon, 23 Mar 2020 22:02:10 -0700 Subject: [PATCH 1/5] [wasm]Test against head. --- tfjs-backend-wasm/cloudbuild.yml | 44 +------------------ tfjs-backend-wasm/package.json | 9 ++-- tfjs-backend-wasm/scripts/link-core-master.js | 27 ------------ tfjs-backend-wasm/scripts/test-ci.sh | 18 ++++++++ 4 files changed, 25 insertions(+), 73 deletions(-) delete mode 100755 tfjs-backend-wasm/scripts/link-core-master.js create mode 100644 tfjs-backend-wasm/scripts/test-ci.sh diff --git a/tfjs-backend-wasm/cloudbuild.yml b/tfjs-backend-wasm/cloudbuild.yml index 0ded3820fbf..ca3451c07b0 100644 --- a/tfjs-backend-wasm/cloudbuild.yml +++ b/tfjs-backend-wasm/cloudbuild.yml @@ -5,56 +5,16 @@ steps: entrypoint: 'yarn' args: ['install'] -# Install wasm dependencies. -- name: 'node:10' - dir: 'tfjs-backend-wasm' - id: 'yarn' - entrypoint: 'yarn' - args: ['install'] - waitFor: ['yarn-common'] - -# Build core from master. -- name: 'node:10' - dir: 'tfjs-backend-wasm' - id: 'build-core' - entrypoint: 'yarn' - args: ['build-core'] - waitFor: ['yarn-common'] - -# Run lint. -- name: 'node:10' - dir: 'tfjs-backend-wasm' - entrypoint: 'yarn' - id: 'lint' - args: ['lint'] - waitFor: ['build-core'] - -# Build the project. -- name: 'node:10' - dir: 'tfjs-backend-wasm' - entrypoint: 'yarn' - id: 'build' - args: ['build-ci'] - waitFor: ['build-core'] - # Run tests in browser. - name: 'node:10' dir: 'tfjs-backend-wasm' entrypoint: 'yarn' id: 'test-wasm' - args: ['test-browser-ci'] - waitFor: ['build'] + args: ['test-ci'] + waitFor: ['yarn-common'] env: ['BROWSERSTACK_USERNAME=deeplearnjs1'] secretEnv: ['BROWSERSTACK_KEY'] -# Run tests in node. -- name: 'node:10' - dir: 'tfjs-backend-wasm' - entrypoint: 'yarn' - id: 'test-node' - args: ['test-node'] - waitFor: ['build'] - # Run C++ tests. - name: 'node:10' dir: 'tfjs-backend-wasm' diff --git a/tfjs-backend-wasm/package.json b/tfjs-backend-wasm/package.json index e843f367892..47ceedd1ec2 100644 --- a/tfjs-backend-wasm/package.json +++ b/tfjs-backend-wasm/package.json @@ -12,16 +12,17 @@ "bazel:format-check": "yarn bazel:format --mode=check", "bazel:lint": "yarn bazel:format --lint=warn", "bazel:lint-check": "yarn bazel:format --lint=warn --mode=check", - "build-core": "cd ../tfjs-core && yarn && yarn build", - "build": "yarn link-core-master && yarn build-core && rimraf dist/ && tsc && ./scripts/build-wasm.sh", + "build-deps": "cd ../tfjs-core && yarn && yarn build", + "build-deps-ci": "cd ../tfjs-core && yarn && yarn build-ci", + "build": "rimraf dist/ && tsc && ./scripts/build-wasm.sh", "build-ci": "./scripts/build-ci.sh", "build-npm": "./scripts/build-npm.sh", "buildifier-ci": "./scripts/buildifier-ci.sh", "clean": "rimraf dist/ && bazel clean --expunge", "cpplint": "./scripts/cpplint.js", "lint": "tslint -p . -t verbose && yarn cpplint", - "link-core-master": "./scripts/link-core-master.js && yarn", - "test": "yarn link-core-master && yarn build-core && ./scripts/build-wasm.sh && karma start", + "test": "yarn && yarn build-deps && yarn build && karma start", + "test-ci": "./scripts/test-ci.sh", "test-node": "ts-node src/test_node.ts", "test-bundle-size": "./scripts/test-bundle-size.js", "test-cc": "bazel test //src/cc:cc_tests --test_output=all", diff --git a/tfjs-backend-wasm/scripts/link-core-master.js b/tfjs-backend-wasm/scripts/link-core-master.js deleted file mode 100755 index 0af5ab13f2b..00000000000 --- a/tfjs-backend-wasm/scripts/link-core-master.js +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env node -// 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. -// ============================================================================= - -// This script updates package.json to link core at master. - -const fs = require('fs'); - -let pkg = fs.readFileSync('package.json', 'utf8'); - -pkg = `${pkg}`.replace( - new RegExp(`"@tensorflow/tfjs-core": ".+"`, 'g'), - `"@tensorflow/tfjs-core": "link:../tfjs-core"`); - -fs.writeFileSync('package.json', pkg); diff --git a/tfjs-backend-wasm/scripts/test-ci.sh b/tfjs-backend-wasm/scripts/test-ci.sh new file mode 100644 index 00000000000..1ef2769e3cc --- /dev/null +++ b/tfjs-backend-wasm/scripts/test-ci.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Copyright 2020 Google LLC +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# ============================================================================= + +set -e + +# Regular testing. +yarn +yarn build-deps-ci +yarn build-ci +yarn lint +yarn test-node +yarn test-browser-ci From f394960dfbfdc98debae8649ee2443e99e89e8e0 Mon Sep 17 00:00:00 2001 From: Na Li Date: Mon, 23 Mar 2020 22:02:28 -0700 Subject: [PATCH 2/5] [wasm]Test against head. --- tfjs-core/scripts/test-integration.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tfjs-core/scripts/test-integration.sh b/tfjs-core/scripts/test-integration.sh index e22c0d3fa20..8a7c9f86cf0 100755 --- a/tfjs-core/scripts/test-integration.sh +++ b/tfjs-core/scripts/test-integration.sh @@ -28,31 +28,33 @@ yarn build && yarn build-test-snippets echo 'Testing layers' cd ../tfjs-layers -yarn yarn test-ci LAYERS_EXIT_CODE=$? echo 'Testing node' cd ../tfjs-node -yarn yarn test-ci NODE_EXIT_CODE=$? +echo 'Testing wasm' +cd ../tfjs-backend-wasm +yarn test-ci +WASM_EXIT_CODE=$? + echo 'Testing converter' cd ../tfjs-converter -yarn yarn test-ci CONVERTER_EXIT_CODE=$? echo 'Testing data' cd ../tfjs-data -yarn yarn test-ci DATA_EXIT_CODE=$? echo '==== INTEGRATION TEST RESULTS ====' print_status "tfjs-layers" "$LAYERS_EXIT_CODE" print_status "tfjs-node" "$NODE_EXIT_CODE" +print_status "tfjs-backend-wasm" "$WASM_EXIT_CODE" print_status "tfjs-converter" "$CONVERTER_EXIT_CODE" print_status "tfjs-data" "$DATA_EXIT_CODE" echo '==================================' From 298547694ed207aa6451f6eaca64017f0327b251 Mon Sep 17 00:00:00 2001 From: Na Li Date: Mon, 23 Mar 2020 22:11:44 -0700 Subject: [PATCH 3/5] Fix cloudbuild.yml. --- tfjs-backend-wasm/cloudbuild.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tfjs-backend-wasm/cloudbuild.yml b/tfjs-backend-wasm/cloudbuild.yml index ca3451c07b0..db48e71f493 100644 --- a/tfjs-backend-wasm/cloudbuild.yml +++ b/tfjs-backend-wasm/cloudbuild.yml @@ -21,7 +21,7 @@ steps: entrypoint: 'yarn' id: 'test-cc' args: ['test-cc'] - waitFor: ['build'] + waitFor: ['test-wasm'] # Check bundle size. - name: 'node:10' @@ -29,7 +29,7 @@ steps: id: 'test-bundle-size' entrypoint: 'yarn' args: ['test-bundle-size'] - waitFor: ['build'] + waitFor: ['test-wasm'] # Lint bazel files. - name: 'node:10' @@ -37,7 +37,7 @@ steps: id: 'buildifier' entrypoint: 'yarn' args: ['buildifier-ci'] - waitFor: ['yarn'] + waitFor: ['test-wasm'] # General configuration secrets: From 884f93ea14fe2a70a46bd859d3c56eb9d3112b0f Mon Sep 17 00:00:00 2001 From: Na Li Date: Mon, 23 Mar 2020 22:15:22 -0700 Subject: [PATCH 4/5] Add dependency to package_dependencies.json --- scripts/package_dependencies.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/package_dependencies.json b/scripts/package_dependencies.json index 02b91fc1527..6e1671d31fe 100644 --- a/scripts/package_dependencies.json +++ b/scripts/package_dependencies.json @@ -3,5 +3,6 @@ "tfjs-core": [], "tfjs-converter": ["tfjs-core"], "tfjs-layers": ["tfjs-core"], - "tfjs-data": ["tfjs-core", "tfjs-layers"] + "tfjs-data": ["tfjs-core", "tfjs-layers"], + "tfjs-backend-wasm": ["tfjs-core"] } From c62d2a0a8b7d34609da8239772fdd68c7eb92740 Mon Sep 17 00:00:00 2001 From: Na Li Date: Tue, 24 Mar 2020 07:07:10 -0700 Subject: [PATCH 5/5] Add permission to file. --- tfjs-backend-wasm/scripts/test-ci.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tfjs-backend-wasm/scripts/test-ci.sh diff --git a/tfjs-backend-wasm/scripts/test-ci.sh b/tfjs-backend-wasm/scripts/test-ci.sh old mode 100644 new mode 100755