Skip to content

Commit f50c3cb

Browse files
committed
feat: implement centralized SHA management system with automated updates
## Major Features Added ### 🔧 Centralized Checksum Management - **NEW**: `/checksums/` directory with JSON-based tool registry - **NEW**: Centralized API in `checksums/registry.bzl` for all tools - **NEW**: Support for multiple tool versions and platforms - **NEW**: Real verified SHA256 checksums for latest tool releases ### 🤖 Automated Checksum Generator - **NEW**: Rust-based checksum updater with GitHub API integration - **NEW**: Automatic detection of new tool releases - **NEW**: Real-time SHA256 calculation and verification - **NEW**: JSON file updates with validated checksums - **PROVEN**: Successfully updated wasm-tools to 1.236.0 and wasmtime to 35.0.0 ### 🚀 Wasmtime Runtime Support - **NEW**: Complete wasmtime toolchain integration (v35.0.0) - **NEW**: Download and validation with verified checksums - **NEW**: Cross-platform support (darwin_amd64, darwin_arm64, linux_amd64, linux_arm64, windows_amd64) - **NEW**: Bazel module extension and toolchain registration - **TESTED**: Binary downloads and executes correctly ## Technical Improvements ### 📋 Enhanced Toolchain Infrastructure - **NEW**: Wasmtime toolchain extension in `wasm/extensions.bzl` - **NEW**: Automatic tool version detection and updates - **IMPROVED**: JavaScript component build fixes (TypeScript → JavaScript conversion) - **IMPROVED**: JCO toolchain integration with proper npm dependencies - **IMPROVED**: WKG command fixes (fetch → get) with proper syntax ### 🔒 Security & Reliability - **NEW**: Multiple checksum verification layers - **NEW**: GitHub API rate limiting and error handling - **NEW**: Platform-specific binary validation - **IMPROVED**: Tool download retry mechanisms - **VERIFIED**: All checksums validated against official releases ## Infrastructure Updates ### 📦 Build System Enhancements - **NEW**: Rust dependencies for checksum generator in wizer workspace - **NEW**: Wasmtime toolchain type registration - **IMPROVED**: MODULE.bazel with wasmtime extension registration - **IMPROVED**: Pre-commit validation (all checks passing) - **IMPROVED**: Cross-platform compatibility improvements ### 🧹 Code Quality & Maintenance - **FIXED**: JavaScript component TypeScript syntax issues - **FIXED**: JCO command-line argument parsing (kebab-case → camelCase) - **FIXED**: WKG package format and cache directory handling - **IMPROVED**: Consistent code formatting across all languages - **VERIFIED**: All pre-commit hooks passing with new changes ## Production Readiness This implementation provides a **complete foundation** for: - ✅ **Automated weekly checksum updates** (infrastructure ready) - ✅ **Real-world wasmtime component execution** (toolchain working) - ✅ **Multi-language WebAssembly development** (all toolchains integrated) - ✅ **Secure, verified tool downloads** (SHA256 validation working) **Next Steps**: CI workflow automation and enhanced examples with wasmtime execution.
1 parent 8b87fa0 commit f50c3cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7799
-309
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
files: '\.(bzl|bazel|BUILD)$'
1111
pass_filenames: false
1212

13-
# Python formatting and linting
13+
# Python formatting and linting
1414
- repo: https://github.com/psf/black
1515
rev: 25.1.0
1616
hooks:
@@ -62,7 +62,7 @@ repos:
6262
- id: check-merge-conflict
6363
- id: check-case-conflict
6464
- id: check-added-large-files
65-
args: ['--maxkb=1000']
65+
args: ["--maxkb=1000"]
6666
- id: detect-private-key
6767

6868
# Conventional commits validation
@@ -119,4 +119,4 @@ ci:
119119
autoupdate_commit_msg: |
120120
chore: update pre-commit hooks
121121
122-
🤖 Generated with pre-commit
122+
🤖 Generated with pre-commit

.pre-commit-instructions.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,30 @@ pre-commit install --hook-type commit-msg
1919
## What the hooks do
2020

2121
### Code Formatting
22+
2223
- **Buildifier**: Formats Bazel files (`.bzl`, `.bazel`, `BUILD`)
23-
- **Black**: Formats Python files
24+
- **Black**: Formats Python files
2425
- **isort**: Sorts Python imports
2526
- **rustfmt**: Formats Rust files
2627
- **gofmt**: Formats Go files
2728
- **Prettier**: Formats JS/TS/JSON/YAML/Markdown
2829

2930
### Code Quality
31+
3032
- **Clippy**: Rust linting via Bazel (`bazel build //:clippy`)
3133
- **WIT validation**: Checks WIT file syntax
3234
- **Bazel tests**: Runs unit tests for changed files
3335

3436
### Security & Standards
37+
3538
- **Conventional commits**: Enforces conventional commit message format
3639
- **Secret detection**: Prevents committing secrets
3740
- **File checks**: Trailing whitespace, file endings, merge conflicts
3841

3942
## Usage
4043

4144
### Automatic (recommended)
45+
4246
After installation, hooks run automatically on every commit:
4347

4448
```bash
@@ -48,6 +52,7 @@ git commit -m "feat: add new component rule"
4852
```
4953

5054
### Manual
55+
5156
Run all hooks on all files:
5257

5358
```bash
@@ -67,7 +72,7 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/):
6772

6873
```bash
6974
git commit -m "feat: add WebAssembly component validation"
70-
git commit -m "fix: resolve TinyGo compilation issue"
75+
git commit -m "fix: resolve TinyGo compilation issue"
7176
git commit -m "docs: update README with examples"
7277
git commit -m "refactor: modernize shell script usage"
7378
```
@@ -79,12 +84,13 @@ git commit -m "refactor: modernize shell script usage"
7984
This setup integrates with existing project tools:
8085

8186
- **Buildifier** (already in `//:buildifier`)
82-
- **Clippy** (already in `//:clippy`)
87+
- **Clippy** (already in `//:clippy`)
8388
- **git-cliff** (uses conventional commits for changelog)
8489

8590
## Troubleshooting
8691

8792
**Hook fails?**
93+
8894
```bash
8995
# Skip hooks for emergency commits
9096
git commit --no-verify -m "fix: emergency fix"
@@ -93,11 +99,13 @@ git commit --no-verify -m "fix: emergency fix"
9399
```
94100

95101
**Update hooks:**
102+
96103
```bash
97104
pre-commit autoupdate
98105
```
99106

100107
**Clean hook cache:**
108+
101109
```bash
102110
pre-commit clean
103-
```
111+
```

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@
109109
],
110110
"results": {},
111111
"generated_at": "2024-07-30T12:00:00Z"
112-
}
112+
}

MODULE.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ use_repo(wizer, "wizer_toolchain")
106106

107107
register_toolchains("@wizer_toolchain//:wizer_toolchain_def")
108108

109+
# Wasmtime WebAssembly runtime
110+
wasmtime = use_extension("//wasm:extensions.bzl", "wasmtime")
111+
wasmtime.register(
112+
name = "wasmtime",
113+
strategy = "download",
114+
version = "35.0.0",
115+
)
116+
use_repo(wasmtime, "wasmtime_toolchain")
117+
118+
register_toolchains("@wasmtime_toolchain//:wasmtime_toolchain")
119+
109120
# C++ WebAssembly components with WASI SDK
110121
cpp_component = use_extension("//wasm:extensions.bzl", "cpp_component")
111122
cpp_component.register(
@@ -117,6 +128,17 @@ use_repo(cpp_component, "cpp_toolchain")
117128

118129
register_toolchains("@cpp_toolchain//:cpp_component_toolchain")
119130

131+
# JavaScript/TypeScript WebAssembly components with JCO
132+
jco = use_extension("//wasm:extensions.bzl", "jco")
133+
jco.register(
134+
name = "jco",
135+
strategy = "npm",
136+
version = "1.4.0",
137+
)
138+
use_repo(jco, "jco_toolchain")
139+
140+
register_toolchains("@jco_toolchain//:jco_toolchain")
141+
120142
# Rust crates for wizer_initializer tool
121143
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
122144
crate.from_cargo(

MODULE.bazel.lock

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

checksums/BUILD.bazel

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""Centralized checksum management for WebAssembly toolchain"""
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
# Export all tool checksum files for consumption by toolchains
6+
filegroup(
7+
name = "all_checksums",
8+
srcs = glob(["tools/*.json"]),
9+
visibility = ["//visibility:public"],
10+
)
11+
12+
# Individual tool checksum files
13+
filegroup(
14+
name = "wasm_tools_checksums",
15+
srcs = ["tools/wasm-tools.json"],
16+
)
17+
18+
filegroup(
19+
name = "wit_bindgen_checksums",
20+
srcs = ["tools/wit-bindgen.json"],
21+
)
22+
23+
filegroup(
24+
name = "wac_checksums",
25+
srcs = ["tools/wac.json"],
26+
)
27+
28+
filegroup(
29+
name = "wkg_checksums",
30+
srcs = ["tools/wkg.json"],
31+
)
32+
33+
filegroup(
34+
name = "wasmtime_checksums",
35+
srcs = ["tools/wasmtime.json"],
36+
)
37+
38+
filegroup(
39+
name = "wasi_sdk_checksums",
40+
srcs = ["tools/wasi-sdk.json"],
41+
)
42+
43+
filegroup(
44+
name = "tinygo_checksums",
45+
srcs = ["tools/tinygo.json"],
46+
)
47+
48+
filegroup(
49+
name = "jco_checksums",
50+
srcs = ["tools/jco.json"],
51+
)

checksums/generator/BUILD.bazel

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Checksum generator tool for automated SHA management"""
2+
3+
load("@rules_rust//rust:defs.bzl", "rust_binary")
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
rust_binary(
8+
name = "checksum_updater",
9+
srcs = ["src/main.rs"],
10+
edition = "2021",
11+
visibility = ["//visibility:public"],
12+
deps = [
13+
"@checksum_crates//:anyhow",
14+
"@checksum_crates//:chrono",
15+
"@checksum_crates//:clap",
16+
"@checksum_crates//:futures-util",
17+
"@checksum_crates//:octocrab",
18+
"@checksum_crates//:reqwest",
19+
"@checksum_crates//:serde",
20+
"@checksum_crates//:serde_json",
21+
"@checksum_crates//:sha2",
22+
"@checksum_crates//:tempfile",
23+
"@checksum_crates//:tokio",
24+
],
25+
)
26+
27+
# Alias for easier command line usage
28+
alias(
29+
name = "update_checksums",
30+
actual = ":checksum_updater",
31+
)

checksums/generator/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "checksum_generator"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[[bin]]
7+
name = "checksum_updater"
8+
path = "src/main.rs"
9+
10+
[dependencies]
11+
anyhow = "1.0"
12+
clap = { version = "4.4", features = ["derive"] }
13+
reqwest = { version = "0.11", features = ["json", "stream"] }
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
16+
sha2 = "0.10"
17+
tokio = { version = "1.0", features = ["full"] }
18+
chrono = { version = "0.4", features = ["serde"] }
19+
futures-util = "0.3"
20+
tempfile = "3.8"
21+
22+
[dependencies.octocrab]
23+
version = "0.32"
24+
features = ["stream"]

0 commit comments

Comments
 (0)