Skip to content

Commit 902eb4d

Browse files
committed
Test with --all_incompatible_changes
1 parent c7b9ae3 commit 902eb4d

File tree

10 files changed

+126
-120
lines changed

10 files changed

+126
-120
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ os:
1111
- osx
1212

1313
env:
14-
- BAZEL=0.20.0
15-
- BAZEL=0.24.0
14+
- BAZEL=0.24.1
1615

1716
before_install:
1817
- |

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
BAZEL_ARGS=--all_incompatible_changes --incompatible_disallow_struct_provider_syntax=false
2+
13
test_helloworld:
2-
(cd tests/helloworld && bazel test //...)
4+
(cd tests/helloworld && bazel test ${BAZEL_ARGS} //...)
35

46
test_lyrics:
5-
(cd tests/lyrics && bazel test //...)
7+
(cd tests/lyrics && bazel test ${BAZEL_ARGS} //...)
68

79
test_express:
8-
(cd tests/express && bazel test //...)
10+
(cd tests/express && bazel test ${BAZEL_ARGS} //...)
911

1012
test_namespace:
11-
(cd tests/namespace && bazel test //...)
13+
(cd tests/namespace && bazel test ${BAZEL_ARGS} //...)
1214

1315
test_rollup:
14-
(cd tests/rollup && bazel test //...)
16+
(cd tests/rollup && bazel test ${BAZEL_ARGS} //...)
1517

1618
test_typescript:
17-
(cd tests/typescript && bazel test //...)
19+
(cd tests/typescript && bazel test ${BAZEL_ARGS} //...)
1820

1921
test_webpack:
20-
(cd tests/webpack && bazel test //...)
22+
(cd tests/webpack && bazel test ${BAZEL_ARGS} //...)
2123

2224
test_polymer-cli:
2325
(cd tests/polymer-cli && bazel test //...)
2426

2527
test_mocha:
26-
(cd tests/mocha && bazel test //...)
28+
(cd tests/mocha && bazel test ${BAZEL_ARGS} //...)
2729

2830
# polymer cli not included as it appears to still be a WIP
2931
test_all: test_helloworld test_lyrics test_express test_namespace test_typescript test_webpack test_mocha test_rollup

node/internal/mocha_test.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("//node:internal/providers.bzl", "NodeModuleInfo")
12
load("//node:internal/node_module.bzl", "node_module")
23
load("//node:internal/node_modules.bzl", "node_modules")
34

node/internal/node_binary.bzl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("//node:internal/providers.bzl", "NodeModuleInfo", "NodeModulesInfo", "NodeBinaryInfo")
12
load("//node:internal/node_modules.bzl", "node_modules")
23
load("//node:internal/node_module.bzl", "node_module")
34
load("//node:internal/node_bundle.bzl", "node_bundle")
@@ -15,7 +16,7 @@ def create_launcher(ctx, output_dir, node, manifest):
1516
1617
"""
1718

18-
entry_module = ctx.attr.entrypoint.node_module
19+
entry_module = ctx.attr.entrypoint[NodeModuleInfo]
1920

2021
# Entrypoint is a string that is used in the script for the node
2122
# main start point. It can be the name of the module itself (in
@@ -94,44 +95,45 @@ def create_launcher(ctx, output_dir, node, manifest):
9495
' '.join(cmd)
9596
]
9697

97-
ctx.file_action(
98+
ctx.actions.write(
9899
output = ctx.outputs.executable,
99-
executable = True,
100+
is_executable = True,
100101
content = '\n'.join(lines),
101102
)
102103

103104

104105
def node_binary_impl(ctx):
105106
target_dir = ctx.attr.target
106107

107-
node = ctx.new_file('%s/%s' % (target_dir, ctx.executable._node.basename))
108-
ctx.action(
108+
node = ctx.actions.declare_file('%s/%s' % (target_dir, ctx.executable._node.basename))
109+
ctx.actions.run_shell(
109110
mnemonic = 'CopyNode',
110-
inputs = [ctx.executable._node],
111+
tools = [ctx.executable._node],
111112
outputs = [node],
112113
command = 'cp %s %s' % (ctx.executable._node.path, node.path),
113114
)
114115

115-
files = ctx.attr.node_modules.node_modules.files
116-
create_launcher(ctx, target_dir, node, ctx.attr.node_modules.node_modules.manifest)
116+
node_modules = ctx.attr.node_modules[NodeModulesInfo]
117+
files = node_modules.files
118+
create_launcher(ctx, target_dir, node, node_modules.manifest)
117119

118120
runfiles = [node, ctx.outputs.executable] + files
119-
120-
return struct(
121+
122+
return [DefaultInfo(
121123
runfiles = ctx.runfiles(
122124
files = runfiles,
123125
collect_data = True,
124126
),
125-
node_binary = struct(
126-
files = runfiles,
127-
node = node,
128-
)
129-
)
127+
), NodeBinaryInfo(
128+
files = runfiles,
129+
node = node,
130+
)]
131+
130132

131133
binary_attrs = {
132134
# The main entrypoint module to run
133135
'entrypoint': attr.label(
134-
providers = ['node_module'],
136+
providers = [NodeModuleInfo],
135137
mandatory = False,
136138
),
137139
# An optional named executable module script to run
@@ -143,7 +145,7 @@ binary_attrs = {
143145
# attribute.
144146
'node_modules': attr.label(
145147
mandatory = True,
146-
providers = ['node_modules'],
148+
providers = [NodeModulesInfo],
147149
),
148150
# A namespace (string) within the package where assets are built.
149151
# This attribute value is also passed the node_modules such that
@@ -160,8 +162,7 @@ binary_attrs = {
160162
# The node executable
161163
'_node': attr.label(
162164
default = Label('@node//:node'),
163-
single_file = True,
164-
allow_files = True,
165+
allow_single_file = True,
165166
executable = True,
166167
cfg = 'host',
167168
),

node/internal/node_bundle.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
2+
load("//node:internal/providers.bzl", "NodeBinaryInfo")
23

34
def _node_bundle_impl(ctx):
4-
return struct(
5-
files = depset(ctx.attr.node_binary.node_binary.files),
6-
)
5+
return [DefaultInfo(
6+
files = depset(ctx.attr.node_binary[NodeBinaryInfo].files),
7+
)]
8+
79

810
_node_bundle = rule(
911
_node_bundle_impl,
1012
attrs = {
1113
'node_binary': attr.label(
12-
providers = ['node_binary'],
14+
providers = [NodeBinaryInfo],
1315
mandatory = True,
1416
),
1517
},

node/internal/node_module.bzl

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
_node_filetype = [".js", ".node"]
1+
load("//node:internal/providers.bzl", "NodeModuleInfo")
22

3+
_node_filetype = [".js", ".node"]
34

45
def _relname(ctx, root_file, file):
56
"""Get a path string relative to the root_file (usually the
@@ -31,7 +32,7 @@ def _get_package_dependencies(module_deps):
3132
"""
3233
dependencies = {}
3334
for dep in module_deps:
34-
module = dep.node_module
35+
module = dep[NodeModuleInfo]
3536
dependencies[module.name] = module.version
3637
return struct(**dependencies)
3738

@@ -50,7 +51,7 @@ def _get_module_name(ctx):
5051

5152

5253
def _create_package_json(ctx, name, files, executables):
53-
output_file = ctx.new_file("%s/package.json" % name)
54+
output_file = ctx.actions.declare_file("%s/package.json" % name)
5455

5556
json = {
5657
"name": name,
@@ -77,7 +78,7 @@ def _create_package_json(ctx, name, files, executables):
7778

7879
content = struct(**json)
7980

80-
ctx.file_action(
81+
ctx.actions.write(
8182
output = output_file,
8283
content = content.to_json(),
8384
)
@@ -86,12 +87,14 @@ def _create_package_json(ctx, name, files, executables):
8687

8788

8889
def _get_transitive_modules(deps, key):
89-
modules = depset()
90+
allmodules = []
9091
for dep in deps:
91-
module = dep.node_module
92-
modules += [module]
93-
modules += getattr(module, key, [])
94-
return modules
92+
module = dep[NodeModuleInfo]
93+
allmodules.append(module)
94+
if hasattr(module, key):
95+
allmodules += getattr(module, key).to_list()
96+
# allmodules += getattr(module, key, [])
97+
return depset(allmodules)
9598

9699

97100
def _get_path_for_module_file(ctx, root_file, file, sourcemap):
@@ -114,7 +117,7 @@ def _get_path_for_module_file(ctx, root_file, file, sourcemap):
114117

115118

116119
def _copy_file(ctx, src, dst):
117-
ctx.action(
120+
ctx.actions.run_shell(
118121
mnemonic = "CopyFileToNodeModule",
119122
inputs = [src],
120123
outputs = [dst],
@@ -150,40 +153,33 @@ def _node_module_impl(ctx):
150153

151154
index_file = None
152155
if ctx.file.index:
153-
dst = ctx.new_file("%s/index.%s" % (name, ctx.file.index.extension))
156+
dst = ctx.actions.declare_file("%s/index.%s" % (name, ctx.file.index.extension))
154157
outputs.append(_copy_file(ctx, ctx.file.index, dst))
155158
index_file = dst
156159

157160
sourcemap = {}
158161
for src in files:
159-
dst = ctx.new_file("%s/%s" % (name, _get_path_for_module_file(ctx, root_file, src, sourcemap)))
162+
dst = ctx.actions.declare_file("%s/%s" % (name, _get_path_for_module_file(ctx, root_file, src, sourcemap)))
160163
outputs.append(_copy_file(ctx, src, dst))
161164

162165
for src in ctx.files.data:
163166
filename = src.short_path
164167
dst = ctx.actions.declare_file(filename, sibling = root_file)
165168
outputs.append(_copy_file(ctx, src, dst))
166169

167-
return struct(
170+
return [DefaultInfo(
168171
files = depset(outputs + ctx.files.data),
169-
node_module = struct(
170-
identifier = name.replace(ctx.attr.separator, '_'),
171-
name = name,
172-
version = ctx.attr.version,
173-
url = ctx.attr.url,
174-
sha1 = ctx.attr.sha1,
175-
description = ctx.attr.description,
176-
executables = executables,
177-
package_json = package_json,
178-
root = root_file,
179-
sourcemap = sourcemap,
180-
index = index_file,
181-
files = depset(outputs),
182-
sources = depset(files),
183-
transitive_deps = _get_transitive_modules(ctx.attr.deps, "transitive_deps"),
184-
transitive_dev_deps = _get_transitive_modules(ctx.attr.dev_deps, "transitive_dev_deps"),
185-
),
186-
)
172+
), NodeModuleInfo(
173+
identifier = name.replace(ctx.attr.separator, '_'),
174+
name = name,
175+
version = ctx.attr.version,
176+
url = ctx.attr.url,
177+
sha1 = ctx.attr.sha1,
178+
executables = executables,
179+
package_json = package_json,
180+
files = depset(outputs),
181+
transitive_deps = _get_transitive_modules(ctx.attr.deps, "transitive_deps"),
182+
)]
187183

188184

189185
node_module = rule(
@@ -231,8 +227,8 @@ node_module = rule(
231227
# the module. If not present, one will be generated UNLESS an
232228
# index file is provided.
233229
"package_json": attr.label(
234-
allow_files = ["package.json"],
235-
single_file = True,
230+
# allow_files = ["package.json"],
231+
allow_single_file = True,
236232
),
237233

238234
"data": attr.label_list(
@@ -242,12 +238,12 @@ node_module = rule(
242238

243239
# Module dependencies.
244240
"deps": attr.label_list(
245-
providers = ["node_module"],
241+
providers = [NodeModuleInfo],
246242
),
247243

248244
# Development-only module dependencies.
249245
"dev_deps": attr.label_list(
250-
providers = ["node_module"],
246+
providers = [NodeModuleInfo],
251247
),
252248

253249
# 'Binary' scripts, to be named in the 'package_json.bin'
@@ -279,17 +275,16 @@ node_module = rule(
279275
# File that should be named as the package.json 'main'
280276
# attribute.
281277
"main": attr.label(
282-
allow_files = True,
283278
mandatory = False,
284-
single_file = True,
279+
allow_single_file = True,
285280
),
286281

287282
# File that should be copied to the module root as 'index.js'.
288283
# If the index file is present and no 'main' is provided, a
289284
# package.json file will not be generated.
290285
"index": attr.label(
291-
allow_files = _node_filetype,
292-
single_file = True,
286+
# allow_files = _node_filetype,
287+
allow_single_file = True,
293288
),
294289
},
295290
)

0 commit comments

Comments
 (0)