Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add @bazel/runfiles test #1895

Merged
merged 1 commit into from
Oct 4, 2024
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# @generated
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "@//:pnpm-lock.yaml").
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "@@//:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
.npmrc=-2065072158
examples/js_binary/package.json=-41174383
Expand All @@ -15,6 +15,7 @@ examples/npm_package/packages/pkg_a/package.json=1006424040
examples/npm_package/packages/pkg_b/package.json=1041247977
examples/npm_package/packages/pkg_d/package.json=1110895851
examples/npm_package/packages/pkg_e/package.json=-2145239245
examples/runfiles/package.json=-1545884645
examples/webpack_cli/package.json=1911342006
js/private/coverage/bundle/package.json=-1543718929
js/private/image/package.json=-1260474848
Expand All @@ -28,5 +29,5 @@ npm/private/test/vendored/is-odd/package.json=1041695223
npm/private/test/vendored/lodash-4.17.21.tgz=-1206623349
npm/private/test/vendored/semver-max/package.json=578664053
package.json=-275319675
pnpm-lock.yaml=1584807079
pnpm-lock.yaml=814447031
pnpm-workspace.yaml=-762451270
64 changes: 40 additions & 24 deletions .aspect/workflows/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ workspaces:
tasks:
- test:
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
e2e/bzlmod:
icon: bazel
tasks:
- test:
queue: aspect-default
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -30,8 +30,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -49,8 +49,8 @@ workspaces:
- test:
queue: aspect-default
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand Down Expand Up @@ -93,8 +93,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -109,8 +109,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -125,8 +125,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand Down Expand Up @@ -223,8 +223,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -239,8 +239,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -255,8 +255,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -271,8 +271,24 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
without: true
- configure:
without: true
- delivery:
without: true
e2e/runfiles:
icon: js
tasks:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand All @@ -287,8 +303,8 @@ workspaces:
- test:
queue: aspect-medium
bazel:
flags:
- --config=aspect_rbe
flags:
- --config=aspect_rbe
- format:
without: true
- buildifier:
Expand Down
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ examples/npm_package/packages/pkg_b/node_modules/
examples/npm_package/packages/pkg_c/node_modules/
examples/npm_package/packages/pkg_d/node_modules/
examples/npm_package/packages/pkg_e/node_modules/
examples/runfiles/node_modules
examples/webpack_cli/node_modules/
js/private/coverage/bundle/node_modules
js/private/image/node_modules
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
e2e/pnpm_workspace
e2e/pnpm_workspace_deps
e2e/pnpm_workspace_rerooted
e2e/runfiles
e2e/rules_foo
e2e/stamped_package_json
e2e/update_pnpm_lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bazel_dep(name = "aspect_rules_js", version = "${TAG:1}")
####### Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
bazel_dep(name = "rules_nodejs", version = "6.2.0")
bazel_dep(name = "rules_nodejs", version = "6.3.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "16.14.2")
#################################
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.7.7")
bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "rules_nodejs", version = "6.2.0")
bazel_dep(name = "rules_nodejs", version = "6.3.0")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_darwin_amd64")
Expand Down Expand Up @@ -140,6 +140,7 @@ npm.npm_translate_lock(
"//examples/npm_package/packages/pkg_b:package.json",
"//examples/npm_package/packages/pkg_d:package.json",
"//examples/npm_package/packages/pkg_e:package.json",
"//examples/runfiles:package.json",
"//examples/webpack_cli:package.json",
"//js/private/coverage/bundle:package.json",
"//js/private/image:package.json",
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ npm_translate_lock(
"//examples/npm_package/packages/pkg_b:package.json",
"//examples/npm_package/packages/pkg_d:package.json",
"//examples/npm_package/packages/pkg_e:package.json",
"//examples/runfiles:package.json",
"//examples/webpack_cli:package.json",
"//js/private/coverage/bundle:package.json",
"//js/private/image:package.json",
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_image_oci/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local_path_override(
bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)
bazel_dep(name = "container_structure_test", version = "1.16.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.3.0", dev_dependency = True)
bazel_dep(name = "rules_oci", version = "2.0.0-alpha2", dev_dependency = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_lockfiles/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PNPM_LOCK_TEST_CASES = [
bazel_dep(name = "aspect_bazel_lib", version = "2.7.7")

bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.3.0", dev_dependency = True)

bazel_dep(name = "platforms", version = "0.0.5")

Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_repo_install/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local_path_override(
path = "../..",
)

bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.3.0", dev_dependency = True)

node = use_extension(
"@rules_nodejs//nodejs:extensions.bzl",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local_path_override(

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.3.0", dev_dependency = True)

node = use_extension(
"@rules_nodejs//nodejs:extensions.bzl",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace_rerooted/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local_path_override(

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "6.3.0", dev_dependency = True)

node = use_extension(
"@rules_nodejs//nodejs:extensions.bzl",
Expand Down
1 change: 1 addition & 0 deletions e2e/runfiles/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions e2e/runfiles/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules)
hoist=false
23 changes: 23 additions & 0 deletions e2e/runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages()

js_test(
name = "runfiles",
data = [
"test_fixture.md",
"test_fixture.md.generated_file_suffix",
":node_modules/@bazel/runfiles",
],
entry_point = "test.js",
)

# Path of file must start similar to `test_fixture.md` in order to regression-test a
# scenario where the runfile resolution would accidentally resolve the path to
# `test_fixture.md` through a runfile manifest entry that starts similarly.
genrule(
name = "gen-data",
outs = ["test_fixture.md.generated_file_suffix"],
cmd = """echo "Generated" > $@""",
)
22 changes: 22 additions & 0 deletions e2e/runfiles/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module(name = "e2e_runfiles")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
2 changes: 2 additions & 0 deletions e2e/runfiles/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The presence of this file causes WORKSPACE to be ignored when bzlmod is enabled.
# See https://docs.google.com/document/d/1JtXIVnXyFZ4bmbiBCr5gsTH4-opZAFf5DMMb-54kES0/edit#heading=h.y054fjub9max
10 changes: 10 additions & 0 deletions e2e/runfiles/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@examples/runfiles",
"private": true,
"dependencies": {
"@bazel/runfiles": "^6.3.0"
},
"pnpm": {
"onlyBuiltDependencies": []
}
}
22 changes: 22 additions & 0 deletions e2e/runfiles/pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions e2e/runfiles/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- '.'
Loading
Loading