-
Notifications
You must be signed in to change notification settings - Fork 0
443 lines (375 loc) · 15.7 KB
/
Copy pathbcr-compatibility.yml
File metadata and controls
443 lines (375 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
name: BCR Compatibility Testing
on:
# Run on pushes to main and develop for continuous validation
push:
branches: [main, develop]
# Run on PRs to catch BCR issues early
pull_request:
branches: [main]
# Allow manual triggering for testing specific scenarios
workflow_dispatch:
inputs:
test_target:
description: "Specific target to test (default: //examples/basic:hello_component)"
required: false
default: "//examples/basic:hello_component"
timeout_minutes:
description: "Timeout in minutes (default: 15)"
required: false
default: "15"
env:
DOCKER_IMAGE: gcr.io/bazel-public/ubuntu2204
DEFAULT_TARGET: //examples/basic:hello_component
jobs:
bcr-hermetic-test:
name: BCR Hermetic Build Test
# Stays on ubuntu-latest: docker run against vendor BCR image (gcr.io/bazel-public/ubuntu2204) untested on smithy podman shim.
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Test Hermetic Build in BCR Environment
env:
TEST_TARGET: ${{ github.event.inputs.test_target || env.DEFAULT_TARGET }}
TIMEOUT_MINUTES: ${{ github.event.inputs.timeout_minutes || '15' }}
run: |
echo "🔍 BCR (Bazel Central Registry) Compatibility Test"
echo "Docker Image: $DOCKER_IMAGE"
echo "Test Target: $TEST_TARGET"
echo "Timeout: ${TIMEOUT_MINUTES} minutes"
echo "----------------------------------------"
# Calculate timeout in seconds
TIMEOUT_SECONDS=$((TIMEOUT_MINUTES * 60))
# Run the hermetic build test
docker run --rm -v "$(pwd):/workspace" -w /workspace \
$DOCKER_IMAGE bash -c "
set -euo pipefail
echo '=== BCR Environment Details ==='
echo 'OS Information:'
cat /etc/os-release
echo
echo 'Architecture:'
uname -m
echo
echo 'Available Tools:'
which git || echo 'git: not found'
which curl || echo 'curl: not found'
which cargo || echo 'cargo: not found (expected - should be hermetic)'
which npm || echo 'npm: not found (expected - should be hermetic)'
which go || echo 'go: not found (expected - should be hermetic)'
echo
echo '=== Bazel Setup ==='
# Set up Bazel cache directory with proper permissions
mkdir -p /tmp/bazel_cache
chmod 755 /tmp/bazel_cache
echo 'Cache directory created: /tmp/bazel_cache'
echo
echo '=== Testing Hermetic Build ==='
echo \"Building target: $TEST_TARGET\"
echo \"Timeout: ${TIMEOUT_SECONDS} seconds\"
echo 'This test verifies:'
echo ' ✓ All toolchains work without system dependencies'
echo ' ✓ Downloads and builds are hermetic'
echo ' ✓ Build succeeds in minimal Docker environment'
echo
# Run the build with timeout
timeout ${TIMEOUT_SECONDS} bazel --output_base=/tmp/bazel_cache build $TEST_TARGET
BUILD_EXIT_CODE=\$?
echo
if [ \$BUILD_EXIT_CODE -eq 0 ]; then
echo '✅ BCR HERMETIC BUILD SUCCESSFUL!'
echo
echo '=== Build Verification ==='
# Find and verify any WASM outputs
echo 'Looking for WebAssembly component outputs...'
find bazel-bin -name '*.wasm' -type f | head -5 | while read wasm_file; do
echo \"Found: \$wasm_file\"
echo \" Size: \$(stat -c%s \"\$wasm_file\") bytes\"
echo \" Type: \$(file \"\$wasm_file\" | cut -d: -f2)\"
done
wasm_count=\$(find bazel-bin -name '*.wasm' -type f | wc -l)
if [ \$wasm_count -gt 0 ]; then
echo \"✅ Successfully created \$wasm_count WebAssembly component(s)\"
else
echo 'ℹ️ No .wasm files found (may be expected for some targets)'
fi
elif [ \$BUILD_EXIT_CODE -eq 124 ]; then
echo '❌ BCR BUILD TIMED OUT'
echo \"Build exceeded ${TIMEOUT_MINUTES} minute limit\"
echo 'This may indicate:'
echo ' - Network issues downloading dependencies'
echo ' - Non-hermetic system tool dependencies'
echo ' - Infinite loops in toolchain setup'
exit 1
else
echo '❌ BCR BUILD FAILED'
echo \"Exit code: \$BUILD_EXIT_CODE\"
echo 'This indicates a fundamental compatibility issue with BCR environment'
exit 1
fi
"
bcr-toolchain-validation:
name: BCR Toolchain Validation
# Stays on ubuntu-latest: docker run against vendor BCR image (gcr.io/bazel-public/ubuntu2204) untested on smithy podman shim.
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Validate All Toolchains in BCR Environment
run: |
echo "🔧 BCR Toolchain Validation Test"
echo "This test validates that all toolchains can be configured"
echo "without requiring system tools or non-hermetic dependencies"
echo "----------------------------------------"
docker run --rm -v "$(pwd):/workspace" -w /workspace \
$DOCKER_IMAGE bash -c "
set -euo pipefail
echo '=== Toolchain Configuration Test ==='
mkdir -p /tmp/bazel_cache
chmod 755 /tmp/bazel_cache
# Test toolchain analysis (faster than full build)
echo 'Testing toolchain resolution and configuration...'
timeout 600 bazel --output_base=/tmp/bazel_cache query --output=label $DEFAULT_TARGET
ANALYZE_EXIT_CODE=\$?
if [ \$ANALYZE_EXIT_CODE -eq 0 ]; then
echo '✅ All toolchains configured successfully in BCR environment'
echo
echo '=== Toolchain Information ==='
# Show configured toolchains
echo 'Registered toolchains:'
bazel --output_base=/tmp/bazel_cache query --output=label 'kind(toolchain, //...)' | head -10 || echo 'Query failed'
elif [ \$ANALYZE_EXIT_CODE -eq 124 ]; then
echo '❌ Toolchain analysis timed out'
echo 'This suggests toolchain setup is hanging or very slow'
exit 1
else
echo '❌ Toolchain analysis failed'
echo \"Exit code: \$ANALYZE_EXIT_CODE\"
echo 'This indicates toolchain configuration issues'
exit 1
fi
"
bcr-multi-platform-test:
name: BCR Multi-Platform Test
# Stays on ${{ matrix.os }}: matrix is multi-OS (Linux/macOS/Windows) + Bazel; smithy fleet is Linux-only without Bazel.
runs-on: ${{ matrix.os }}
timeout-minutes: 25
# Run on all PRs and main branch to catch Windows issues early
# Windows builds have been failing silently - now we'll catch them!
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
bazel_version: ["6.x", "7.x", "8.x"]
exclude:
# Skip some combinations to reduce CI load
- os: windows-latest
bazel_version: "6.x"
# On PRs, only test latest Bazel versions to reduce load
- os: windows-latest
bazel_version: "7.x"
- os: ubuntu-latest
bazel_version: "6.x"
- os: macos-latest
bazel_version: "6.x"
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-version: "1.x"
bazelisk-cache: true
- name: Test BCR Presubmit Targets
shell: bash
run: |
echo "🎯 BCR Multi-Platform Test"
echo "Platform: ${{ matrix.os }}"
echo "Bazel: ${{ matrix.bazel_version }}"
echo "----------------------------------------"
# Use the targets from our presubmit.yml
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "Testing Windows-compatible targets only"
bazel build //examples/basic:hello_component
bazel test //test/unit:unit_tests
else
echo "Testing full target set"
bazel build //test_examples/basic:hello_component
bazel build //examples/basic:hello_component
bazel test //test/integration:basic_component_build_test || echo "Integration test failed but continuing"
bazel test //test/unit:unit_tests
fi
bcr-incompatible-flags-test:
name: BCR Incompatible Flags Test
# Stays on ubuntu-latest: Bazel not installed on smithy fleet.
runs-on: ubuntu-latest
timeout-minutes: 20
# Only run on main branch and manual dispatch
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Setup Bazel with Incompatible Flags
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-version: "1.x"
bazelisk-cache: true
- name: Test with Common Incompatible Flags
run: |
echo "🚩 BCR Incompatible Flags Test"
echo "Testing against upcoming Bazel breaking changes"
echo "----------------------------------------"
# Test with commonly problematic incompatible flags
incompatible_flags=(
"--incompatible_enable_cc_toolchain_resolution"
"--incompatible_strict_action_env"
"--incompatible_disable_starlark_host_transitions"
)
for flag in "${incompatible_flags[@]}"; do
echo "Testing with flag: $flag"
# Test basic build with the flag
if bazel build --experimental_enable_bzlmod "$flag" //examples/basic:hello_component; then
echo "✅ Compatible with $flag"
else
echo "⚠️ Potential incompatibility with $flag"
# Log the issue but don't fail (these are future-proofing tests)
fi
done
echo "Incompatible flags testing completed"
bcr-metadata-validation:
name: BCR Metadata Validation
# Stays on ubuntu-latest: bundled with the BCR test suite; keeping co-located with related Bazel jobs.
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Validate BCR Structure
run: |
echo "📋 BCR Metadata Validation"
echo "Checking BCR-required files and structure"
echo "----------------------------------------"
# Check for required BCR files
echo "Checking for required BCR files..."
if [ -f ".bcr/presubmit.yml" ]; then
echo "✅ presubmit.yml found"
else
echo "❌ presubmit.yml missing"
exit 1
fi
# Validate presubmit.yml structure
echo "Validating presubmit.yml structure..."
if grep -q "bcr_test_module" .bcr/presubmit.yml; then
echo "✅ presubmit.yml has bcr_test_module section"
else
echo "❌ presubmit.yml missing bcr_test_module"
exit 1
fi
if grep -q "matrix:" .bcr/presubmit.yml; then
echo "✅ presubmit.yml has testing matrix"
else
echo "❌ presubmit.yml missing testing matrix"
exit 1
fi
# Validate test module exists
echo "Checking test module structure..."
if [ -d "test_examples/basic" ]; then
echo "✅ Test module directory exists"
else
echo "❌ Test module directory missing"
exit 1
fi
if [ -f "test_examples/basic/BUILD.bazel" ]; then
echo "✅ Test module has BUILD.bazel"
else
echo "❌ Test module missing BUILD.bazel"
exit 1
fi
echo "BCR metadata validation completed successfully"
bcr-test-module-validation:
name: BCR Test Module Validation
# Stays on ubuntu-latest: Bazel not installed on smithy fleet.
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: false
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-version: "1.x"
bazelisk-cache: true
- name: Validate BCR Test Module
run: |
echo "🧪 BCR Test Module Validation"
echo "Testing the BCR test module functionality"
echo "----------------------------------------"
# Test the specific module path from presubmit.yml
echo "Testing BCR test module: test_examples/basic"
# Build the test module targets
bazel build //test_examples/basic:hello_component
# Verify the test module can use the main module
echo "Verifying test module can use rules_wasm_component..."
# Check that the test module BUILD file references the main module correctly
if grep -q "rules_wasm_component" test_examples/basic/BUILD.bazel; then
echo "✅ Test module properly references rules_wasm_component"
else
echo "ℹ️ Test module may be using local_path_override (normal for BCR)"
fi
# Test example usage patterns
echo "Testing example usage patterns..."
bazel build //examples/basic:hello_component
echo "BCR test module validation completed"
bcr-summary:
name: BCR Test Summary
# Stays on ubuntu-latest: bundled summary job for the BCR test suite, keeping co-located.
runs-on: ubuntu-latest
needs: [bcr-hermetic-test, bcr-toolchain-validation]
if: always()
steps:
- name: Generate Test Summary
run: |
echo "📋 BCR Compatibility Test Summary"
echo "=================================="
echo
# Check individual job results
if [ "${{ needs.bcr-hermetic-test.result }}" = "success" ]; then
echo "✅ Hermetic Build Test: PASSED"
else
echo "❌ Hermetic Build Test: FAILED"
fi
if [ "${{ needs.bcr-toolchain-validation.result }}" = "success" ]; then
echo "✅ Toolchain Validation: PASSED"
else
echo "❌ Toolchain Validation: FAILED"
fi
echo
echo "BCR Compatibility Status:"
if [ "${{ needs.bcr-hermetic-test.result }}" = "success" ] && \
[ "${{ needs.bcr-toolchain-validation.result }}" = "success" ]; then
echo "🎉 ALL TESTS PASSED - Ready for BCR submission"
echo
echo "The rules_wasm_component project successfully:"
echo " ✓ Builds hermetically in BCR Docker environment"
echo " ✓ Configures all toolchains without system dependencies"
echo " ✓ Meets BCR acceptance testing requirements"
else
echo "⚠️ SOME TESTS FAILED - BCR compatibility issues detected"
echo
echo "Please review failed tests before BCR submission"
exit 1
fi