:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ci): retry the rust toolchain install in rust ci (#121579)
Georges-Antoine Assi232662537082
diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.ymlnew file mode 100644index 000000000000..4390393a646d--- /dev/null+++ b/.github/actions/setup-rust/action.yml@@ -0,0 +1,84 @@+name: Setup Rust+description: |+ Installs a pinned Rust toolchain with rustup and retries the download.+ Runs the same rustup commands as dtolnay/rust-toolchain. That action does not retry,+ so one network error on static.rust-lang.org fails the job before any test runs.++inputs:+ toolchain:+ description: 'Rust toolchain to install (e.g. 1.91.1)'+ required: true+ components:+ description: 'Comma-separated list of components to install in addition to the minimal profile'+ required: false+ default: ''++runs:+ using: composite+ steps:+ - name: Install rustup if needed+ shell: bash+ env:+ RUSTUP_VERSION: 1.28.2+ run: |+ set -euo pipefail+ echo "CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}" >> "$GITHUB_ENV"+ if ! command -v rustup &>/dev/null; then+ case "$(uname -m)" in+ x86_64)+ target=x86_64-unknown-linux-gnu+ expected_sha256=20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c+ ;;+ aarch64)+ target=aarch64-unknown-linux-gnu+ expected_sha256=e3853c5a252fca15252d07cb23a1bdd9377a8c6f3efa01531109281ae47f841c+ ;;+ *)+ echo "::error::No pinned rustup-init checksum for $(uname -m)"+ exit 1+ ;;+ esac+ installer="$RUNNER_TEMP/rustup-init"+ curl --proto '=https' --tlsv1.2 -fsSL --retry 5 --retry-all-errors --retry-max-time 60 --connect-timeout 10 \+ "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${target}/rustup-init" -o "$installer"+ echo "${expected_sha256} $installer" | sha256sum -c -+ chmod +x "$installer"+ "$installer" --default-toolchain none -y+ echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> "$GITHUB_PATH"+ fi++ - name: rustup toolchain install ${{ inputs.toolchain }}+ shell: bash+ env:+ TOOLCHAIN: ${{ inputs.toolchain }}+ COMPONENTS: ${{ inputs.components }}+ RUSTUP_PERMIT_COPY_RENAME: 1+ run: |+ set -euo pipefail+ PATH="${CARGO_HOME:-$HOME/.cargo}/bin:$PATH"+ component_flags=()+ for c in ${COMPONENTS//,/ }; do+ component_flags+=(--component "$c")+ done+ for attempt in 1 2 3; do+ if rustup toolchain install "$TOOLCHAIN" "${component_flags[@]}" --profile minimal --no-self-update; then+ break+ fi+ if [ "$attempt" -eq 3 ]; then+ echo "::error::rustup could not install $TOOLCHAIN after 3 attempts"+ exit 1+ fi+ echo "::warning::rustup toolchain install failed (attempt $attempt of 3), retrying in $((attempt * 15))s"+ sleep $((attempt * 15))+ done+ rustup default "$TOOLCHAIN"++ - name: Set Cargo defaults+ shell: bash+ run: |+ if [ -z "${CARGO_INCREMENTAL+set}" ]; then+ echo CARGO_INCREMENTAL=0 >> "$GITHUB_ENV"+ fi+ if [ -z "${CARGO_TERM_COLOR+set}" ]; then+ echo CARGO_TERM_COLOR=always >> "$GITHUB_ENV"+ fidiff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.ymlindex eeba6430a09b..031bb3c21969 100644--- a/.github/workflows/ci-rust.yml+++ b/.github/workflows/ci-rust.yml@@ -79,6 +79,7 @@ jobs:- '.github/workflows/rust.yml'- '.github/workflows/rust-docker-build.yml'- '.github/actions/setup-protoc/**'+ - '.github/actions/setup-rust/**'- '.github/actions/setup-sccache/**'- 'posthog/management/commands/setup_test_environment.py'- 'posthog/migrations/**'@@ -118,11 +119,12 @@ jobs:proto/.github/rust-images.yml.github/actions/rust-compute-affected/+ .github/actions/setup-rust/sparse-checkout-cone-mode: falseclean: false- name: Install rust- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ uses: ./.github/actions/setup-rustwith:toolchain: 1.91.1@@ -300,6 +302,7 @@ jobs:rust/proto/.github/actions/setup-protoc/+ .github/actions/setup-rust/.github/actions/setup-sccache/sparse-checkout-cone-mode: falseclean: false@@ -318,7 +321,7 @@ jobs:uses: ./.github/actions/setup-protoc- name: Install rust- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ uses: ./.github/actions/setup-rustwith:toolchain: 1.91.1@@ -418,7 +421,7 @@ jobs:# please keep the tag version here in sync with rust-version in rust/*/Cargo.toml- name: Install rust- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ uses: ./.github/actions/setup-rustwith:toolchain: 1.91.1@@ -683,7 +686,7 @@ jobs:# please keep the tag version here in sync with rust-version in rust/*/Cargo.toml- name: Install rust- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ uses: ./.github/actions/setup-rustwith:toolchain: 1.91.1@@ -915,6 +918,7 @@ jobs:rust/proto/.github/actions/setup-protoc/+ .github/actions/setup-rust/.github/actions/setup-sccache/sparse-checkout-cone-mode: falseclean: false@@ -933,7 +937,7 @@ jobs:uses: ./.github/actions/setup-protoc- name: Install rust- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ uses: ./.github/actions/setup-rustwith:toolchain: 1.91.1components: clippy,rustfmtdiff --git a/rust/affected-services/determinator-rules.toml b/rust/affected-services/determinator-rules.tomlindex 431b76d5e832..4aa5b2df4192 100644--- a/rust/affected-services/determinator-rules.toml+++ b/rust/affected-services/determinator-rules.toml@@ -71,6 +71,7 @@ globs = ["../bin/download-mmdb","../.github/workflows/ci-rust.yml","../.github/actions/setup-protoc/**",+ "../.github/actions/setup-rust/**","../.github/actions/setup-sccache/**","../.github/actions/setup-sqlx-cli/**","../.github/actions/rust-compute-affected/**",