~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/stream

jetstream v2 in zig · mirror of https://tangled.org/zat.dev/stream

0
0
62 lines · 2.6 KB Raw History
# .tangled/workflows/admission.yml — TRIGGER the gate; never run it here.
#
# This workflow used to run the whole 21-suite gate inside a microVM. It no
# longer does, for one reason: nothing stopped it from running concurrently
# with a gate started any other way. On 2026-08-09 two full gates ran on the
# same box at once (a microVM guest and a bare-metal run), pushing the worker
# cgroup past its memory.high 534,646 times and silently throttling both.
#
# The gate now has exactly one entry point: the `stream-admission` Prefect
# deployment, which carries concurrency_limit=1 (ENQUEUE). A second trigger
# queues behind the first instead of competing with it. Running the gate
# anywhere else re-opens the hole this closes.
#
# It also runs on bare metal there (32 cores, no VM tax): the lifecycle oracle
# took 2533s in the stock guest, 900s at 12 vCPU, ~420s native.
#
# Secrets (repo settings): PREFECT_API_URL, PREFECT_API_AUTH_STRING.

when:
  - event: ["push"]
    branch: ["main"]
  - event: ["manual"]

engine: nixery

dependencies:
  nixpkgs:
    - curl
    - coreutils
    - python3
    - openssl
    - jq

steps:
  - name: trigger the bare-metal gate
    command: |
      set -euo pipefail
      python3 scripts/test-ci-public-ca.py
      ca_dir=$(mktemp -d)
      trap 'rm -rf "$ca_dir"' EXIT
      python3 scripts/ci-public-ca.py "${SSL_CERT_FILE:-/etc/ssl/certs/ca-bundle.crt}" "$ca_dir/ca-certificates.crt"
      export SSL_CERT_FILE="$ca_dir/ca-certificates.crt" SSL_CERT_DIR="$ca_dir" CURL_CA_BUNDLE="$ca_dir/ca-certificates.crt"
      : "${PREFECT_API_URL:?add the PREFECT_API_URL repo secret}"
      : "${PREFECT_API_AUTH_STRING:?add the PREFECT_API_AUTH_STRING repo secret}"

      # create flow run FROM DEPLOYMENT: this is the endpoint that stamps the
      # work queue and sets state=Scheduled, which is what makes a worker pick
      # it up. POST /flow_runs/ would create an inert Pending run instead.
      auth=$(printf '%s' "$PREFECT_API_AUTH_STRING" | base64 -w0)
      deployment=$(curl --disable --proto '=https' -fsS \
        "$PREFECT_API_URL/deployments/name/stream-admission/stream-admission" \
        -H "Authorization: Basic $auth" | jq -er '.id')

      curl --disable --proto '=https' -fsS -X POST \
        "$PREFECT_API_URL/deployments/$deployment/create_flow_run" \
        -H "Authorization: Basic $auth" \
        -H 'Content-Type: application/json' \
        -d "{\"parameters\": {\"sha\": \"$TANGLED_COMMIT_SHA\", \"only\": [], \"skip\": [], \"build_image\": true},
             \"tags\": [\"spindle\", \"$TANGLED_COMMIT_SHA\"]}" \
        | head -c 400
      echo
      echo "queued; the gate is serialised by the deployment's concurrency limit"