Skip to content

Commit ce43aa3

Browse files
committed
fix: resolve critical CI failures across multiple component types
Fixes three major CI issues that were causing early build failures: 1. **Go Component World Name Validation**: Updated validation in go/defs.bzl to accept valid WIT world names with colons and forward slashes like 'wasi:cli/command'. Previous validation was too restrictive, rejecting standard WIT namespace syntax. 2. **WIT Dependency Check Syntax Error**: Fixed wit_deps_check.bzl by removing unsupported 'stdout' parameter from ctx.actions.run() and passing output file path as argument instead. This resolves the "unexpected keyword argument 'stdout'" error. 3. **JavaScript Component JCO Installation**: Fixed jco_toolchain.bzl by actually installing npm packages with repository_ctx.execute() instead of creating empty placeholder files. This resolves the "Cannot find module" errors for @bytecodealliance/jco. All fixes maintain hermetic build principles and cross-platform compatibility. Successfully tested JavaScript components and Go world name validation.
1 parent 191c3ef commit ce43aa3

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

MODULE.bazel.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/defs.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ def _assert_valid_go_component_attrs(ctx):
5757

5858
# Validate world name format if provided
5959
if ctx.attr.world:
60-
if not ctx.attr.world.replace("-", "").replace("_", "").isalnum():
61-
fail("go_wasm_component rule '{}' has invalid world name '{}'. World names must be alphanumeric with hyphens/underscores".format(
60+
# WIT world names support namespaces with colons, hyphens, underscores, and forward slashes
61+
# Valid examples: "wasi:cli/command", "example:calculator/operations", "simple-world"
62+
allowed_chars = ctx.attr.world.replace("-", "").replace("_", "").replace(":", "").replace("/", "")
63+
if not allowed_chars.isalnum():
64+
fail("go_wasm_component rule '{}' has invalid world name '{}'. World names must be alphanumeric with hyphens, underscores, colons, and forward slashes".format(
6265
ctx.label, ctx.attr.world))
6366

6467
def _assert_valid_toolchain_setup(ctx, tinygo, wasm_tools):

toolchains/jco_toolchain.bzl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,23 @@ def _setup_downloaded_jco_tools(repository_ctx, platform, jco_version, node_vers
194194

195195
print("JCO dependencies configured")
196196

197-
print("JCO build configured")
198-
199-
# Create jco_workspace directory structure for compatibility
200-
repository_ctx.file("jco_workspace/node_modules/.keep", "")
197+
# Actually install the packages using npm
198+
npm_install_result = repository_ctx.execute([
199+
str(npm_binary),
200+
"install", "--global-style", "--no-package-lock",
201+
] + install_packages, environment = npm_env, working_directory = "jco_workspace")
201202

203+
if npm_install_result.return_code != 0:
204+
print("ERROR: npm install failed:")
205+
print("STDOUT:", npm_install_result.stdout)
206+
print("STDERR:", npm_install_result.stderr)
207+
fail("Failed to install jco dependencies: {}".format(npm_install_result.stderr))
208+
209+
print("JCO installation completed successfully")
210+
202211
# Create robust wrapper script for jco that always uses hermetic Node.js
203212
workspace_path = repository_ctx.path("jco_workspace").realpath
204213

205-
# Create placeholder package.json for compatibility
206-
repository_ctx.file("jco_workspace/node_modules/@bytecodealliance/jco/package.json", "{}")
207-
208214
print("jco installation verified, creating hermetic wrapper...")
209215

210216
if platform.startswith("windows"):

wit/wit_deps_check.bzl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ def _wit_deps_check_impl(ctx):
2222
# Run dependency analysis
2323
output_file = ctx.actions.declare_file(ctx.label.name + "_analysis.json")
2424

25-
# Run dependency analysis using ctx.actions.run with stdout parameter
25+
# Run dependency analysis using ctx.actions.run (without stdout parameter for compatibility)
2626
ctx.actions.run(
2727
executable = ctx.executable._wit_dependency_analyzer,
28-
arguments = [config_file.path],
28+
arguments = [config_file.path, output_file.path],
2929
inputs = [config_file, ctx.file.wit_file],
3030
outputs = [output_file],
31-
stdout = output_file,
3231
mnemonic = "CheckWitDependencies",
3332
progress_message = "Checking WIT dependencies in %s" % ctx.file.wit_file.short_path,
3433
)

0 commit comments

Comments
 (0)