|
| 1 | +# GitHub Actions Integration with Buildkite CI |
| 2 | + |
| 3 | +This document explains how to integrate the Buildkite CI configuration with your existing GitHub Actions workflow for comprehensive testing coverage. |
| 4 | + |
| 5 | +## Integration Strategy |
| 6 | + |
| 7 | +### Complementary Testing Approach |
| 8 | + |
| 9 | +The existing GitHub Actions workflow (`.github/workflows/ci.yml`) and the new Buildkite CI configuration (`.bazelci/presubmit.yml`) work together to provide comprehensive testing: |
| 10 | + |
| 11 | +**GitHub Actions** - Fast feedback and basic validation: |
| 12 | +- Quick lint and format checks |
| 13 | +- Basic build and test validation on Linux and macOS |
| 14 | +- Essential WebAssembly component validation |
| 15 | +- Integration tests for core functionality |
| 16 | + |
| 17 | +**Buildkite CI** - Comprehensive testing matrix: |
| 18 | +- Multi-platform testing (including Windows) |
| 19 | +- Multiple Bazel versions (minimum, current, rolling) |
| 20 | +- Various configuration combinations (bzlmod vs WORKSPACE) |
| 21 | +- Specialized WebAssembly testing (WASI, component model) |
| 22 | +- Performance and optimization testing |
| 23 | + |
| 24 | +## Recommended Workflow Changes |
| 25 | + |
| 26 | +### 1. Update GitHub Actions for Buildkite Integration |
| 27 | + |
| 28 | +Add Buildkite status checks to your GitHub Actions workflow: |
| 29 | + |
| 30 | +```yaml |
| 31 | +# Add to .github/workflows/ci.yml |
| 32 | +buildkite_trigger: |
| 33 | + name: Trigger Buildkite CI |
| 34 | + runs-on: ubuntu-latest |
| 35 | + if: github.event_name == 'pull_request' |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Trigger Buildkite Build |
| 39 | + |
| 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 }}" |
| 46 | +``` |
| 47 | +
|
| 48 | +### 2. Configure Branch Protection Rules |
| 49 | +
|
| 50 | +In your GitHub repository settings, add Buildkite checks as required status checks: |
| 51 | +
|
| 52 | +- Navigate to Settings → Branches → Branch protection rules |
| 53 | +- Add required status checks for critical Buildkite jobs: |
| 54 | + - `ubuntu2204` |
| 55 | + - `macos_arm64` |
| 56 | + - `examples_ubuntu2204` |
| 57 | + - `integration_tests` |
| 58 | + - `bcr_test` |
| 59 | + |
| 60 | +### 3. Parallel Execution Strategy |
| 61 | + |
| 62 | +Configure workflows to run in parallel for faster feedback: |
| 63 | + |
| 64 | +```yaml |
| 65 | +# Updated strategy in .github/workflows/ci.yml |
| 66 | +jobs: |
| 67 | + # Keep existing fast checks |
| 68 | + lint: |
| 69 | + name: Lint and Format Check |
| 70 | + runs-on: ubuntu-latest |
| 71 | + # ... existing configuration |
| 72 | +
|
| 73 | + # Simplified GitHub Actions tests for speed |
| 74 | + quick_test: |
| 75 | + name: Quick Test on ${{ matrix.os }} |
| 76 | + runs-on: ${{ matrix.os }} |
| 77 | + needs: lint |
| 78 | + strategy: |
| 79 | + matrix: |
| 80 | + os: [ubuntu-latest, macos-latest] |
| 81 | + # ... focused on essential tests only |
| 82 | +
|
| 83 | + # Buildkite trigger (runs in parallel) |
| 84 | + buildkite_comprehensive: |
| 85 | + name: Comprehensive Testing (Buildkite) |
| 86 | + runs-on: ubuntu-latest |
| 87 | + if: github.event_name == 'pull_request' |
| 88 | + # ... trigger Buildkite pipeline |
| 89 | +``` |
| 90 | + |
| 91 | +## Buildkite Setup |
| 92 | + |
| 93 | +### 1. Pipeline Configuration |
| 94 | + |
| 95 | +Create a Buildkite pipeline with the following configuration: |
| 96 | + |
| 97 | +```yaml |
| 98 | +# buildkite.yml (in your Buildkite pipeline settings) |
| 99 | +env: |
| 100 | + BUILDKITE_CLEAN_CHECKOUT: true |
| 101 | +
|
| 102 | +steps: |
| 103 | + - label: ":bazel: Bazel CI" |
| 104 | + plugins: |
| 105 | + - bazelbuild/bazel-ci: |
| 106 | + config: .bazelci/presubmit.yml |
| 107 | +``` |
| 108 | + |
| 109 | +### 2. Agent Configuration |
| 110 | + |
| 111 | +Ensure your Buildkite agents have the necessary tools: |
| 112 | + |
| 113 | +```bash |
| 114 | +# Agent setup script |
| 115 | +#!/bin/bash |
| 116 | +
|
| 117 | +# Install Bazelisk |
| 118 | +curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 |
| 119 | +chmod +x /usr/local/bin/bazel |
| 120 | +
|
| 121 | +# Install Rust (will be done per-job but can be cached) |
| 122 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 123 | +
|
| 124 | +# Install system dependencies |
| 125 | +apt-get update && apt-get install -y build-essential git curl |
| 126 | +``` |
| 127 | + |
| 128 | +### 3. Environment Variables |
| 129 | + |
| 130 | +Configure the following environment variables in Buildkite: |
| 131 | + |
| 132 | +- `BUILDKITE_API_ACCESS_TOKEN`: For GitHub integration |
| 133 | +- `BAZEL_CACHE_URL`: Optional remote cache URL |
| 134 | +- `RUST_CACHE_DIR`: Optional Rust toolchain cache |
| 135 | + |
| 136 | +## Testing Matrix Coordination |
| 137 | + |
| 138 | +### GitHub Actions (Fast Lane) |
| 139 | +```yaml |
| 140 | +# Focus on essential, fast tests |
| 141 | +test_matrix: |
| 142 | + platform: [ubuntu-latest, macos-latest] |
| 143 | + targets: |
| 144 | + - "//examples/basic:hello_component" |
| 145 | + - "//rust/..." |
| 146 | + - "//test/unit/..." |
| 147 | +``` |
| 148 | + |
| 149 | +### Buildkite CI (Comprehensive Lane) |
| 150 | +```yaml |
| 151 | +# Full matrix testing |
| 152 | +test_matrix: |
| 153 | + platform: [ubuntu2204, macos_arm64, windows] |
| 154 | + bazel_version: [minimum, current, rolling] |
| 155 | + configuration: [bzlmod, no_bzlmod, optimized, clippy] |
| 156 | + targets: ["//..."] |
| 157 | +``` |
| 158 | + |
| 159 | +## Status Reporting Integration |
| 160 | + |
| 161 | +### 1. GitHub Status Checks |
| 162 | + |
| 163 | +Configure Buildkite to report status back to GitHub: |
| 164 | + |
| 165 | +```yaml |
| 166 | +# In your Buildkite pipeline |
| 167 | +plugins: |
| 168 | + - seek-oss/github-commit-status#v2.0.0: |
| 169 | + context: "buildkite/rules-wasm-component" |
| 170 | +``` |
| 171 | + |
| 172 | +### 2. Slack/Teams Integration |
| 173 | + |
| 174 | +Optional: Add notifications for CI status: |
| 175 | + |
| 176 | +```yaml |
| 177 | +# Buildkite pipeline notification |
| 178 | +notify: |
| 179 | + - slack: "#engineering" |
| 180 | + if: build.state == "failed" |
| 181 | +``` |
| 182 | + |
| 183 | +## Caching Strategy |
| 184 | + |
| 185 | +### 1. Bazel Remote Cache |
| 186 | + |
| 187 | +Configure shared caching between GitHub Actions and Buildkite: |
| 188 | + |
| 189 | +```bash |
| 190 | +# .bazelrc additions for CI |
| 191 | +build:ci --remote_cache=https://your-cache-url |
| 192 | +build:ci --remote_timeout=10s |
| 193 | +build:ci --remote_accept_cached=true |
| 194 | +build:ci --remote_upload_local_results=true |
| 195 | +``` |
| 196 | + |
| 197 | +### 2. Rust Toolchain Cache |
| 198 | + |
| 199 | +Cache Rust installations across builds: |
| 200 | + |
| 201 | +```yaml |
| 202 | +# GitHub Actions caching |
| 203 | +- uses: actions/cache@v4 |
| 204 | + with: |
| 205 | + path: | |
| 206 | + ~/.cargo/registry |
| 207 | + ~/.cargo/git |
| 208 | + ~/.rustup |
| 209 | + key: ${{ runner.os }}-rust-${{ hashFiles('MODULE.bazel') }} |
| 210 | +``` |
| 211 | + |
| 212 | +## Debugging CI Failures |
| 213 | + |
| 214 | +### 1. Local Reproduction |
| 215 | + |
| 216 | +For Buildkite failures, reproduce locally: |
| 217 | + |
| 218 | +```bash |
| 219 | +# Use the exact same configuration |
| 220 | +export BAZEL_VERSION="7.4.1" # From failed job |
| 221 | +bazel test //... --platforms=//platforms:wasm32-wasi --config=wasm_component |
| 222 | +
|
| 223 | +# Check specific example |
| 224 | +bazel build //examples/basic:hello_component |
| 225 | +wasm-tools validate bazel-bin/examples/basic/hello_component.wasm |
| 226 | +``` |
| 227 | + |
| 228 | +### 2. Buildkite Logs |
| 229 | + |
| 230 | +Access detailed logs in Buildkite UI: |
| 231 | +- Build timeline view |
| 232 | +- Artifact downloads |
| 233 | +- Raw log outputs |
| 234 | +- Performance metrics |
| 235 | + |
| 236 | +### 3. GitHub Actions Comparison |
| 237 | + |
| 238 | +Compare with GitHub Actions results: |
| 239 | +- Same commit, different environment results |
| 240 | +- Platform-specific differences |
| 241 | +- Timing and resource usage variations |
| 242 | + |
| 243 | +## Migration Strategy |
| 244 | + |
| 245 | +### Phase 1: Parallel Testing |
| 246 | +- Keep existing GitHub Actions |
| 247 | +- Add Buildkite CI as additional testing |
| 248 | +- Monitor for inconsistencies |
| 249 | + |
| 250 | +### Phase 2: Gradual Migration |
| 251 | +- Move comprehensive tests to Buildkite |
| 252 | +- Keep fast feedback in GitHub Actions |
| 253 | +- Update branch protection rules |
| 254 | + |
| 255 | +### Phase 3: Optimization |
| 256 | +- Fine-tune test distribution |
| 257 | +- Optimize cache usage |
| 258 | +- Minimize redundant testing |
| 259 | + |
| 260 | +## Cost Optimization |
| 261 | + |
| 262 | +### 1. Selective Testing |
| 263 | +```yaml |
| 264 | +# Only run full matrix on main branch |
| 265 | +if: build.branch == "main" || build.pull_request.draft == false |
| 266 | +``` |
| 267 | + |
| 268 | +### 2. Resource Management |
| 269 | +```yaml |
| 270 | +# Use appropriate agent sizes |
| 271 | +agents: |
| 272 | + queue: "high-memory" # For resource-intensive jobs |
| 273 | + queue: "default" # For standard jobs |
| 274 | +``` |
| 275 | + |
| 276 | +### 3. Parallel Execution Limits |
| 277 | +```yaml |
| 278 | +# Prevent resource exhaustion |
| 279 | +parallelism: 3 # Limit concurrent jobs |
| 280 | +``` |
| 281 | + |
| 282 | +This integration provides comprehensive testing coverage while maintaining fast feedback loops for developers. |
0 commit comments