Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 71 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ on:
pull_request:
workflow_dispatch:

# packages: read lets jobs pull the base images CI runs from ghcr.io/docspring/mirror (private; .github/mirror.txt).
permissions:
contents: read
packages: read

concurrency:
group: ci-${{ github.ref }}
Expand Down Expand Up @@ -64,7 +66,10 @@ jobs:
timeout-minutes: 40
services:
postgres:
image: postgres:17
image: ghcr.io/docspring/mirror/postgres:17@sha256:97fb53376be3e4fb1a8a61421daa69dcc3bf2fa39bda3259f5245f9a455af1a9
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
POSTGRES_USER: visualci
POSTGRES_PASSWORD: visualci
Expand All @@ -73,10 +78,19 @@ jobs:
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v4
# Base images come from GHCR's copy of Docker Hub (.github/mirror.txt), pinned by digest, so a Docker Hub outage
# can't fail the job.
- uses: docker/login-action@v3
with:
registry: ghcr.io
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/mirror/rustfs:1.0.6@sha256:ee717072290bec9b11abfc0365f8310b00df1cd9b3639943edae47bdef05044a
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 rustfs/rustfs:1.0.6
-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
# 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.
Expand Down Expand Up @@ -177,7 +191,10 @@ jobs:
timeout-minutes: 30
services:
postgres:
image: postgres:17
image: ghcr.io/docspring/mirror/postgres:17@sha256:97fb53376be3e4fb1a8a61421daa69dcc3bf2fa39bda3259f5245f9a455af1a9
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
POSTGRES_USER: loco
POSTGRES_PASSWORD: loco
Expand All @@ -189,11 +206,20 @@ jobs:
with:
# As `visual` has it, so the site and docs build from the same history.
fetch-depth: 101
# Base images come from GHCR's copy of Docker Hub (.github/mirror.txt), pinned by digest, so a Docker Hub outage
# can't fail the job.
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
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/mirror/rustfs:1.0.6@sha256:ee717072290bec9b11abfc0365f8310b00df1cd9b3639943edae47bdef05044a
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 rustfs/rustfs:1.0.6
-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
# 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,
Expand Down Expand Up @@ -308,7 +334,10 @@ jobs:
timeout-minutes: 30
services:
postgres:
image: postgres:17
image: ghcr.io/docspring/mirror/postgres:17@sha256:97fb53376be3e4fb1a8a61421daa69dcc3bf2fa39bda3259f5245f9a455af1a9
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
POSTGRES_USER: loco
POSTGRES_PASSWORD: loco
Expand All @@ -325,9 +354,18 @@ jobs:
with:
fetch-depth: 101
- run: echo "127.0.0.1 visualci.test app.visualci.test api.visualci.test mcp.visualci.test github.test" | sudo tee -a /etc/hosts
# Base images come from GHCR's copy of Docker Hub (.github/mirror.txt), pinned by digest, so a Docker Hub outage
# can't fail the job.
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
image=ghcr.io/docspring/mirror/rustfs:1.0.6@sha256:ee717072290bec9b11abfc0365f8310b00df1cd9b3639943edae47bdef05044a
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 rustfs/rustfs:1.0.6
-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
- uses: kunobi-ninja/kache-action@061011817fd04b0e460f79d6bb3c115b1fc8f029 # v1
with:
Expand Down Expand Up @@ -358,8 +396,11 @@ jobs:
- uses: ./.github/actions/playwright
with:
save: ${{ github.ref == 'refs/heads/main' }}
- run: scripts/journeys/run.sh
- run: |
scripts/ci/pull.sh "$CADDY_IMAGE"
scripts/journeys/run.sh
env:
CADDY_IMAGE: ghcr.io/docspring/mirror/caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b
DATABASE_URL: postgres://loco:loco@127.0.0.1:55433/visualci_journeys
# The screenshots go up even when a journey failed: its last one shows where it stopped.
- if: ${{ !cancelled() }}
Expand Down Expand Up @@ -535,7 +576,12 @@ jobs:
release-bins:
runs-on: ${{ fromJSON(vars.CI_RUNNER || '"ubuntu-latest"') }}
environment: ${{ github.ref == 'refs/heads/main' && 'kache-write' || '' }}
container: rust:1.99.1-trixie
# The renderer's inputs hash (in `images`) greps this image line: keep it on one line.
container:
image: ghcr.io/docspring/mirror/rust:1.99.1-trixie@sha256:8a4e90c7946b74626488b1446f712c0fe0ed1a596cbd3d871684bc9c5433ae07
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -596,20 +642,27 @@ jobs:
name: release-bins
path: tmp/bin
- run: chmod +x tmp/bin/*
- uses: docker/setup-buildx-action@v3
- if: env.PUSH == 'true'
uses: docker/login-action@v3
# Logged in on pull requests too: BuildKit and the Dockerfiles' base images come from ghcr.io/docspring/mirror.
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
with:
driver-opts: image=ghcr.io/docspring/mirror/buildkit:buildx-stable-1@sha256:baf6138eb8c37644800c7c913fba051e840ebb9ba13eaf92d92ef9a1712d0b4c
# The app (app/), which serves the API, the web app, MCP and the site's pages on its hosts
- id: app
uses: docker/build-push-action@v6
with:
context: .
file: docker/app.Dockerfile
build-contexts: bin=tmp/bin
# The Dockerfiles' FROM images, from the mirror (the same digests as Docker Hub's; local builds use Docker Hub)
build-contexts: |
bin=tmp/bin
rust:1.99.1-trixie=docker-image://ghcr.io/docspring/mirror/rust:1.99.1-trixie@sha256:8a4e90c7946b74626488b1446f712c0fe0ed1a596cbd3d871684bc9c5433ae07
node:24-trixie-slim=docker-image://ghcr.io/docspring/mirror/node:24-trixie-slim@sha256:83079001d4ca6bf276035aa1c7b819b9542fc87a858a4fdc52ccc014bbf92143
debian:trixie-slim=docker-image://ghcr.io/docspring/mirror/debian:trixie-slim@sha256:8aa5a7bf5a1955bddbe7d74fcdd0b91ab30e74362a8b73af672b0481b35b44a0
push: ${{ env.PUSH == 'true' }}
build-args: |
BUILD_SHA=${{ github.sha }}
Expand All @@ -635,7 +688,7 @@ jobs:
deps=$(echo "$tree" | grep -v ' (/')
# shellcheck disable=SC2086
# The image release-bins compiles it in (its `container:`) is an input too.
hash=$( { git ls-files -s docker/renderer.Dockerfile docker/renderer.version rust-toolchain.toml $paths; grep -v '^version = ' Cargo.toml; echo "$deps"; grep -m1 'container: rust:' .github/workflows/ci.yml; } | sha256sum | cut -c1-24)
hash=$( { git ls-files -s docker/renderer.Dockerfile docker/renderer.version rust-toolchain.toml $paths; grep -v '^version = ' Cargo.toml; echo "$deps"; grep -m1 '^ *image: ghcr.io/docspring/mirror/rust:' .github/workflows/ci.yml; } | sha256sum | cut -c1-24)
echo "tag=ghcr.io/docspring/visualci-renderer:inputs-$hash" >>"$GITHUB_OUTPUT"
if digest=$(docker buildx imagetools inspect "ghcr.io/docspring/visualci-renderer:inputs-$hash" --format '{{json .Manifest}}' 2>/dev/null | python3 -c 'import json,sys; print(json.load(sys.stdin)["digest"])'); then
echo "existing=$digest" >>"$GITHUB_OUTPUT"
Expand All @@ -647,7 +700,11 @@ jobs:
with:
context: .
file: docker/renderer.Dockerfile
build-contexts: bin=tmp/bin
build-contexts: |
bin=tmp/bin
rust:1.99.1-trixie=docker-image://ghcr.io/docspring/mirror/rust:1.99.1-trixie@sha256:8a4e90c7946b74626488b1446f712c0fe0ed1a596cbd3d871684bc9c5433ae07
node:24-trixie-slim=docker-image://ghcr.io/docspring/mirror/node:24-trixie-slim@sha256:83079001d4ca6bf276035aa1c7b819b9542fc87a858a4fdc52ccc014bbf92143
debian:trixie-slim=docker-image://ghcr.io/docspring/mirror/debian:trixie-slim@sha256:8aa5a7bf5a1955bddbe7d74fcdd0b91ab30e74362a8b73af672b0481b35b44a0
push: ${{ env.PUSH == 'true' }}
build-args: RENDERER_VERSION=${{ steps.version.outputs.renderer }}
tags: |
Expand Down
12 changes: 12 additions & 0 deletions scripts/ci/pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Pulls each image given, retrying with backoff, so a registry hiccup doesn't fail the job. CI pulls its images from
# ghcr.io/docspring/mirror by digest (.github/mirror.txt); log in to ghcr.io first.
set -euo pipefail
for image in "$@"; do
for attempt in 1 2 3 4 5; do
docker pull -q "$image" && continue 2
[ "$attempt" = 5 ] || { echo "pulling $image failed (attempt $attempt); retrying in $((attempt * 10)) s" >&2; sleep $((attempt * 10)); }
done
echo "::error::could not pull $image" >&2
exit 1
done
4 changes: 2 additions & 2 deletions scripts/journeys/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ psql "${DATABASE_URL%/*}/postgres" -qc "CREATE DATABASE $db"

# The bucket, through the AWS CLI or its image
s3cmd=(aws)
command -v aws >/dev/null || s3cmd=(docker run --rm --network host -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION amazon/aws-cli)
command -v aws >/dev/null || s3cmd=(docker run --rm --network host -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION amazon/aws-cli:2.17.0)
AWS_ACCESS_KEY_ID=visualci AWS_SECRET_ACCESS_KEY=visualci-dev-secret AWS_DEFAULT_REGION=auto \
"${s3cmd[@]}" --endpoint-url "$s3" s3 mb "s3://$bucket" >/dev/null 2>&1 || true

Expand Down Expand Up @@ -142,7 +142,7 @@ app.visualci.test, api.visualci.test, mcp.visualci.test {
EOF
docker rm -f visualci-journeys-caddy >/dev/null 2>&1 || true
docker run -d --name visualci-journeys-caddy --network host \
-v "$run/Caddyfile:/etc/caddy/Caddyfile:ro" -v "$site:/site:ro" caddy:2 >/dev/null
-v "$run/Caddyfile:/etc/caddy/Caddyfile:ro" -v "$site:/site:ro" "${CADDY_IMAGE:-caddy:2.11.9}" >/dev/null

for _ in $(seq 1 60); do
curl -fsSk https://app.visualci.test/up >/dev/null 2>&1 && curl -fsSk https://visualci.test/ >/dev/null 2>&1 && break
Expand Down
Loading