From 9ea9f758e970a85ec97e102c79717a919a66181b Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 6 Dec 2019 07:36:28 -0800 Subject: [PATCH] test: cleanup user_managed_deps e2e test (#1428) * e2e/user_managed_deps now tested in its own circleci job from within the working directory; I tried using working_directory in bazelci but for some reason the node_modules filegroup glob was always empty * remove the old dormant test_legacy_runfiles circleci job * remove @e2e_packages workspace as it is not being used anymore --- .circleci/config.yml | 23 +++------- WORKSPACE | 13 ------ e2e/BUILD.bazel | 1 - e2e/packages/BUILD.bazel | 14 ------ e2e/packages/WORKSPACE | 36 +++++++++++++-- e2e/packages/setup_workspace.bzl | 55 ----------------------- examples/BUILD.bazel | 14 ------ examples/user_managed_deps/BUILD.bazel | 3 +- examples/user_managed_deps/WORKSPACE | 58 +++++++++++++++++++++++-- examples/user_managed_deps/package.json | 3 +- examples/user_managed_deps/yarn.lock | 34 +++++---------- packages/jasmine/src/BUILD.bazel | 11 ----- scripts/test_all.sh | 5 --- 13 files changed, 106 insertions(+), 164 deletions(-) delete mode 100644 e2e/packages/setup_workspace.bzl diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d16dee58c..8c95db39f2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,13 +71,6 @@ var_7: &hide_node_and_yarn_local_binaries sudo mv /usr/local/bin/npm /usr/local/bin/npm_ sudo mv /usr/local/bin/yarn /usr/local/bin/yarn_ -var_8: &use_legacy_runfiles - run: - name: Use legacy runfiles - command: | - echo 'run --legacy_external_runfiles' >> .bazelrc - echo 'test --legacy_external_runfiles' >> .bazelrc - var_9: &job_defaults working_directory: ~/rules_nodejs docker: @@ -224,21 +217,14 @@ jobs: command: bazel test --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 //examples:examples_vendored_node //examples:examples_vendored_node_and_yarn no_output_timeout: 20m - test_legacy_runfiles: + test_user_managed_deps: <<: *job_defaults + resource_class: xlarge steps: - *attach_workspace - *init_environment - - *use_legacy_runfiles - *init_bazel - - *hide_node_and_yarn_local_binaries - - # We should also be able to test targets in a different workspace - # TODO(gmagolan): move these tests into `build` job once - # https://github.com/bazelbuild/bazel/issues/6481 is resolved - - run: 'cd examples/user_managed_deps && bazel run @nodejs//:yarn_node_repositories' - - run: bazel test @examples_user_managed_deps//... - - run: bazel test @e2e_packages//... + - run: cd examples/user_managed_deps && yarn install && bazel test ... workflows: version: 2 @@ -257,3 +243,6 @@ workflows: - test_examples: requires: - setup + - test_user_managed_deps: + requires: + - setup diff --git a/WORKSPACE b/WORKSPACE index 784693bfbe..9a20b7c5f9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -276,16 +276,3 @@ load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries # Depend on the Bazel binaries bazel_binaries(versions = [BAZEL_VERSION]) - -# -# Setup bazel_integration_test repositories -# - -local_repository( - name = "e2e_packages", - path = "e2e/packages", -) - -load("@e2e_packages//:setup_workspace.bzl", "e2e_packages_setup_workspace") - -e2e_packages_setup_workspace() diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel index 8df260c1c2..990e75d4bc 100644 --- a/e2e/BUILD.bazel +++ b/e2e/BUILD.bazel @@ -42,7 +42,6 @@ e2e_integration_test( e2e_integration_test( name = "e2e_packages", - workspace_files = "@e2e_packages//:all_files", ) e2e_integration_test( diff --git a/e2e/packages/BUILD.bazel b/e2e/packages/BUILD.bazel index a440b36107..b088eaa37d 100644 --- a/e2e/packages/BUILD.bazel +++ b/e2e/packages/BUILD.bazel @@ -45,17 +45,3 @@ nodejs_test( # TODO(gregmagolan): fix this test on windows tags = ["fix-windows"], ) - -# For testing from the root workspace of this repository with bazel_integration_test. -filegroup( - name = "all_files", - srcs = glob( - include = ["**/*"], - exclude = [ - "bazel-out/**/*", - "dist/**/*", - "node_modules/**/*", - ], - ), - visibility = ["//visibility:public"], -) diff --git a/e2e/packages/WORKSPACE b/e2e/packages/WORKSPACE index 137195e6cd..ab85380be3 100644 --- a/e2e/packages/WORKSPACE +++ b/e2e/packages/WORKSPACE @@ -8,13 +8,43 @@ http_archive( urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.2/rules_nodejs-0.42.2.tar.gz"], ) -load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories") +load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "npm_install", "yarn_install") # Test that check_rules_nodejs_version works as expected check_rules_nodejs_version(minimum_version_string = "0.11.2") node_repositories() -load(":setup_workspace.bzl", "e2e_packages_setup_workspace") +npm_install( + name = "e2e_packages_npm_install", + data = ["//:postinstall.js"], + package_json = "//:npm1/package.json", + package_lock_json = "//:npm1/package-lock.json", + # Just here as a smoke test for this attribute + prod_only = True, + symlink_node_modules = False, +) + +npm_install( + name = "e2e_packages_npm_install_duplicate_for_determinism_testing", + data = ["//:postinstall.js"], + package_json = "//:npm2/package.json", + package_lock_json = "//:npm2/package-lock.json", + symlink_node_modules = False, +) -e2e_packages_setup_workspace() +yarn_install( + name = "e2e_packages_yarn_install", + data = ["//:postinstall.js"], + package_json = "//:yarn1/package.json", + symlink_node_modules = False, + yarn_lock = "//:yarn1/yarn.lock", +) + +yarn_install( + name = "e2e_packages_yarn_install_duplicate_for_determinism_testing", + data = ["//:postinstall.js"], + package_json = "//:yarn2/package.json", + symlink_node_modules = False, + yarn_lock = "//:yarn2/yarn.lock", +) diff --git a/e2e/packages/setup_workspace.bzl b/e2e/packages/setup_workspace.bzl deleted file mode 100644 index 89dce1602b..0000000000 --- a/e2e/packages/setup_workspace.bzl +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2017 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. - -"""Helper function to setup @e2e_packages workspace. -""" - -load("@build_bazel_rules_nodejs//:index.bzl", "npm_install", "yarn_install") - -def e2e_packages_setup_workspace(): - """Node repositories for @e2e_packagess - """ - npm_install( - name = "e2e_packages_npm_install", - package_json = "@e2e_packages//:npm1/package.json", - package_lock_json = "@e2e_packages//:npm1/package-lock.json", - data = ["@e2e_packages//:postinstall.js"], - symlink_node_modules = False, - # Just here as a smoke test for this attribute - prod_only = True, - ) - - npm_install( - name = "e2e_packages_npm_install_duplicate_for_determinism_testing", - package_json = "@e2e_packages//:npm2/package.json", - package_lock_json = "@e2e_packages//:npm2/package-lock.json", - data = ["@e2e_packages//:postinstall.js"], - symlink_node_modules = False, - ) - - yarn_install( - name = "e2e_packages_yarn_install", - package_json = "@e2e_packages//:yarn1/package.json", - yarn_lock = "@e2e_packages//:yarn1/yarn.lock", - data = ["@e2e_packages//:postinstall.js"], - symlink_node_modules = False, - ) - - yarn_install( - name = "e2e_packages_yarn_install_duplicate_for_determinism_testing", - package_json = "@e2e_packages//:yarn2/package.json", - yarn_lock = "@e2e_packages//:yarn2/yarn.lock", - data = ["@e2e_packages//:postinstall.js"], - symlink_node_modules = False, - ) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 557f2bba91..9de2ee6e24 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -188,20 +188,6 @@ example_integration_test( tags = ["no-bazelci-windows"], ) -example_integration_test( - name = "examples_user_managed_deps", - # This test requires calling `bazel run @nodejs//:yarn_node_repositories` before `bazel test ...` - bazel_commands = [ - "run @nodejs//:yarn_node_repositories", - "test ...", - ], - # replace the following repositories with the generated archives - repositories = { - "//:release": "build_bazel_rules_nodejs", - "@npm_bazel_jasmine//:release": "npm_bazel_jasmine", - }, -) - example_integration_test( name = "examples_vendored_node", npm_packages = { diff --git a/examples/user_managed_deps/BUILD.bazel b/examples/user_managed_deps/BUILD.bazel index 353533ba39..0f2488a7a5 100644 --- a/examples/user_managed_deps/BUILD.bazel +++ b/examples/user_managed_deps/BUILD.bazel @@ -15,7 +15,6 @@ filegroup( "node_modules/**/*.d.ts", "node_modules/**/*.json", ]), - visibility = ["//visibility:public"], ) filegroup( @@ -34,7 +33,7 @@ nodejs_binary( args = ["--node_options=--expose-gc"], data = [ "index.js", - ":node_modules", + "//:node_modules", ], entry_point = ":index.js", ) diff --git a/examples/user_managed_deps/WORKSPACE b/examples/user_managed_deps/WORKSPACE index 7f29e474d3..dc1ec3412e 100644 --- a/examples/user_managed_deps/WORKSPACE +++ b/examples/user_managed_deps/WORKSPACE @@ -1,12 +1,19 @@ workspace(name = "examples_user_managed_deps") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -http_archive( +# In your code, you'd fetch this repository with an `http_archive` call. +# We do this local repository only because this example lives in the same +# repository with the rules_nodejs code and we want to test them together. +local_repository( name = "build_bazel_rules_nodejs", - sha256 = "16fc00ab0d1e538e88f084272316c0693a2e9007d64f45529b82f6230aedb073", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.2/rules_nodejs-0.42.2.tar.gz"], + path = "../..", ) +# http_archive( +# name = "build_bazel_rules_nodejs", +# urls = ["https://github.com/bazelbuild/rules_nodejs/archive/x.x.x.tar.gz"], +# strip_prefix = "rules_nodejs-x.x.x", +# ) load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dev_dependencies") @@ -43,3 +50,46 @@ local_repository( # urls = ["https://github.com/bazelbuild/rules_nodejs/archive/x.x.x.tar.gz"], # strip_prefix = "rules_nodejs-x.x.x/packages/jasmine/src", # ) + +# In your code, you'd fetch this repository with an `http_archive` call. +# We do this local repository only because this example lives in the same +# repository with the rules_nodejs code and we want to test them together. +local_repository( + name = "npm_bazel_typescript", + path = "../../packages/typescript/src", +) +# http_archive( +# name = "npm_bazel_jasmine", +# urls = ["https://github.com/bazelbuild/rules_nodejs/archive/x.x.x.tar.gz"], +# strip_prefix = "rules_nodejs-x.x.x/packages/typescript/src", +# ) + +# TODO(gregmagolan): keep this in sync with root WORKSPACE programatically +git_repository( + name = "build_bazel_rules_typescript", + commit = "951ae46a9651e9f6814b303c5902d858cc509aa4", + remote = "http://github.com/bazelbuild/rules_typescript.git", +) + +# We have a source dependency on build_bazel_rules_typescript +# so we must repeat its transitive toolchain deps +load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dev_dependencies") + +rules_typescript_dev_dependencies() + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +gazelle_dependencies() + +go_rules_dependencies() + +go_register_toolchains() + +load("@build_bazel_rules_typescript//internal:ts_repositories.bzl", "ts_setup_dev_workspace") + +ts_setup_dev_workspace() + +load("@npm_bazel_typescript//internal:ts_repositories.bzl", "ts_setup_workspace") + +ts_setup_workspace() diff --git a/examples/user_managed_deps/package.json b/examples/user_managed_deps/package.json index 28966d52b8..cda7bbab67 100644 --- a/examples/user_managed_deps/package.json +++ b/examples/user_managed_deps/package.json @@ -1,7 +1,8 @@ { "description": "runtime dependencies for program example", "devDependencies": { - "jasmine": "~2.8.0", + "jasmine": "~3.4.0", + "jasmine-core": "~3.4.0", "v8-coverage": "1.0.9" }, "scripts": { diff --git a/examples/user_managed_deps/yarn.lock b/examples/user_managed_deps/yarn.lock index c64cfa6375..e44fd90022 100644 --- a/examples/user_managed_deps/yarn.lock +++ b/examples/user_managed_deps/yarn.lock @@ -88,10 +88,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -exit@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - find-up@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" @@ -123,17 +119,6 @@ get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" -glob@^7.0.6: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - glob@^7.1.3: version "7.1.4" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" @@ -223,17 +208,18 @@ istanbul-reports@^1.3.0: dependencies: handlebars "^4.0.3" -jasmine-core@~2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" +jasmine-core@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.4.0.tgz#2a74618e966026530c3518f03e9f845d26473ce3" + integrity sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg== -jasmine@~2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.8.0.tgz#6b089c0a11576b1f16df11b80146d91d4e8b8a3e" +jasmine@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.4.0.tgz#0fa68903ff0c9697459cd044b44f4dcef5ec8bdc" + integrity sha512-sR9b4n+fnBFDEd7VS2el2DeHgKcPiMVn44rtKFumq9q7P/t8WrxsVIZPob4UDdgcDNCwyDqwxCt4k9TDRmjPoQ== dependencies: - exit "^0.1.2" - glob "^7.0.6" - jasmine-core "~2.8.0" + glob "^7.1.3" + jasmine-core "~3.4.0" json-parse-better-errors@^1.0.1: version "1.0.2" diff --git a/packages/jasmine/src/BUILD.bazel b/packages/jasmine/src/BUILD.bazel index 55421db5cd..95acb245f7 100644 --- a/packages/jasmine/src/BUILD.bazel +++ b/packages/jasmine/src/BUILD.bazel @@ -16,7 +16,6 @@ # Parts of this BUILD file only necessary when building from source. # The generated `@bazel/jasmine` npm package contains a trimmed BUILD file using INTERNAL fences. load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library") package(default_visibility = ["//visibility:public"]) @@ -49,14 +48,4 @@ js_library( ], module_name = "@bazel/jasmine", ) - -pkg_tar( - name = "release", - srcs = [ - "index.from_src.bzl", - ":package_contents", - ], - extension = "tar.gz", - tags = ["manual"], -) # END-INTERNAL diff --git a/scripts/test_all.sh b/scripts/test_all.sh index c11b75074e..42df3d298e 100755 --- a/scripts/test_all.sh +++ b/scripts/test_all.sh @@ -43,11 +43,6 @@ echo_and_run bazel run @bazel_workspace_a//subdir:bin echo_and_run bazel run @bazel_workspace_b//:bin echo_and_run bazel run @bazel_workspace_b//subdir:bin -# bazel test @examples_user_managed_deps//... # DOES NOT WORK WITH --nolegacy_external_runfiles -# bazel test @e2e_packages//... # DOES NOT WORK WITH --nolegacy_external_runfiles -# TODO: re-enable when after https://github.com/bazelbuild/bazel/pull/8090 makes it into a Bazel release -# Related issue https://github.com/bazelbuild/bazel/issues/8088 on Windows - printf "\n\nRunning all e2e tests (this make take some time as these are run sequentially...)\n" echo_and_run yarn test_e2e