From 687441b6f7884d973d0d2453b781712bd591f4a7 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 15:11:32 +0000 Subject: [PATCH] CI: RustFS on a free host port per job (scripts/ci/s3.sh), not a fixed 59000 that an earlier job's container can hold (sc-9611) Main's run 47533443138 failed in journeys: the s3 container couldn't bind 59000 (address already in use), so a container from an earlier job was still on the runner. s3.sh names the container per run, attempt and job, publishes 127.0.0.1::9000, looks the port up, and puts it in VISUALCI_S3_ENDPOINT and VISUALCI_APP_TEST_S3_ENDPOINT for the job's later steps, which already read them. --- .github/workflows/ci.yml | 21 +++------------------ scripts/ci/s3.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 18 deletions(-) create mode 100755 scripts/ci/s3.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36e50613..783e8574 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,12 +89,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # S3 storage for the blob tests: RustFS, as the visual-capture job uses. - - run: | - image=ghcr.io/docspring/visualci/mirror/rustfs:1.0.6@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 - scripts/ci/pull.sh "$image" - docker run -d --name s3 -p 59000:9000 \ - -e RUSTFS_ACCESS_KEY=visualci -e RUSTFS_SECRET_KEY=visualci-dev-secret "$image" - for _ in $(seq 1 30); do curl -s -o /dev/null http://127.0.0.1:59000/ && break; sleep 1; done + - run: scripts/ci/s3.sh # Trial (c) on this job: rust-cache restores target/ (incremental state and our own crates), with kache behind # it for dependency misses. Its key covers Cargo.lock and the toolchain; only main saves it, like kache. - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 @@ -259,12 +254,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} # S3 storage for the seeded blobs: RustFS (Apache-2.0), since MinIO's images are no longer public. A step rather # than a service, so the job doesn't wait on a health check the image doesn't define. - - run: | - image=ghcr.io/docspring/visualci/mirror/rustfs:1.0.6@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 - scripts/ci/pull.sh "$image" - docker run -d --name s3 -p 59000:9000 \ - -e RUSTFS_ACCESS_KEY=visualci -e RUSTFS_SECRET_KEY=visualci-dev-secret "$image" - for _ in $(seq 1 30); do curl -s -o /dev/null http://127.0.0.1:59000/ && break; sleep 1; done + - run: scripts/ci/s3.sh # Compile cache (kache, as Cargo's rustc wrapper): the R2 bucket every machine shares (KACHE_BUCKET), else the # GitHub Actions cache. Only main writes it: the read-write key is a secret of the kache-write environment, # which only main may use, so a pull request (whatever its ci.yml says) gets the read-only key. @@ -418,12 +408,7 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - run: | - image=ghcr.io/docspring/visualci/mirror/rustfs:1.0.6@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 - scripts/ci/pull.sh "$image" - docker run -d --name s3 -p 59000:9000 \ - -e RUSTFS_ACCESS_KEY=visualci -e RUSTFS_SECRET_KEY=visualci-dev-secret "$image" - for _ in $(seq 1 30); do curl -s -o /dev/null http://127.0.0.1:59000/ && break; sleep 1; done + - run: scripts/ci/s3.sh - uses: kunobi-ninja/kache-action@061011817fd04b0e460f79d6bb3c115b1fc8f029 # v1 with: version: "2.4.0" diff --git a/scripts/ci/s3.sh b/scripts/ci/s3.sh new file mode 100755 index 00000000..bc23122b --- /dev/null +++ b/scripts/ci/s3.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Starts RustFS for a CI job's blob store on a free host port, and points the job's later steps at it +# (VISUALCI_S3_ENDPOINT for scripts/ci/visual.sh and scripts/journeys/run.sh, VISUALCI_APP_TEST_S3_ENDPOINT for app's +# tests). Never a fixed port: a runner can keep an earlier job's container, and two jobs can share a host (5 Dec 2026, +# run 47533443138: "port 59000 ... address already in use"). Log in to ghcr.io first. +set -euo pipefail +image=ghcr.io/docspring/visualci/mirror/rustfs:1.0.6@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 +"$(dirname "$0")/pull.sh" "$image" +name="s3-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-1}-${GITHUB_JOB:-job}" +docker rm -f "$name" >/dev/null 2>&1 || true +docker run -d --rm --name "$name" -p 127.0.0.1::9000 \ + -e RUSTFS_ACCESS_KEY=visualci -e RUSTFS_SECRET_KEY=visualci-dev-secret "$image" >/dev/null +port=$(docker port "$name" 9000/tcp | head -1 | sed 's/.*://') +endpoint="http://127.0.0.1:$port" +for _ in $(seq 1 30); do curl -s -o /dev/null "$endpoint/" && break; sleep 1; done +curl -s -o /dev/null "$endpoint/" || { echo "::error::RustFS didn't answer on $endpoint"; docker logs "$name" | tail -20; exit 1; } +echo "RustFS ($name) on $endpoint" +if [ -n "${GITHUB_ENV:-}" ]; then + { echo "VISUALCI_S3_ENDPOINT=$endpoint"; echo "VISUALCI_APP_TEST_S3_ENDPOINT=$endpoint"; } >>"$GITHUB_ENV" +fi