Skip to content

Commit dc1c077

Browse files
committed
style: apply code formatting and linting fixes
Apply comprehensive code formatting across all languages via pre-commit hooks: - Buildifier formatting for all Bazel files (.bzl, .bazel, BUILD) - Black and isort formatting for Python files - Rustfmt formatting for Rust source files - Gofmt formatting for Go source files - Prettier formatting for JS/TS/JSON/YAML/Markdown files - Fix trailing whitespace and line endings across all files - Update documentation formatting and consistency This commit ensures consistent code style across the entire codebase following language-specific best practices. All formatting is applied automatically via pre-commit hooks for future consistency.
1 parent 9906bd6 commit dc1c077

File tree

239 files changed

+4922
-3642
lines changed

Some content is hidden

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

239 files changed

+4922
-3642
lines changed

.bazelci/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ This directory contains Buildkite CI configuration for `rules_wasm_component`, f
1010
## Test Matrix
1111

1212
### Platforms
13+
1314
- **Ubuntu 22.04** - Primary Linux platform
1415
- **Ubuntu 18.04** - Legacy Linux support
1516
- **macOS ARM64** - Apple Silicon support
1617
- **Windows** - Cross-platform compatibility
1718
- **RBE** - Remote Build Execution for scalability
1819

1920
### Bazel Versions
21+
2022
- **7.4.1** - Minimum supported LTS version
2123
- **rolling** - Latest Bazel version (soft fail)
2224

2325
### Build Configurations
26+
2427
- **Standard** - Default build and test
2528
- **Bzlmod** - Modern dependency management
2629
- **Optimized** - Performance validation
@@ -30,19 +33,22 @@ This directory contains Buildkite CI configuration for `rules_wasm_component`, f
3033
## Specialized Test Jobs
3134

3235
### WebAssembly Component Specific
36+
3337
- **WAC Composition** - Component composition validation
3438
- **Multi-profile** - Debug/release build variants
3539
- **Toolchain** - WASM toolchain validation
3640
- **Dependencies** - External dependency resolution
3741

3842
### Quality Assurance
43+
3944
- **Integration Tests** - End-to-end workflow validation
4045
- **Unit Tests** - Rule implementation testing
4146
- **Examples** - Real-world usage scenarios
4247

4348
## Integration with GitHub Actions
4449

4550
The project uses a hybrid CI approach:
51+
4652
- **GitHub Actions** - Community accessibility, formatting, documentation
4753
- **Buildkite** - Industry standard for Bazel rules, comprehensive platform matrix
4854

@@ -51,9 +57,10 @@ This follows the pattern established by `rules_rust` and other major Bazel rules
5157
## BCR Compatibility
5258

5359
The CI configuration is designed to meet BCR submission requirements:
60+
5461
- Multi-platform testing
5562
- Multiple Bazel version support
5663
- Comprehensive test coverage
5764
- Industry-standard patterns
5865

59-
This ensures the rules are ready for publication to the Bazel Central Registry.
66+
This ensures the rules are ready for publication to the Bazel Central Registry.

.bazelci/github-actions-integration.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ This document explains how to integrate the Buildkite CI configuration with your
99
The existing GitHub Actions workflow (`.github/workflows/ci.yml`) and the new Buildkite CI configuration (`.bazelci/presubmit.yml`) work together to provide comprehensive testing:
1010

1111
**GitHub Actions** - Fast feedback and basic validation:
12+
1213
- Quick lint and format checks
1314
- Basic build and test validation on Linux and macOS
1415
- Essential WebAssembly component validation
1516
- Integration tests for core functionality
1617

1718
**Buildkite CI** - Comprehensive testing matrix:
19+
1820
- Multi-platform testing (including Windows)
1921
- Multiple Bazel versions (minimum, current, rolling)
2022
- Various configuration combinations (bzlmod vs WORKSPACE)
@@ -33,16 +35,16 @@ buildkite_trigger:
3335
name: Trigger Buildkite CI
3436
runs-on: ubuntu-latest
3537
if: github.event_name == 'pull_request'
36-
38+
3739
steps:
38-
- name: Trigger Buildkite Build
39-
uses: buildkite/[email protected]
40-
with:
41-
buildkite_api_access_token: ${{ secrets.BUILDKITE_API_ACCESS_TOKEN }}
42-
pipeline: "your-org/rules-wasm-component"
43-
commit: ${{ github.event.pull_request.head.sha }}
44-
branch: ${{ github.event.pull_request.head.ref }}
45-
message: "PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
40+
- name: Trigger Buildkite Build
41+
uses: buildkite/[email protected]
42+
with:
43+
buildkite_api_access_token: ${{ secrets.BUILDKITE_API_ACCESS_TOKEN }}
44+
pipeline: "your-org/rules-wasm-component"
45+
commit: ${{ github.event.pull_request.head.sha }}
46+
branch: ${{ github.event.pull_request.head.ref }}
47+
message: "PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
4648
```
4749
4850
### 2. Configure Branch Protection Rules
@@ -52,7 +54,7 @@ In your GitHub repository settings, add Buildkite checks as required status chec
5254
- Navigate to Settings → Branches → Branch protection rules
5355
- Add required status checks for critical Buildkite jobs:
5456
- `ubuntu2204`
55-
- `macos_arm64`
57+
- `macos_arm64`
5658
- `examples_ubuntu2204`
5759
- `integration_tests`
5860
- `bcr_test`
@@ -136,6 +138,7 @@ Configure the following environment variables in Buildkite:
136138
## Testing Matrix Coordination
137139

138140
### GitHub Actions (Fast Lane)
141+
139142
```yaml
140143
# Focus on essential, fast tests
141144
test_matrix:
@@ -147,6 +150,7 @@ test_matrix:
147150
```
148151

149152
### Buildkite CI (Comprehensive Lane)
153+
150154
```yaml
151155
# Full matrix testing
152156
test_matrix:
@@ -228,6 +232,7 @@ wasm-tools validate bazel-bin/examples/basic/hello_component.wasm
228232
### 2. Buildkite Logs
229233

230234
Access detailed logs in Buildkite UI:
235+
231236
- Build timeline view
232237
- Artifact downloads
233238
- Raw log outputs
@@ -236,36 +241,42 @@ Access detailed logs in Buildkite UI:
236241
### 3. GitHub Actions Comparison
237242

238243
Compare with GitHub Actions results:
244+
239245
- Same commit, different environment results
240246
- Platform-specific differences
241247
- Timing and resource usage variations
242248

243249
## Migration Strategy
244250

245251
### Phase 1: Parallel Testing
252+
246253
- Keep existing GitHub Actions
247254
- Add Buildkite CI as additional testing
248255
- Monitor for inconsistencies
249256

250257
### Phase 2: Gradual Migration
258+
251259
- Move comprehensive tests to Buildkite
252260
- Keep fast feedback in GitHub Actions
253261
- Update branch protection rules
254262

255263
### Phase 3: Optimization
264+
256265
- Fine-tune test distribution
257266
- Optimize cache usage
258267
- Minimize redundant testing
259268

260269
## Cost Optimization
261270

262271
### 1. Selective Testing
272+
263273
```yaml
264274
# Only run full matrix on main branch
265275
if: build.branch == "main" || build.pull_request.draft == false
266276
```
267277

268278
### 2. Resource Management
279+
269280
```yaml
270281
# Use appropriate agent sizes
271282
agents:
@@ -274,9 +285,10 @@ agents:
274285
```
275286

276287
### 3. Parallel Execution Limits
288+
277289
```yaml
278290
# Prevent resource exhaustion
279-
parallelism: 3 # Limit concurrent jobs
291+
parallelism: 3 # Limit concurrent jobs
280292
```
281293

282-
This integration provides comprehensive testing coverage while maintaining fast feedback loops for developers.
294+
This integration provides comprehensive testing coverage while maintaining fast feedback loops for developers.

.bazelci/local-testing.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,28 @@ command_exists() {
4444
# Setup WebAssembly toolchain (similar to CI)
4545
setup_wasm_toolchain() {
4646
echo -e "${YELLOW}=== Setting up WebAssembly toolchain ===${NC}"
47-
47+
4848
# Install Rust if not present
4949
if ! command_exists rustc; then
5050
echo "Installing Rust..."
5151
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
5252
source ~/.cargo/env
5353
fi
54-
54+
5555
# Add WASM targets
5656
run_command "Adding wasm32-wasip1 target" rustup target add wasm32-wasip1
5757
run_command "Adding wasm32-wasip2 target" rustup target add wasm32-wasip2
5858
run_command "Adding wasm32-unknown-unknown target" rustup target add wasm32-unknown-unknown
59-
59+
6060
# Install WebAssembly tools
6161
if ! command_exists wasm-tools; then
6262
run_command "Installing wasm-tools" cargo install wasm-tools
6363
fi
64-
64+
6565
if ! command_exists wac; then
6666
run_command "Installing wac-cli" cargo install wac-cli
6767
fi
68-
68+
6969
if ! command_exists wit-bindgen; then
7070
run_command "Installing wit-bindgen-cli" cargo install wit-bindgen-cli
7171
fi
@@ -74,7 +74,7 @@ setup_wasm_toolchain() {
7474
# Setup Bazel configuration (similar to CI)
7575
setup_bazel_config() {
7676
echo -e "${YELLOW}=== Setting up Bazel configuration ===${NC}"
77-
77+
7878
# Create user.bazelrc with CI-like settings
7979
cat > user.bazelrc << EOF
8080
# CI-like configuration for local testing
@@ -90,45 +90,45 @@ test --test_summary=detailed
9090
build --local_resources=memory=HOST_RAM*.6
9191
build --local_resources=cpu=HOST_CPUS*.8
9292
EOF
93-
93+
9494
echo "Created user.bazelrc with CI-like settings"
9595
}
9696

9797
# Test basic functionality
9898
test_basic() {
9999
echo -e "${YELLOW}=== Testing basic functionality ===${NC}"
100-
100+
101101
run_command "Bazel version check" bazel version
102-
102+
103103
run_command "Build all targets" bazel build //...
104-
104+
105105
run_command "Run all tests" bazel test //...
106-
106+
107107
# Test specific examples
108108
run_command "Build basic example" bazel build //examples/basic:hello_component
109-
109+
110110
run_command "Build multi-profile examples" bazel build //examples/multi_profile:camera_sensor //examples/multi_profile:object_detection
111111
}
112112

113113
# Test with Clippy (if requested)
114114
test_with_clippy() {
115115
if [[ "${WITH_CLIPPY:-}" == "true" ]]; then
116116
echo -e "${YELLOW}=== Testing with Clippy ===${NC}"
117-
117+
118118
# Add clippy config to user.bazelrc
119119
echo "build --config=clippy" >> user.bazelrc
120-
120+
121121
run_command "Build with Clippy" bazel build //...
122122
fi
123123
}
124124

125125
# Validate generated WebAssembly components
126126
validate_wasm_components() {
127127
echo -e "${YELLOW}=== Validating WebAssembly components ===${NC}"
128-
128+
129129
# Build components first
130130
run_command "Build hello component" bazel build //examples/basic:hello_component
131-
131+
132132
# Validate with wasm-tools
133133
if command_exists wasm-tools; then
134134
HELLO_COMPONENT="bazel-bin/examples/basic/hello_component.wasm"
@@ -140,11 +140,11 @@ validate_wasm_components() {
140140
else
141141
echo -e "${YELLOW}wasm-tools not available, skipping validation${NC}"
142142
fi
143-
143+
144144
# Test multi-profile components if they exist
145145
run_command "Build multi-profile debug component" bazel build //examples/multi_profile:camera_sensor_debug || true
146146
run_command "Build multi-profile release component" bazel build //examples/multi_profile:camera_sensor_release || true
147-
147+
148148
# Validate multi-profile components
149149
for component in "camera_sensor_debug.component.wasm" "camera_sensor_release.component.wasm"; do
150150
COMPONENT_PATH="bazel-bin/examples/multi_profile/$component"
@@ -157,36 +157,36 @@ validate_wasm_components() {
157157
# Test integration scenarios
158158
test_integration() {
159159
echo -e "${YELLOW}=== Testing integration scenarios ===${NC}"
160-
160+
161161
# Integration tests
162162
run_command "Run integration tests" bazel test //test/integration/... || true
163-
163+
164164
# Unit tests
165165
run_command "Run unit tests" bazel test //test/unit/... || true
166-
166+
167167
# Toolchain tests
168168
run_command "Run toolchain tests" bazel test //test/toolchain/... || true
169169
}
170170

171171
# Test different configurations
172172
test_configurations() {
173173
echo -e "${YELLOW}=== Testing different configurations ===${NC}"
174-
174+
175175
# Test optimized build
176176
echo "build --compilation_mode=opt" >> user.bazelrc
177177
run_command "Build with optimization" bazel build //examples/basic:hello_component
178-
178+
179179
# Remove opt flag
180180
sed -i.bak '/--compilation_mode=opt/d' user.bazelrc
181181
}
182182

183183
# Cleanup function
184184
cleanup() {
185185
echo -e "${YELLOW}=== Cleaning up ===${NC}"
186-
186+
187187
# Remove generated files
188188
rm -f user.bazelrc user.bazelrc.bak
189-
189+
190190
# Clean Bazel outputs (optional)
191191
if [[ "${CLEAN_AFTER:-}" == "true" ]]; then
192192
run_command "Clean Bazel outputs" bazel clean
@@ -197,27 +197,27 @@ cleanup() {
197197
main() {
198198
echo -e "${GREEN}Starting local CI testing...${NC}"
199199
echo ""
200-
200+
201201
# Check if we're in the right directory
202202
if [[ ! -f "MODULE.bazel" ]] || [[ ! -f ".bazelci/presubmit.yml" ]]; then
203203
echo -e "${RED}Error: Please run this script from the rules_wasm_component root directory${NC}"
204204
exit 1
205205
fi
206-
206+
207207
# Set up environment
208208
setup_wasm_toolchain
209209
setup_bazel_config
210-
210+
211211
# Run tests
212212
test_basic
213213
test_with_clippy
214214
validate_wasm_components
215215
test_integration
216216
test_configurations
217-
217+
218218
# Cleanup
219219
cleanup
220-
220+
221221
echo -e "${GREEN}=== Local CI testing completed successfully! ===${NC}"
222222
}
223223

@@ -245,4 +245,4 @@ case "${1:-all}" in
245245
"all"|*)
246246
main
247247
;;
248-
esac
248+
esac

.bazelci/postsubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ tasks:
8686
- "--config=remote"
8787
- "--remote_executor=grpcs://remotebuildexecution.googleapis.com"
8888
- "--remote_instance_name=projects/bazel-public/instances/default_instance"
89-
- "--test_output=errors"
89+
- "--test_output=errors"

0 commit comments

Comments
 (0)