Skip to content

Commit cc33333

Browse files
committed
feat: register wasmtime toolchain in MODULE.bazel for centralized version management
This change eliminates duplicate wasmtime installation logic by registering the wasmtime toolchain in MODULE.bazel and extracting it from Bazel's cache in the performance workflow. Changes: - MODULE.bazel: Register wasmtime toolchain using rules_wasm_component extension - performance.yml: Extract wasmtime from @wasmtime_toolchain instead of manual download - Use bazel info output_base to construct full path to cached binary Benefits: - Single source of truth for wasmtime version (centralized in MODULE.bazel) - Reuses Bazel's cached download (faster, no redundant network calls) - Eliminates manual version maintenance in performance.yml - Consistent wasmtime version across all Bazel builds and CI workflows
1 parent 1c3ac6f commit cc33333

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

.github/workflows/performance.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,27 @@ jobs:
7070
brew install hyperfine
7171
fi
7272
73-
# Install wasmtime - use manual installation since @wasmtime toolchain not registered
74-
# TODO: Register wasmtime toolchain in MODULE.bazel to reuse Bazel's download
75-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
76-
WASMTIME_VERSION="v27.0.0"
77-
curl -L "https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-x86_64-linux.tar.xz" -o wasmtime.tar.xz
78-
tar -xf wasmtime.tar.xz
79-
sudo mv "wasmtime-${WASMTIME_VERSION}-x86_64-linux/wasmtime" /usr/local/bin/
80-
rm -rf wasmtime.tar.xz "wasmtime-${WASMTIME_VERSION}-x86_64-linux"
81-
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
82-
WASMTIME_VERSION="v27.0.0"
83-
curl -L "https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-aarch64-macos.tar.xz" -o wasmtime.tar.xz
84-
tar -xf wasmtime.tar.xz
85-
sudo mv "wasmtime-${WASMTIME_VERSION}-aarch64-macos/wasmtime" /usr/local/bin/
86-
rm -rf wasmtime.tar.xz "wasmtime-${WASMTIME_VERSION}-aarch64-macos"
73+
# Use wasmtime from Bazel toolchain (registered in MODULE.bazel)
74+
# This ensures version consistency and reuses Bazel's cached download
75+
echo "Extracting wasmtime from Bazel toolchain..."
76+
77+
# Get Bazel output base and wasmtime relative path
78+
OUTPUT_BASE=$(bazel info output_base 2>/dev/null)
79+
WASMTIME_REL=$(bazel cquery --output=files @wasmtime_toolchain//:wasmtime 2>/dev/null | head -1)
80+
WASMTIME_PATH="$OUTPUT_BASE/$WASMTIME_REL"
81+
82+
if [ -f "$WASMTIME_PATH" ]; then
83+
echo "Found wasmtime at: $WASMTIME_PATH"
84+
sudo cp "$WASMTIME_PATH" /usr/local/bin/wasmtime
85+
sudo chmod +x /usr/local/bin/wasmtime
86+
wasmtime --version
87+
else
88+
echo "Error: Could not find wasmtime binary from Bazel at: $WASMTIME_PATH"
89+
echo "Output base: $OUTPUT_BASE"
90+
echo "Relative path: $WASMTIME_REL"
91+
exit 1
8792
fi
8893
89-
# Verify it works
90-
wasmtime --version
91-
9294
- name: Build All Components
9395
run: |
9496
# Build TinyGo component (regular version)

MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ register_toolchains(
8383
"@wasi_sdk//:cc_toolchain",
8484
)
8585

86+
# Wasmtime runtime toolchain for running and testing WASM components
87+
wasmtime = use_extension("@rules_wasm_component//wasm:extensions.bzl", "wasmtime")
88+
wasmtime.register(
89+
name = "wasmtime",
90+
strategy = "download",
91+
version = "35.0.0", # Latest version with verified checksums
92+
)
93+
use_repo(wasmtime, "wasmtime_toolchain")
94+
95+
# Register wasmtime toolchain
96+
register_toolchains("@wasmtime_toolchain//:wasmtime_toolchain")
97+
8698
# Register C++ toolchains explicitly for cross-platform compatibility
8799
# This ensures Linux CI has proper C++ toolchain resolution for Rust binaries
88100
register_toolchains("@bazel_tools//tools/cpp:all")

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)