|
| 1 | +name: Rust Foundation Heavy Gate |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, reopened, ready_for_review] |
| 6 | + branches: [main] |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + ref: |
| 12 | + description: "Branch, tag, or SHA to test. Defaults to the selected ref." |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +env: |
| 20 | + PYTHON_VERSION: "3.11" |
| 21 | + RUST_KERNEL_MODE: required |
| 22 | + |
| 23 | +jobs: |
| 24 | + rust-wheel: |
| 25 | + name: rust-wheel |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + wheel-name: ${{ steps.wheel.outputs.name }} |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + ref: ${{ github.event.inputs.ref || github.ref }} |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: ${{ env.PYTHON_VERSION }} |
| 39 | + cache: pip |
| 40 | + |
| 41 | + - name: Install Rust toolchain |
| 42 | + run: rustup toolchain install stable --profile minimal |
| 43 | + |
| 44 | + - name: Install maturin |
| 45 | + run: python -m pip install "maturin>=1.13,<2" |
| 46 | + |
| 47 | + - name: Check Rust formatting |
| 48 | + run: cargo fmt --manifest-path crates/voscript_core/Cargo.toml -- --check |
| 49 | + |
| 50 | + - name: Run Rust clippy |
| 51 | + run: cargo clippy --manifest-path crates/voscript_core/Cargo.toml --all-targets -- -D warnings |
| 52 | + |
| 53 | + - name: Run Rust tests |
| 54 | + run: cargo test --manifest-path crates/voscript_core/Cargo.toml |
| 55 | + |
| 56 | + - name: Build Rust wheel |
| 57 | + run: python -m maturin build --release --manifest-path crates/voscript_core/Cargo.toml --features extension-module --out dist |
| 58 | + |
| 59 | + - name: Verify wheel artifact |
| 60 | + id: wheel |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + wheel_count="$(find dist -maxdepth 1 -name 'voscript_core-*.whl' | wc -l | tr -d ' ')" |
| 64 | + if [ "$wheel_count" != "1" ]; then |
| 65 | + echo "Expected exactly one voscript_core wheel, found $wheel_count" >&2 |
| 66 | + find dist -maxdepth 1 -type f >&2 |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + wheel_path="$(find dist -maxdepth 1 -name 'voscript_core-*.whl' -print -quit)" |
| 70 | + echo "name=$(basename "$wheel_path")" >> "$GITHUB_OUTPUT" |
| 71 | +
|
| 72 | + - name: Upload internal wheel artifact |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: voscript-core-wheel |
| 76 | + path: dist/voscript_core-*.whl |
| 77 | + if-no-files-found: error |
| 78 | + retention-days: 1 |
| 79 | + |
| 80 | + docker-packaging: |
| 81 | + name: docker-packaging |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: rust-wheel |
| 84 | + steps: |
| 85 | + - name: Checkout repository |
| 86 | + uses: actions/checkout@v4 |
| 87 | + with: |
| 88 | + ref: ${{ github.event.inputs.ref || github.ref }} |
| 89 | + |
| 90 | + - name: Download internal wheel artifact |
| 91 | + uses: actions/download-artifact@v4 |
| 92 | + with: |
| 93 | + name: voscript-core-wheel |
| 94 | + path: app/.wheelhouse |
| 95 | + |
| 96 | + - name: Verify downloaded wheel |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + test -f "app/.wheelhouse/${{ needs.rust-wheel.outputs.wheel-name }}" |
| 100 | +
|
| 101 | + - name: Build Docker image with Rust extension |
| 102 | + run: | |
| 103 | + docker build ./app \ |
| 104 | + --build-arg "VOSCRIPT_CORE_WHEEL=${{ needs.rust-wheel.outputs.wheel-name }}" \ |
| 105 | + -t voscript-rust-foundation:${{ github.sha }} |
| 106 | +
|
| 107 | + - name: Run container extension smoke |
| 108 | + run: | |
| 109 | + docker run --rm \ |
| 110 | + -e RUST_KERNEL_MODE=required \ |
| 111 | + voscript-rust-foundation:${{ github.sha }} \ |
| 112 | + python -c "from providers.kernel_bridge import core_smoke; result = core_smoke({'source': 'ci'}); assert result['ok'] is True; assert result['echoed']['source'] == 'ci'" |
| 113 | +
|
| 114 | + - name: Run health check smoke |
| 115 | + run: | |
| 116 | + set -euo pipefail |
| 117 | + cid="$(docker run -d -e DEVICE=cpu -e ALLOW_NO_AUTH=1 voscript-rust-foundation:${{ github.sha }})" |
| 118 | + trap 'docker logs "$cid" || true; docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT |
| 119 | + for _ in $(seq 1 60); do |
| 120 | + if docker exec "$cid" python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8780/healthz', timeout=2).read()" >/dev/null 2>&1; then |
| 121 | + exit 0 |
| 122 | + fi |
| 123 | + sleep 2 |
| 124 | + done |
| 125 | + echo "Container did not pass /healthz smoke in time" >&2 |
| 126 | + exit 1 |
0 commit comments