diff --git a/.agents/skills/watch-github-actions/SKILL.md b/.agents/skills/watch-github-actions/SKILL.md index 4b03fb5b32..cc5ef99097 100644 --- a/.agents/skills/watch-github-actions/SKILL.md +++ b/.agents/skills/watch-github-actions/SKILL.md @@ -131,11 +131,36 @@ gh run list --json databaseId,status,headBranch,url --jq '.[] | {id: .databaseId `Release Dev` finishes its active run and replaces pending runs when new commits arrive. Other callers retain E2E cancellation. Inspect job annotations for cancellation reasons. -## View Job Logs - -For Branch Checks `Reviewer Roster` failures, the log lists non-collaborators in -`REVIEWERS.md`. Remove those entries or arrange repository access before rerunning. -Lookup errors fail the check rather than treating missing results as eligibility. +## GKE runners + +Trusted Branch Checks Linux jobs use only `openshell-ci-amd64` and +`openshell-ci-arm64`. Fork PRs, ARM Python, and macOS use hosted runners. +AMD64 runs on C4 Ubuntu; ARM64 runs natively on C4A Ubuntu. Each public label +is shared by internal singleton cache slots, with five warm/twenty maximum +AMD64 workers and three warm/four maximum ARM64 workers. Slot names in job +logs are internal identities, not labels to hardcode in workflows. + +Every slot owns an exclusive 200 GiB Hyperdisk mounted at `/mnt/ci-cache`. +Setup separates targets by repository, Nix shell, job, and matrix variant, +reports initial size/slot name, and skips GitHub Cargo archive caches. Claims +survive pod replacement and node scaling. Different runs may use different +slots, so compare actual cache size and shared memcached sccache statistics +before attributing changes to hardware. There is no automatic target pruning; +monitor disk usage. Pending replacement pods can be waiting for exclusive disk +release; inspect PVC/PV events before diagnosing registration failure. + +Check Docker sidecar logs for job-container or PostgreSQL startup failures. +A missing `gh` or `$USER must be set` indicates runner-image/bootstrap drift. +Preloaded Nix runners verify the global Cachix substituter and skip re-adding it. +Separate sccache backend failures from compiler/test failures. AMD64 tests +set `CARGO_PROFILE_TEST_DEBUG=0`; debug assertions remain enabled. ARM crypto +checks run in lint while workspace tests run separately. Gateway core features +retain both parallel matrix jobs and all four independent feature checks. + +Manual `local_image_builds` runs build AMD64 gateway/sandbox/supervisor images +and smoke-test `--help` with pushing disabled. They use production auditable +Nix GNU/musl release commands, verify glibc/static linkage, and load images only +into ephemeral Docker. They do not qualify ARM images or publish artifacts. For Kubernetes app-listener E2E failures during kind setup, inspect the uploaded `results/app-listener/cni-setup/` evidence. It includes node and Calico pod diff --git a/.github/actionlint.yml b/.github/actionlint.yml index 31c5f55713..e4548f4707 100644 --- a/.github/actionlint.yml +++ b/.github/actionlint.yml @@ -3,6 +3,8 @@ self-hosted-runner: labels: + - openshell-ci-amd64 + - openshell-ci-arm64 - ubuntu-26.04 - windows-arm64 diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml index 0ae11edfe9..431ef22037 100644 --- a/.github/actions/setup-nix/action.yml +++ b/.github/actions/setup-nix/action.yml @@ -32,9 +32,17 @@ runs: extra-conf: | http2 = false + - name: Verify GKE image cache configuration + if: ${{ (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + shell: bash + run: | + nix config show --json | jq -e '.substituters.value | index("https://openshell.cachix.org") != null' > /dev/null + - uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17 with: name: openshell + # The image configures the substituter globally before dropping to runner. + skipAddingSubstituter: ${{ (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} authToken: ${{ inputs.cachix-auth-token }} skipPush: ${{ inputs.cachix-auth-token == '' }} diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml index 10e76ed63c..3ff4958f4c 100644 --- a/.github/actions/setup-rust/action.yml +++ b/.github/actions/setup-rust/action.yml @@ -8,10 +8,18 @@ inputs: cache-key: description: Rust target cache namespace required: true + cache-variant: + description: Separate persistent targets for matrix variants within one job + required: false + default: "" save-cache: description: Whether this job writes the Rust target cache required: false default: "false" + cache-workspace-crates: + description: Retain workspace build artifacts as well as dependencies + required: false + default: "false" outputs: cache-hit: @@ -21,6 +29,19 @@ outputs: runs: using: composite steps: + - name: Configure shared sccache on GKE runners + if: ${{ runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + shell: nix develop -c bash -euo pipefail {0} + run: | + mise install --locked github:mozilla/sccache + sccache_bin=$(mise which sccache) + dirname "$sccache_bin" >> "$GITHUB_PATH" + { + echo "RUSTC_WRAPPER=$sccache_bin" + echo "SCCACHE_MEMCACHED_ENDPOINT=tcp://memcached.sccache:11211" + echo "SCCACHE_BASEDIRS=$GITHUB_WORKSPACE" + } >> "$GITHUB_ENV" + - name: Hash Nix development shell id: dev-shell shell: bash @@ -28,7 +49,43 @@ runs: shell_drv=$(nix eval --raw --impure .#devShells --apply 'shells: shells.${builtins.currentSystem}.default.drvPath') echo "hash=$(nix hash file --type sha256 --base16 "$shell_drv")" >> "$GITHUB_OUTPUT" + - name: Configure persistent Cargo target directory + id: persistent-cache + shell: bash + env: + NIX_SHELL_HASH: ${{ steps.dev-shell.outputs.hash }} + CACHE_VARIANT: ${{ inputs.cache-variant }} + run: | + set -euo pipefail + # Pod environment is visible to the shell, not the workflow env context. + if [[ -z "${OPENSHELL_PERSISTENT_CACHE:-}" ]]; then + exit 0 + fi + echo "enabled=true" >> "$GITHUB_OUTPUT" + test "$GITHUB_REPOSITORY" = ai-openshell/openshell + test "$OPENSHELL_PERSISTENT_CACHE" = /mnt/ci-cache + mountpoint -q "$OPENSHELL_PERSISTENT_CACHE" + # A slot can run any job. Keep incompatible job/matrix targets separate, + # independent of branch/run IDs so later runs can reuse their artifacts. + cache_namespace="$GITHUB_JOB${CACHE_VARIANT:+-$CACHE_VARIANT}" + [[ "$cache_namespace" =~ ^[a-zA-Z0-9_-]+$ ]] + [[ "$NIX_SHELL_HASH" =~ ^[a-f0-9]{64}$ ]] + cache_root="$OPENSHELL_PERSISTENT_CACHE/ai-openshell-openshell/$NIX_SHELL_HASH/$cache_namespace" + # Keep no-debug artifacts separate from targets with debug information. + if [[ "${CARGO_PROFILE_TEST_DEBUG:-}" == "0" ]]; then + cache_root="$cache_root/test-debug0" + fi + mkdir -p "$cache_root/target" + echo "CARGO_TARGET_DIR=$cache_root/target" >> "$GITHUB_ENV" + echo "Persistent cache slot: $OPENSHELL_CACHE_SLOT" + echo "Cache namespace: $cache_namespace" + echo "Runner pod: $RUNNER_NAME" + echo "Target directory: $cache_root/target" + du -sh "$cache_root/target" + df -h "$cache_root/target" + - name: Cache Rust target and registry + if: ${{ steps.persistent-cache.outputs.enabled != 'true' }} id: cache uses: Swatinem/rust-cache@6a7bc3ebce750e0a16a430dd57485acfdb38b05f with: @@ -36,4 +93,5 @@ runs: save-if: ${{ inputs.save-cache }} cache-on-failure: ${{ inputs.save-cache }} cache-bin: "false" + cache-workspace-crates: ${{ inputs.cache-workspace-crates }} cmd-format: nix develop -c {0} diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 5505a1fa1b..5a63c95142 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -5,6 +5,11 @@ on: types: [checks_requested] pull_request: workflow_dispatch: + inputs: + local_image_builds: + description: Build and smoke-test native AMD64 images locally without publishing + type: boolean + default: false env: CARGO_TERM_COLOR: always @@ -22,7 +27,7 @@ concurrency: jobs: reviewer-roster: name: Reviewer Roster - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -59,7 +64,7 @@ jobs: ${{ !cancelled() && github.event_name == 'pull_request' && needs.compatibility-review.outputs.has_findings == 'true' && needs.compatibility-review.outputs.report_artifact != '' }} - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 5 continue-on-error: true permissions: @@ -98,7 +103,7 @@ jobs: protobuf-compatibility: name: Protobuf Compatibility - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -116,7 +121,7 @@ jobs: monitoring-changes: name: Detect monitoring mixin changes - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 5 outputs: changed: ${{ steps.changes.outputs.changed }} @@ -153,7 +158,7 @@ jobs: name: Monitoring Mixin needs: monitoring-changes if: needs.monitoring-changes.outputs.changed == 'true' - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 15 container: image: ghcr.io/ai-openshell/openshell/ci:82e753ba3ffdfb40c118e7cb416ced7f350381d5@sha256:d816f3b4b2de675928e2ecfd26ec6b937be35fe9986542c87d440bc3de5a29de @@ -174,7 +179,7 @@ jobs: mise-lockfile: name: mise Lockfile - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 container: image: ghcr.io/ai-openshell/openshell/ci:82e753ba3ffdfb40c118e7cb416ced7f350381d5@sha256:d816f3b4b2de675928e2ecfd26ec6b937be35fe9986542c87d440bc3de5a29de @@ -197,7 +202,7 @@ jobs: license-headers: name: License Headers - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 container: image: ghcr.io/ai-openshell/openshell/ci:82e753ba3ffdfb40c118e7cb416ced7f350381d5@sha256:d816f3b4b2de675928e2ecfd26ec6b937be35fe9986542c87d440bc3de5a29de @@ -215,7 +220,7 @@ jobs: cargo-deny: name: Cargo Deny - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 defaults: run: @@ -243,7 +248,7 @@ jobs: rust-format: name: Rust format - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -272,7 +277,7 @@ jobs: cargo-lockfiles: name: Cargo lockfiles - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -294,9 +299,9 @@ jobs: fail-fast: false matrix: include: - - runner: ubuntu-24.04 + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} system: x86_64-linux - - runner: ubuntu-24.04-arm + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-arm64' || 'ubuntu-24.04-arm' }} system: aarch64-linux - runner: macos-15-xlarge system: aarch64-darwin @@ -332,21 +337,81 @@ jobs: cargo clippy --locked --manifest-path tests/suites/features/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/support/Cargo.toml --all-targets -- -D warnings + # Balance ARM crypto checks against the parallel workspace test job. + - name: Verify crypto backend independence + if: matrix.runner == 'openshell-ci-arm64' + shell: nix develop -c bash -euo pipefail {0} + run: | + cargo tree --locked -p openshell-crypto --no-default-features --edges normal,build,dev --target all --prefix none > /tmp/openshell-crypto-dependencies.txt + if grep -Eq '^(ring|aws-lc-rs|aws-lc-sys|aws-lc-fips-sys) v' /tmp/openshell-crypto-dependencies.txt; then + echo "ERROR: backend-free crypto build includes Ring or AWS-LC" >&2 + cat /tmp/openshell-crypto-dependencies.txt >&2 + exit 1 + fi + cargo test --locked -p openshell-crypto --no-default-features --test independent_backend + + - name: Verify OpenSSL backend + if: matrix.runner == 'openshell-ci-arm64' + shell: nix develop .#crypto -c bash -euo pipefail {0} + env: + OPENSSL_NO_VENDOR: "1" + OPENSSL_STATIC: "0" + run: | + cargo tree --locked -p openshell-crypto --no-default-features --features openssl --edges normal,build,dev --target all --prefix none > /tmp/openshell-openssl-dependencies.txt + if grep -Eq '^(ring|aws-lc-rs|aws-lc-sys|aws-lc-fips-sys|openssl-src) v' /tmp/openshell-openssl-dependencies.txt; then + echo "ERROR: OpenSSL-only crypto build includes another backend or vendored OpenSSL" >&2 + cat /tmp/openshell-openssl-dependencies.txt >&2 + exit 1 + fi + cargo clippy --locked -p openshell-crypto --no-default-features --features openssl --all-targets -- -D warnings + cargo test --locked -p openshell-crypto --no-default-features --features openssl + for feature in tls-tonic tls-kube tls-sqlx; do + cargo check --locked -p openshell-crypto --no-default-features --features "openssl,$feature" + done + cargo clippy --locked -p openshell-crypto --features openssl --all-targets -- -D warnings + cargo test --locked -p openshell-crypto --features openssl + + - name: Verify dynamic OpenSSL linkage on Linux + if: runner.os == 'Linux' && matrix.runner == 'openshell-ci-arm64' + shell: nix develop .#crypto -c bash -euo pipefail {0} + env: + OPENSSL_NO_VENDOR: "1" + OPENSSL_STATIC: "0" + run: | + cargo test --locked -p openshell-crypto --no-default-features --features openssl --test openssl_tls --no-run --message-format=json > "$RUNNER_TEMP/openssl-artifacts.jsonl" + executable=$(uv run --no-project python -c 'import json, sys; artifacts = [json.loads(line) for line in sys.stdin]; paths = [a["executable"] for a in artifacts if a.get("reason") == "compiler-artifact" and a.get("target", {}).get("name") == "openssl_tls" and a.get("executable")]; assert len(paths) == 1, paths; print(paths[0])' < "$RUNNER_TEMP/openssl-artifacts.jsonl") + ldd "$executable" > "$RUNNER_TEMP/openssl-linkage.txt" + cat "$RUNNER_TEMP/openssl-linkage.txt" + for library in libssl libcrypto; do + if ! grep -Eq "^[[:space:]]*$library\\.so[^[:space:]]* => /" "$RUNNER_TEMP/openssl-linkage.txt"; then + echo "ERROR: $library did not resolve to a dynamic library" >&2 + exit 1 + fi + done + + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + rust-test: name: Rust test (${{ matrix.system }}) strategy: fail-fast: false matrix: include: - - runner: ubuntu-24.04 + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} system: x86_64-linux - - runner: ubuntu-24.04-arm + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-arm64' || 'ubuntu-24.04-arm' }} system: aarch64-linux - runner: macos-15-xlarge system: aarch64-darwin runs-on: ${{ matrix.runner }} timeout-minutes: 45 steps: + - name: Disable test debug information on AMD64 + if: matrix.runner == 'openshell-ci-amd64' + run: echo "CARGO_PROFILE_TEST_DEBUG=0" >> "$GITHUB_ENV" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: ./.github/actions/setup-nix @@ -360,6 +425,7 @@ jobs: save-cache: "true" - name: Verify crypto backend independence + if: matrix.runner != 'openshell-ci-arm64' shell: nix develop -c bash -euo pipefail {0} run: | cargo tree --locked -p openshell-crypto --no-default-features --edges normal,build,dev --target all --prefix none > /tmp/openshell-crypto-dependencies.txt @@ -371,6 +437,7 @@ jobs: cargo test --locked -p openshell-crypto --no-default-features --test independent_backend - name: Verify OpenSSL backend + if: matrix.runner != 'openshell-ci-arm64' shell: nix develop .#crypto -c bash -euo pipefail {0} env: OPENSSL_NO_VENDOR: "1" @@ -391,7 +458,7 @@ jobs: cargo test --locked -p openshell-crypto --features openssl - name: Verify dynamic OpenSSL linkage on Linux - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.runner != 'openshell-ci-arm64' shell: nix develop .#crypto -c bash -euo pipefail {0} env: OPENSSL_NO_VENDOR: "1" @@ -421,11 +488,77 @@ jobs: cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path tests/support/Cargo.toml tasks/scripts/check-conformance-program.sh + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + + local-image-builds: + name: Local image builds (amd64, no push) + if: github.event_name == 'workflow_dispatch' && inputs.local_image_builds && github.repository == 'ai-openshell/openshell' + runs-on: openshell-ci-amd64 + timeout-minutes: 90 + env: + CONTAINER_ENGINE: docker + DOCKER_PLATFORM: linux/amd64 + DOCKER_PUSH: "0" + DOCKER_OUTPUT: type=docker + DOCKER_BUILDER: openshell-local-images + IMAGE_REGISTRY: localhost/openshell-ci + IMAGE_TAG: ${{ github.sha }} + PREBUILT_ARCH: amd64 + PREBUILT_AUTO_STAGE: "0" + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ./.github/actions/setup-nix + with: + prepare-shell: "true" + - uses: ./.github/actions/setup-rust + with: + cache-key: local-image-builds + save-cache: "false" + - name: Stage real release binaries + shell: nix develop -c bash -euo pipefail {0} + run: | + # Match build-rust-binary's Nix release toolchain. The local Zig + # staging task mixes libc++ objects with Nix's GNU final linker. + for component in gateway sandbox supervisor; do + target=x86_64-unknown-linux-gnu + if [[ "$component" == sandbox ]]; then + target=x86_64-unknown-linux-musl + fi + binary="openshell-$component" + env -u RUSTC_WRAPPER cargo auditable build --locked --release \ + --target "$target" --package "$binary" --bin "$binary" + artifact="target/$target/release/$binary" + if [[ "$component" == sandbox ]]; then + tasks/scripts/verify-static-binary.sh "$artifact" + else + tasks/scripts/verify-glibc-symbols.sh 2.28 "$artifact" + fi + install -Dm0755 "$artifact" "deploy/docker/.build/prebuilt-binaries/amd64/$binary" + done + - name: Build and verify local images + shell: nix develop -c bash -euo pipefail {0} + run: | + docker buildx create --name "$DOCKER_BUILDER" --driver remote "$BUILDKIT_HOST" + trap 'docker buildx rm "$DOCKER_BUILDER"' EXIT + for component in gateway sandbox supervisor; do + mise run --skip-tools "docker:build:$component" + image="$IMAGE_REGISTRY/$component:$IMAGE_TAG" + test "$(docker image inspect --format '{{.Architecture}}' "$image")" = amd64 + docker run --rm --network none "$image" --help + done + - name: Shared sccache statistics + if: always() && env.RUSTC_WRAPPER != '' + run: sccache --show-stats + rust-postgres-test: name: Rust PostgreSQL tests # Bare runner: the test script starts a disposable PostgreSQL container # with the host's Docker. - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -449,15 +582,19 @@ jobs: OPENSHELL_TELEMETRY_ENABLED: "false" run: tasks/scripts/run-postgres-tests.sh --locked --profile ci + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + rust-build-modes: name: Rust build modes (${{ matrix.system }}) strategy: fail-fast: false matrix: include: - - runner: ubuntu-24.04 + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} system: x86_64-linux - - runner: ubuntu-24.04-arm + - runner: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-arm64' || 'ubuntu-24.04-arm' }} system: aarch64-linux - runner: macos-15-xlarge system: aarch64-darwin @@ -479,12 +616,13 @@ jobs: - name: Verify build modes shell: nix develop -c bash -euo pipefail {0} run: | + target_dir="${CARGO_TARGET_DIR:-target}" cargo build --locked -p openshell-gateway --bin openshell-gateway - tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway + tasks/scripts/verify-telemetry-compiled-out.sh present "$target_dir/debug/openshell-gateway" cargo build --locked -p openshell-gateway --bin openshell-gateway --no-default-features --features defaults-without-telemetry - tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway + tasks/scripts/verify-telemetry-compiled-out.sh absent "$target_dir/debug/openshell-gateway" cargo build --locked -p openshell-supervisor --bin openshell-supervisor --no-default-features --features defaults-without-telemetry - tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-supervisor + tasks/scripts/verify-telemetry-compiled-out.sh absent "$target_dir/debug/openshell-supervisor" cargo check --locked -p openshell-supervisor --all-targets --no-default-features --features system-ca-roots - name: Verify system CA roots dependency boundary @@ -507,9 +645,13 @@ jobs: exit 1 fi + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + rust-feature-alias: name: Rust feature alias - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -530,9 +672,19 @@ jobs: tasks/scripts/verify-defaults-without-telemetry.sh git diff --exit-code HEAD -- ':(glob)**/Cargo.lock' + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + rust-gateway-core-features: - name: Rust gateway core features - runs-on: ubuntu-24.04 + name: Rust gateway core features (${{ matrix.lane }}) + strategy: + fail-fast: false + matrix: + include: + - lane: base-kubernetes + - lane: docker-podman + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -545,19 +697,36 @@ jobs: - uses: ./.github/actions/setup-rust with: cache-key: rust-checks-v2 + cache-variant: ${{ matrix.lane }} save-cache: "false" - - name: Verify core gateway compute-driver feature sets + - name: Test gateway without optional drivers + if: matrix.lane == 'base-kubernetes' shell: nix develop -c bash -euo pipefail {0} - run: | - cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features - cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-docker - cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-kubernetes - cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-podman + run: cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features + + - name: Test Kubernetes-only gateway + if: matrix.lane == 'base-kubernetes' + shell: nix develop -c bash -euo pipefail {0} + run: cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-kubernetes + + - name: Test Docker-only gateway + if: matrix.lane == 'docker-podman' + shell: nix develop -c bash -euo pipefail {0} + run: cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-docker + + - name: Test Podman-only gateway + if: matrix.lane == 'docker-podman' + shell: nix develop -c bash -euo pipefail {0} + run: cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-podman + + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats rust-gateway-extended-features: name: Rust gateway extended features - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -579,12 +748,18 @@ jobs: cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-mxc cargo nextest run --locked --profile ci -p openshell-gateway --all-targets --no-default-features --features compute-driver-docker,compute-driver-vm + - name: Shared sccache statistics + if: ${{ always() && env.RUSTC_WRAPPER != '' && runner.environment == 'self-hosted' && (startsWith(runner.name, 'openshell-ci-amd64-') || startsWith(runner.name, 'openshell-ci-arm64-')) }} + run: sccache --show-stats + python: name: Python (${{ matrix.runner }}) strategy: fail-fast: false matrix: - runner: [ubuntu-24.04, ubuntu-24.04-arm] + runner: + - ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} + - ubuntu-24.04-arm runs-on: ${{ matrix.runner }} timeout-minutes: 30 container: @@ -635,7 +810,7 @@ jobs: # Merge queue runs skip this job; the PR already passed it. name: Python SDK Freeze if: github.event_name == 'pull_request' - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -662,7 +837,7 @@ jobs: markdown: name: Markdown - runs-on: ubuntu-24.04 + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-24.04' }} timeout-minutes: 30 container: image: ghcr.io/ai-openshell/openshell/ci:82e753ba3ffdfb40c118e7cb416ced7f350381d5@sha256:d816f3b4b2de675928e2ecfd26ec6b937be35fe9986542c87d440bc3de5a29de @@ -681,7 +856,7 @@ jobs: typescript-sdk-freeze: name: TypeScript SDK Freeze if: github.event_name == 'pull_request' - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -714,7 +889,7 @@ jobs: install-script: name: install.sh - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'ai-openshell/openshell' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'openshell-ci-amd64' || 'ubuntu-latest' }} timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/CI.md b/CI.md index cab896eefd..eb048bb6ee 100644 --- a/CI.md +++ b/CI.md @@ -6,7 +6,70 @@ For local test commands see [TESTING.md](TESTING.md). For PR conventions see [CO ## Overview -PR CI runs on standard GitHub-hosted runners. `Branch Checks` and `Helm Lint` trigger on `pull_request` and `merge_group`. Workflow runs from outside contributors wait for a maintainer to approve them in the Actions tab. +`Branch Checks` targets two GKE ARC labels for trusted Linux jobs: +`openshell-ci-amd64` and `openshell-ci-arm64`. Same-repository branches, manual +runs, and merge groups use these labels. Fork PRs use GitHub-hosted runners; +ARM Python and macOS also remain hosted. This configuration is on the CI branch +and takes effect on main when merged. `Branch Checks` and `Helm Lint` trigger on +`pull_request` and `merge_group`. Outside contributors may need maintainer approval +in the Actions tab. + +AMD64 has five warm workers and a twenty-worker limit on `c4-standard-24` Ubuntu +nodes; ARM64 has three warm workers and a four-worker limit on `c4a-standard-16`. +Each architecture label is shared by internal singleton cache slots. GitHub +can dispatch any matching job to a free slot; workflows never select slot names. +Each slot owns an exclusive 200 GiB Hyperdisk Balanced claim, provisioned on +first use, with 6,000 IOPS and 250 MiB/s. At full use this is 4.8 TiB across +24 slots. Claims survive runner replacement and node scaling; deleting a claim +deletes its disk. `ReadWriteOncePod` prevents concurrent mounts, including on +the same node. Replacement runners may briefly wait for disk release. + +Every AMD64 runner reserves/limits eight CPUs, with 16 GiB requested and 32 GiB +maximum memory. ARM64 reserves/limits twelve CPUs, with 32 GiB requested and +48 GiB maximum memory. Each has an isolated Docker sidecar reserving one CPU +and 4 GiB memory, limited to two CPUs and 8 GiB. Runner images contain GitHub +CLI, system dependencies, and preloaded Nix shells with signed Cachix configured. +The system pool uses N4, and the general N4 pool continues to host AMD64 BuildKit +and memcached. + +Rust jobs use shared memcached sccache plus the slot's persistent target directory. +Targets are separated by repository, Nix shell, job, and matrix variant; branch +and run IDs are excluded so subsequent runs can reuse outputs. GitHub Cargo +archive caches are skipped on these workers. Checkout, credentials, and Docker +storage remain ephemeral. A job can land on a different slot with a colder +target cache; shared sccache can still serve compiler outputs. This removes the +old job-specific serialization but does not guarantee a warm target every run. +Check initial target size, runner name, and queue/setup time when comparing runs. +There is no automatic disk pruning; monitor usage and pause workers before +resetting or removing cache directories. + +AMD64 tests set `CARGO_PROFILE_TEST_DEBUG=0` and use a separate `test-debug0` +target directory. All assertions and crypto/workspace checks remain enabled; +backtraces contain less debug information. Other platforms retain their profiles. + +Manual Branch Checks runs can enable `local_image_builds` for an additional +native AMD64 gateway/sandbox/supervisor build and `--help` smoke check. It uses +the production Nix auditable release-binary build commands and remote BuildKit, explicitly sets +`DOCKER_PUSH=0` and `DOCKER_OUTPUT=type=docker`, and loads results only into the +runner's ephemeral Docker daemon. No registry login, image upload, or registry +cache export is performed. The job uses the production Nix GNU/musl toolchain +rather than the local Zig staging helper, verifies the glibc 2.28 floor and +static sandbox linkage, and skips unrelated mise tool installation. This optional release/image build is measured +separately from the normal branch-check latency and does not qualify ARM64 +images or release attestations. + +Native ARM lint/crypto, workspace tests, and build-mode checks all use +`openshell-ci-arm64`. Build-mode checks retain telemetry-on/off builds, +telemetry-marker verification, system CA roots, and prover dependency checks. +Verification reads `${CARGO_TARGET_DIR:-target}/debug/...`. ARM crypto checks +run in the lint job in parallel with workspace tests; AMD64 and hosted test jobs +retain their crypto checks. + +Gateway core features run two matrix jobs on `openshell-ci-amd64`: +`base-kubernetes` checks no-driver and Kubernetes-only configurations, while +`docker-podman` checks Docker-only and Podman-only configurations. Each variant +has its own persistent target namespace. All four commands retain +`--all-targets --no-default-features`, and both matrix jobs must succeed. `pull_request` runs from forks get a read-only token and no secrets, so they cannot post statuses. `Required CI Gates` runs from the base repository (`pull_request_target` and `workflow_run`), never checks out PR code, and posts the required `OpenShell / ...` statuses on the PR head SHA. E2E suites are opt-in because they are more expensive.