Skip to content

Commit

Permalink
feat(builtin): e2e tests for symlinked node_modules and hide-bazel-files
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored and alexeagle committed Jun 18, 2019
1 parent e7d2fbd commit 8cafe43
Show file tree
Hide file tree
Showing 24 changed files with 206 additions and 8 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ e2e/
# Examples are tested by running examples/test_example.sh outside of Bazel
examples/
# Most packages are nested workspaces
packages/hide-bazel-files
packages/jasmine
packages/karma
packages/labs
Expand Down
1 change: 1 addition & 0 deletions e2e/symlinked_node_modules_npm/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions e2e/symlinked_node_modules_npm/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import %workspace%/../../common.bazelrc
9 changes: 9 additions & 0 deletions e2e/symlinked_node_modules_npm/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")

nodejs_test(
name = "test",
data = [
"@npm//typescript",
],
entry_point = ":main.js",
)
18 changes: 18 additions & 0 deletions e2e/symlinked_node_modules_npm/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
workspace(
name = "e2e_symlinked_node_modules_yarn",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
path = "../../dist/build_bazel_rules_nodejs/release",
)

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_install")

npm_install(
name = "npm",
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
quiet = False,
)
2 changes: 2 additions & 0 deletions e2e/symlinked_node_modules_npm/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const ts = require('typescript');
console.log('\nYour typescript version is', ts.version);
28 changes: 28 additions & 0 deletions e2e/symlinked_node_modules_npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions e2e/symlinked_node_modules_npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dependencies": {
"typescript": "2.9.1",
"rxjs": "6.4.0"
},
"devDependencies": {
"@bazel/hide-bazel-files": "file:../../dist/npm_bazel_hide-bazel-files"
},
"scripts": {
"postinstall": "hide-bazel-files",
"test": "bazel test ... && rm -rf node_modules && bazel test ... && rm -rf node_modules && yarn install && bazel test ..."
}
}
23 changes: 23 additions & 0 deletions e2e/symlinked_node_modules_npm/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@bazel/hide-bazel-files@file:../../dist/npm_bazel_hide-bazel-files":
version "0.31.1-16-g4196fa7"

[email protected]:
version "6.4.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.4.0.tgz#f3bb0fe7bda7fb69deac0c16f17b50b0b8790504"
integrity sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==
dependencies:
tslib "^1.9.0"

tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

[email protected]:
version "2.9.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961"
integrity sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA==
1 change: 1 addition & 0 deletions e2e/symlinked_node_modules_yarn/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions e2e/symlinked_node_modules_yarn/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import %workspace%/../../common.bazelrc
9 changes: 9 additions & 0 deletions e2e/symlinked_node_modules_yarn/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")

nodejs_test(
name = "test",
data = [
"@npm//typescript",
],
entry_point = ":main.js",
)
18 changes: 18 additions & 0 deletions e2e/symlinked_node_modules_yarn/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
workspace(
name = "e2e_symlinked_node_modules_yarn",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
path = "../../dist/build_bazel_rules_nodejs/release",
)

load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
package_json = "//:package.json",
quiet = False,
yarn_lock = "//:yarn.lock",
)
2 changes: 2 additions & 0 deletions e2e/symlinked_node_modules_yarn/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const ts = require('typescript');
console.log('\nYour typescript version is', ts.version);
13 changes: 13 additions & 0 deletions e2e/symlinked_node_modules_yarn/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dependencies": {
"typescript": "2.9.1",
"rxjs": "6.4.0"
},
"devDependencies": {
"@bazel/hide-bazel-files": "file:../../dist/npm_bazel_hide-bazel-files"
},
"scripts": {
"postinstall": "hide-bazel-files",
"test": "bazel test ... && rm -rf node_modules && bazel test ... && rm -rf node_modules && yarn install && bazel test ..."
}
}
23 changes: 23 additions & 0 deletions e2e/symlinked_node_modules_yarn/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@bazel/hide-bazel-files@file:../../dist/npm_bazel_hide-bazel-files":
version "0.31.1-16-g4196fa7"

[email protected]:
version "6.4.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.4.0.tgz#f3bb0fe7bda7fb69deac0c16f17b50b0b8790504"
integrity sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==
dependencies:
tslib "^1.9.0"

tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

[email protected]:
version "2.9.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961"
integrity sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA==
30 changes: 30 additions & 0 deletions packages/hide-bazel-files/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 The Bazel Authors. 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.

workspace(name = "npm_bazel_hide_bazel_files")

local_repository(
name = "build_bazel_rules_nodejs",
path = "../..",
)

# Pull in build_bazel_rules_nodejs dev dependencies which are
# needed for generating documentation
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dev_dependencies")

rules_nodejs_dev_dependencies()

load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")

node_repositories()
Empty file modified packages/hide-bazel-files/index.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion scripts/packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -eu -o pipefail

# Define packages so that dependencies come first as locally
# they will be built in the order provided
export readonly PACKAGES=( jasmine typescript karma labs )
export readonly PACKAGES=( hide-bazel-files jasmine typescript karma labs )
3 changes: 0 additions & 3 deletions scripts/publish_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ for pkg in ${PACKAGES[@]} ; do (

# packages/create is not a nested workspace and has no deps
echo_and_run node_modules/.bin/bazel --output_base=$TMP run --workspace_status_command=scripts/current_version.sh //packages/create:npm_package.${NPM_COMMAND}

# packages/hide-bazel-files is not a nested workspace and has no deps
echo_and_run node_modules/.bin/bazel --output_base=$TMP run --workspace_status_command=scripts/current_version.sh //packages/hide-bazel-files:npm_package.${NPM_COMMAND}
4 changes: 3 additions & 1 deletion scripts/test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ for e2eTest in ${E2E_TESTS[@]} ; do
cd "${E2E_DIR}/${e2eTest}"
printf "\n\nRunning e2e test ${e2eTest}\n"
${RULES_NODEJS_DIR}/scripts/check_deps.sh
echo_and_run yarn test
if grep -q "\"test\":" package.json; then
echo_and_run yarn test
fi
)
done
4 changes: 3 additions & 1 deletion scripts/test_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ for example in ${EXAMPLES[@]} ; do
cd "${EXAMPLES_DIR}/${example}"
printf "\n\nRunning example ${example}\n"
${RULES_NODEJS_DIR}/scripts/check_deps.sh
echo_and_run yarn test
if grep -q "\"test\":" package.json; then
echo_and_run yarn test
fi
if grep -q "\"e2e\":" package.json; then
echo_and_run yarn e2e
fi
Expand Down
4 changes: 3 additions & 1 deletion scripts/test_legacy_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ for e2eTest in ${E2E_TESTS[@]} ; do
cd "${E2E_DIR}/${e2eTest}"
printf "\n\nRunning legacy e2e test ${e2eTest}\n"
${RULES_NODEJS_DIR}/scripts/check_deps.sh
echo_and_run yarn test
if grep -q "\"test\":" package.json; then
echo_and_run yarn test
fi
)
done
4 changes: 3 additions & 1 deletion scripts/test_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ for package in ${PACKAGES[@]} ; do
cd "${PACKAGES_DIR}/${package}"
printf "\n\nTesting package ${package}\n"
${RULES_NODEJS_DIR}/scripts/check_deps.sh
echo_and_run yarn test
if grep -q "\"test\":" package.json; then
echo_and_run yarn test
fi
)
done

0 comments on commit 8cafe43

Please sign in to comment.