ci: consolidate rust + protoc install across workflows (#23700)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Nails
2026-04-29 13:39:02 -07:00
committed by GitHub
co-authored by Claude Opus 4.7
parent b3ead32d3c
commit c3ab5bec7d
8 changed files with 61 additions and 26 deletions
+9 -4
View File
@@ -725,11 +725,16 @@ jobs:
# Needed by setuptools-rust to build the bundled native gRPC extension
# (rust/sglang-grpc) when installing the main `sglang` wheel from source.
- name: Install protoc
run: sudo bash scripts/ci/utils/install_protoc.sh
- name: Install protoc + Rust toolchain
timeout-minutes: 10
run: bash scripts/ci/utils/install_rust_protoc.sh
- name: Install Rust toolchain
run: bash scripts/ci/utils/install_rustup.sh
- name: Rust cache (sglang-grpc)
uses: Swatinem/rust-cache@v2
with:
workspaces: rust/sglang-grpc
shared-key: "sglang-grpc-cpu"
save-if: ${{ matrix.partition == 0 }}
# uv pip targets a venv by default; setup-python has no venv — install into that interpreter (see UV_SYSTEM_PYTHON in https://docs.astral.sh/uv/guides/integration/github/)
- name: Install dependencies
+3 -5
View File
@@ -153,11 +153,9 @@ jobs:
# Needed by setuptools-rust to build the bundled native gRPC extension
# (rust/sglang-grpc) when installing the main `sglang` wheel from source.
- name: Install protoc
run: sudo bash scripts/ci/utils/install_protoc.sh
- name: Install Rust toolchain
run: bash scripts/ci/utils/install_rustup.sh
- name: Install protoc + Rust toolchain
timeout-minutes: 10
run: bash scripts/ci/utils/install_rust_protoc.sh
- name: Install dependencies
timeout-minutes: 20
+3
View File
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.90"
profile = "minimal"
+2 -5
View File
@@ -160,11 +160,8 @@ clean_site_packages() {
set -x
fi
# Install protoc
bash "${SCRIPT_DIR}/../utils/install_protoc.sh"
# Install Rust toolchain (needed by setuptools-rust, e.g. the native gRPC extension)
bash "${SCRIPT_DIR}/../utils/install_rustup.sh"
# Install protoc + Rust toolchain (needed by setuptools-rust, e.g. the native gRPC extension)
bash "${SCRIPT_DIR}/../utils/install_rust_protoc.sh"
export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}"
mark_step_done "${FUNCNAME[0]}"
@@ -1,24 +1,28 @@
#!/bin/bash
# Install dependencies for the sgl-model-gateway CI jobs.
#
# Gateway-specific apt deps are installed here; protoc and the Rust toolchain
# are delegated to the shared installer (the toolchain version is pinned by
# sgl-model-gateway/rust-toolchain.toml, picked up automatically on first
# `cargo` invocation).
set -euxo pipefail
# Check if sudo is available
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GATEWAY_APT_PACKAGES=(libssl-dev pkg-config redis-server)
if command -v sudo >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config protobuf-compiler redis-server
sudo apt-get install -y "${GATEWAY_APT_PACKAGES[@]}"
else
apt-get update
apt-get install -y libssl-dev pkg-config protobuf-compiler redis-server
apt-get install -y "${GATEWAY_APT_PACKAGES[@]}"
fi
# Install rustup (Rust installer and version manager)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.90
bash "${SCRIPT_DIR}/../utils/install_rust_protoc.sh"
# Follow the installation prompts, then reload your shell
# Make cargo/rustc/protoc visible in this shell.
. "$HOME/.cargo/env"
source $HOME/.cargo/env
# Verify installation
rustc --version
cargo --version
protoc --version
+3 -3
View File
@@ -18,7 +18,7 @@ ARCH=$(uname -m)
if command -v apt-get &> /dev/null; then
# Ubuntu/Debian
apt-get update || true # May fail due to unrelated broken packages
PROTOC_APT_PACKAGES=(wget unzip gcc g++ perl make)
PROTOC_APT_PACKAGES=(wget unzip)
apt-get install -y --no-install-recommends "${PROTOC_APT_PACKAGES[@]}" || {
echo "Warning: apt-get install failed, checking if required packages are available..."
for pkg in "${PROTOC_APT_PACKAGES[@]}"; do
@@ -32,9 +32,9 @@ if command -v apt-get &> /dev/null; then
elif command -v yum &> /dev/null; then
# RHEL/CentOS
yum update -y
yum install -y wget unzip gcc gcc-c++ perl-core make
yum install -y wget unzip
else
echo "ERROR: Neither apt-get nor yum found; cannot install protoc build deps"
echo "ERROR: Neither apt-get nor yum found; cannot install protoc"
exit 1
fi
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# Install protoc and a Rust toolchain (rustup/cargo). Required by setuptools-rust
# to build the bundled native gRPC extension (rust/sglang-grpc) when installing
# the main `sglang` wheel from source. Idempotent — both helpers no-op if
# already installed.
#
# protoc installs system-wide (/usr/local) and apt deps, so it needs root.
# rustup installs per-user under $HOME/.cargo, so it must run as the calling
# user (running it under sudo would put cargo in /root/.cargo and the rest of
# the job wouldn't find it).
set -euxo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$(id -u)" = "0" ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi
${SUDO} bash "${SCRIPT_DIR}/install_protoc.sh"
bash "${SCRIPT_DIR}/install_rustup.sh"
+4
View File
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.90"
profile = "minimal"
components = ["clippy"]