diff --git a/.agents/skills/manage-ci/SKILL.md b/.agents/skills/manage-ci/SKILL.md index 71816abd..db7c0bed 100644 --- a/.agents/skills/manage-ci/SKILL.md +++ b/.agents/skills/manage-ci/SKILL.md @@ -9,7 +9,7 @@ Read this file before inspecting or changing CI. This is the standalone Skippy contract; no downstream product's workflow topology applies here. - `.github/workflows/pr-checks.yml` owns the single intended required `PR checks` - aggregate on a standard GitHub-hosted Ubuntu runner. Protected-main code reads + aggregate on the repository's selected Ubuntu runner. Protected-main code reads workflow/check/status results without executing candidate code or using lab credentials. Failures/cancellations fail it; pending or missing applicable work stays pending; success/neutral/intentional skips pass. Producer starts and diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 527a23a5..a1307860 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -35,6 +35,7 @@ runs: fi echo "SKIPPY_CARGO_CACHE_LAYOUT=${digest:0:16}" >> "$GITHUB_ENV" - name: Restore shared Cargo downloads + if: ${{ !startsWith(runner.name, 'depot-') }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | @@ -44,10 +45,12 @@ runs: restore-keys: | cargo-downloads-v1-${{ github.event_name == 'pull_request_target' && 'same-repo-pr-' || '' }}${{ runner.os }}-${{ env.SKIPPY_CARGO_CACHE_LAYOUT }}-${{ inputs.download-scope }}- - name: Identify checked-out source + if: ${{ !startsWith(runner.name, 'depot-') }} id: source shell: bash run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - name: Restore rolling Cargo build snapshot + if: ${{ !startsWith(runner.name, 'depot-') }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ inputs.build-paths }} diff --git a/.github/actions/ci-package/action.yml b/.github/actions/ci-package/action.yml index 2add796a..1b5b4f73 100644 --- a/.github/actions/ci-package/action.yml +++ b/.github/actions/ci-package/action.yml @@ -10,6 +10,9 @@ inputs: build-cli: description: Build the CLI locally instead of downloading the platform producer artifact. default: 'false' + setup-host: + description: Install the pinned command runner on a standard runner image. + default: 'false' smoke: description: Select inference or artifact smoke. default: inference @@ -26,7 +29,7 @@ runs: using: composite steps: - uses: ./.github/actions/setup - if: runner.environment == 'github-hosted' && inputs.containerized != 'true' + if: inputs.setup-host == 'true' with: cache: 'false' - name: Identify the compiler image diff --git a/.github/actions/ci-smoke/action.yml b/.github/actions/ci-smoke/action.yml index cf322940..4eedc64c 100644 --- a/.github/actions/ci-smoke/action.yml +++ b/.github/actions/ci-smoke/action.yml @@ -33,7 +33,7 @@ runs: name: ${{ env.SKIPPY_ARTIFACT_SCOPE }}-package-${{ inputs.runtime_id }} path: dist/products/${{ inputs.runtime_id }} - name: Restore immutable Qwen3 smoke fixture - if: env.SKIPPY_CI_MODEL == '' + if: ${{ !startsWith(runner.name, 'depot-') && env.SKIPPY_CI_MODEL == '' }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: target/ci-models/Qwen3-0.6B-Q8_0.gguf diff --git a/.github/actions/native-source/action.yml b/.github/actions/native-source/action.yml index 458a9954..6edebe47 100644 --- a/.github/actions/native-source/action.yml +++ b/.github/actions/native-source/action.yml @@ -4,7 +4,7 @@ runs: using: composite steps: - name: Restore prepared llama.cpp source - if: env.LLAMA_WORKDIR == '' && env.LLAMA_UPSTREAM_URL == '' && env.LLAMA_PIN_FILE == '' && env.LLAMA_PATCH_DIR == '' && env.SKIPPY_LLAMA_DIR == '' + if: ${{ !startsWith(runner.name, 'depot-') && env.LLAMA_WORKDIR == '' && env.LLAMA_UPSTREAM_URL == '' && env.LLAMA_PIN_FILE == '' && env.LLAMA_PATCH_DIR == '' && env.SKIPPY_LLAMA_DIR == '' }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: .deps/llama.cpp @@ -12,7 +12,7 @@ runs: restore-keys: | native-source-v1-${{ runner.os }}-${{ hashFiles('llama_cpp/upstream.txt') }}- - name: Restore pinned whisper.cpp source - if: env.WHISPER_WORKDIR == '' && env.WHISPER_UPSTREAM_URL == '' && env.WHISPER_PIN_FILE == '' + if: ${{ !startsWith(runner.name, 'depot-') && env.WHISPER_WORKDIR == '' && env.WHISPER_UPSTREAM_URL == '' && env.WHISPER_PIN_FILE == '' }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: .deps/whisper.cpp diff --git a/.github/actions/sccache/action.yml b/.github/actions/sccache/action.yml index 280e06f1..7d564b3a 100644 --- a/.github/actions/sccache/action.yml +++ b/.github/actions/sccache/action.yml @@ -4,6 +4,9 @@ inputs: scope: description: Platform and backend identity for cache isolation. required: true + read-only: + description: Use the compiler cache in read-only mode even on protected main. + default: 'false' runs: using: composite steps: @@ -14,10 +17,12 @@ runs: core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'true'); core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('SKIPPY_ACTIONS_CACHE_MODE', process.env.ACTIONS_CACHE_MODE || ''); - name: Prepare pinned sccache shell: bash env: SCCACHE_SCOPE: ${{ inputs.scope }} + SCCACHE_READ_ONLY: ${{ inputs.read-only }} run: | set -euo pipefail version=0.19.0 @@ -66,8 +71,11 @@ runs: export SCCACHE_GHA_RW_MODE=READ_ONLY case "${GITHUB_REF:-}:$GITHUB_EVENT_NAME" in refs/heads/main:push|refs/heads/main:schedule|refs/heads/main:workflow_dispatch) - if [[ "${GITHUB_REF_PROTECTED:-false}" == true && "$(git rev-parse HEAD)" == "$GITHUB_SHA" ]]; then - export SCCACHE_GHA_RW_MODE=READ_WRITE + if [[ "$SCCACHE_READ_ONLY" != true && "${GITHUB_REF_PROTECTED:-false}" == true && + "$(git rev-parse HEAD)" == "$GITHUB_SHA" ]]; then + case "${SKIPPY_ACTIONS_CACHE_MODE:-write}" in + write|write-only) export SCCACHE_GHA_RW_MODE=READ_WRITE ;; + esac fi ;; esac diff --git a/.github/path-filters.yml b/.github/path-filters.yml index a016e3ed..5fc2b4bc 100644 --- a/.github/path-filters.yml +++ b/.github/path-filters.yml @@ -14,6 +14,7 @@ code: - '.github/scripts/**' - '.github/path-filters.yml' - '.github/workflows/ci.yml' + - '.github/workflows/ci-pr.yml' - '.github/workflows/inference.yml' - '.github/workflows/llama-upgrade.yml' - 'Cargo.toml' diff --git a/.github/scripts/ci-gate.test.cjs b/.github/scripts/ci-gate.test.cjs index 5324a105..37e18dbe 100644 --- a/.github/scripts/ci-gate.test.cjs +++ b/.github/scripts/ci-gate.test.cjs @@ -86,6 +86,89 @@ test('hosted CI cannot satisfy a native inference requirement', () => { assert.throws(() => gate(results({ hostedRequiresNative: true })), /require native hardware qualification on an isolated runner/); }); +test('the repository switch moves every hosted job to Depot', () => { + const workflows = ['ci', 'ci-images', 'ci-image-builds', 'docs', 'inference', 'llama-upgrade', 'pr-checks', 'release']; + for (const name of workflows) { + const yaml = readFileSync(join(__dirname, '../workflows', name + '.yml'), 'utf8'); + const labels = [...yaml.matchAll(/^ runs-on: (.+)\n((?: .+\n)*)/gm)] + .map(([, label, continuation]) => `${label} ${continuation.trim().replaceAll(/\s+/g, ' ')}`.trim()); + assert.ok(labels.some(label => label.includes('SKIPPY_DEPOT_RUNNERS_ENABLED')), name); + const smokeJobs = name === 'ci' ? workflow.split('\n pr_image_builds:')[0] : ''; + const smokeLabels = [...smokeJobs.matchAll(/^ runs-on: (.+)$/gm)].map(([, label]) => label); + assert.deepEqual(smokeLabels, name === 'ci' ? ['depot-ubuntu-24.04-4', 'depot-ubuntu-24.04-4'] : []); + for (const label of labels.slice(smokeLabels.length)) { + if (name === 'llama-upgrade' && label === '${{ matrix.runner }}') continue; + assert.match(label, /vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true'.*depot-/, name); + } + } +}); + +test('ordinary PRs call protected workflows with scoped cache access and read-only permissions', () => { + const workflows = { 'ci-pr': 'ci', 'ci-images-pr': 'ci', 'docs-pr': 'docs' }; + for (const [caller, callee] of Object.entries(workflows)) { + const yaml = readFileSync(join(__dirname, '../workflows', caller + '.yml'), 'utf8'); + assert.ok(yaml.includes(`uses: Mesh-LLM/skippy/.github/workflows/${callee}.yml@main`)); + assert.match(yaml, caller === 'ci-pr' ? /^ cache-mode: read$/m : /^ cache-mode: none$/m); + assert.doesNotMatch(yaml, /runs-on:|secrets:|: write$/m); + const reusable = readFileSync(join(__dirname, '../workflows', callee + '.yml'), 'utf8'); + assert.doesNotMatch(reusable, /^(?: )+\w+: write$/m); + } +}); + +test('Depot compiler cache smoke runs only on manual protected main and caps its reader', () => { + const [seed, read] = workflow.split('\n sccache_seed:\n')[1] + .split('\n pr_image_builds:\n')[0].split('\n sccache_read:\n'); + assert.match(seed, /github\.workflow_ref == 'Mesh-LLM\/skippy\/\.github\/workflows\/ci\.yml@refs\/heads\/main'/); + assert.match(seed, /github\.event_name == 'workflow_dispatch' && inputs\.profile == 'sccache'/); + assert.doesNotMatch(seed + read, /^ cache-mode:/m); + assert.match(read, /^ needs: sccache_seed$/m); + assert.match(read, /needs\.sccache_seed\.outputs\.scope/); + assert.match(read, /read-only: 'true'/); + const changes = workflow.split('\n changes:\n')[1].split('\n plan:\n')[0]; + assert.match(changes, /github\.event_name != 'workflow_dispatch' \|\| inputs\.profile != 'sccache'/); +}); + +test('the protected image PR bridge routes only the image workflow', () => { + const bridge = workflow.split('\n pr_image_builds:\n')[1].split('\n changes:\n')[0]; + const admission = bridge.match(/if: >-\n([\s\S]+?)\n uses:/)[1]; + const eligible = new Function('github', 'vars', 'startsWith', `return (${admission});`); + const event = { + repository: 'Mesh-LLM/skippy', event_name: 'pull_request', + workflow_ref: 'Mesh-LLM/skippy/.github/workflows/ci-images-pr.yml@refs/pull/136/merge', + }; + const vars = { SKIPPY_DEPOT_RUNNERS_ENABLED: 'true' }; + const startsWith = (value, prefix) => value.startsWith(prefix); + assert.equal(eligible(event, vars, startsWith), true); + assert.equal(eligible(event, {}, startsWith), false); + assert.equal(eligible({ ...event, workflow_ref: event.workflow_ref.replace('ci-images-pr', 'ci-pr') }, vars, startsWith), false); + assert.match(bridge, /uses: \.\/\.github\/workflows\/ci-image-builds\.yml/); +}); + +test('host CPU packages install Just on GitHub and Depot runners', () => { + for (const row of rows) { + const job = `package_${row.id.replaceAll('-', '_')}`; + const body = workflow.split(`\n ${job}:\n`)[1].split(/\n \w+:\n/)[0]; + assert.equal(body.includes("setup-host: 'true'"), row.backend === 'cpu', job); + } + const action = readFileSync(join(__dirname, '../actions/ci-package/action.yml'), 'utf8'); + assert.match(action, /uses: \.\/\.github\/actions\/setup\n if: inputs.setup-host == 'true'/); +}); + +test('manual compiler image smoke can skip publication on either runner provider', () => { + const images = readFileSync(join(__dirname, '../workflows/ci-images.yml'), 'utf8'); + const repository = 'Mesh-LLM/skippy'; + const ref = 'refs/heads/main'; + for (const kind of ['cpu', 'gpu']) { + const publish = images.split(`\n ${kind}-publish:\n`)[1]; + const publishPolicy = publish.match(/if: >-\n([\s\S]+?)\n runs-on:/)[1]; + const publishImage = new Function('github', 'inputs', `return (${publishPolicy});`); + assert.equal(publishImage({ repository, ref, event_name: 'workflow_dispatch' }, { build_only: true }), false); + assert.equal(publishImage({ repository, ref, event_name: 'workflow_dispatch' }, { build_only: false }), true); + assert.equal(publishImage({ repository, ref, event_name: 'push' }, {}), true); + assert.equal(publishImage({ repository, ref, event_name: 'pull_request' }, {}), false); + } +}); + test('native CI trusts only an immutable same-repository PR from a writer', async () => { const admission = workflow.split(' - name: Verify the same-repository PR author\n')[1].split('\n plan:\n')[0]; const script = admission.split(' script: |\n')[1]; diff --git a/.github/scripts/pr-checks.cjs b/.github/scripts/pr-checks.cjs index 4da61784..4b6cc44d 100644 --- a/.github/scripts/pr-checks.cjs +++ b/.github/scripts/pr-checks.cjs @@ -5,7 +5,7 @@ const automaticPR = run => ['pull_request', 'pull_request_target'].includes(run. const accepted = new Set(['success', 'skipped', 'neutral']); const controllerName = 'Evaluate aggregate PR checks'; -module.exports = async function aggregate({ github, context, core }) { +module.exports = async function aggregate({ github, context, core, depot = false }) { const repo = context.repo; const trigger = context.payload.workflow_run; const source = context.payload.pull_request?.head.sha || trigger?.head_sha || @@ -36,7 +36,7 @@ module.exports = async function aggregate({ github, context, core }) { } const sameRepositoryPR = pr.base?.ref === 'main' && pr.head.repo?.id != null && pr.head.repo.id === pr.base.repo?.id; - const expected = expectedWorkflows(files, sameRepositoryPR); + const expected = expectedWorkflows(files, sameRepositoryPR, depot); const runs = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, { ...repo, head_sha: source, per_page: 100 }); const latest = new Map(); diff --git a/.github/scripts/pr-checks.test.cjs b/.github/scripts/pr-checks.test.cjs index 4b3dbe1b..d7def2cb 100644 --- a/.github/scripts/pr-checks.test.cjs +++ b/.github/scripts/pr-checks.test.cjs @@ -32,7 +32,7 @@ async function evaluate(options = {}) { } }; const context = { repo: { owner: 'Mesh-LLM', repo: 'skippy' }, runId: 42, payload: options.payload || { pull_request: pr } }; - await aggregate({ github, context, core: { info() {}, setFailed: message => failures.push(message) } }); + await aggregate({ github, context, depot: options.depot, core: { info() {}, setFailed: message => failures.push(message) } }); assert.ok(calls.every(c => c.sha === sha && c.context === 'PR checks')); return { state: calls.at(-1)?.state, calls, failures }; } @@ -63,9 +63,13 @@ test('every failed or cancelled workflow blocks, including additional workflows' test('combined image workflow cannot be missed before it is scheduled', async () => { const workflow = readFileSync(join(__dirname, '../workflows/ci-images.yml'), 'utf8'); const triggers = [...workflow.matchAll(/paths: \[([^\]]+)\]/g)]; - const expectedPaths = ['.github/workflows/ci-images.yml', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile']; + const expectedPaths = ['.github/workflows/ci-images.yml', '.github/workflows/ci-images-pr.yml', + '.github/workflows/ci-image-builds.yml', 'ci/image-targets.json', 'ci/Dockerfile*', + 'ci/targets.json', 'rust-toolchain.toml', 'Justfile']; assert.equal(triggers.length, 2); for (const trigger of triggers) assert.deepEqual(JSON.parse('[' + trigger[1].replaceAll("'", '"') + ']'), expectedPaths); + const pr = readFileSync(join(__dirname, '../workflows/ci-images-pr.yml'), 'utf8'); + assert.equal(pr.match(/paths: \[([^\]]+)\]/)[1], triggers[0][1]); for (const filename of [ 'ci/Dockerfile', 'ci/Dockerfile.cuda', 'ci/Dockerfile.gpu', 'ci/Dockerfile.gpu.dockerignore', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile', '.github/workflows/ci-images.yml' @@ -137,6 +141,8 @@ test('native CI and inference triggers match the internal route lists', () => { const exclusion = code.findIndex(path => path.startsWith('!')); assert.deepEqual(lists(prPaths), [...code.slice(0, exclusion), ...ciOnly, ...code.slice(exclusion)]); assert.deepEqual(lists(targetPaths), lists(prPaths)); + const depotPr = readFileSync(join(__dirname, '../workflows/ci-pr.yml'), 'utf8'); + assert.deepEqual(lists(depotPr), lists(prPaths)); const includes = lists(prPaths).filter(path => !path.startsWith('!')); for (const path of inference.filter(path => !path.startsWith('!'))) { assert.ok(includes.some(trigger => trigger === path || @@ -156,6 +162,20 @@ test('same-repository PRs to main wait for the protected CI producer', async () assert.equal((await evaluate({ pr: fork, runs: [ordinary, inference] })).state, 'success'); }); +test('Depot PR checks require each protected producer rather than its legacy run', async () => { + const files = [inferenceChange, { filename: 'ci/Dockerfile' }, { filename: 'docs-site/index.mdx' }]; + const legacy = [run('ci.yml'), run('inference.yml'), run('ci-images.yml'), run('docs.yml')]; + const protectedRuns = [run('ci-pr.yml'), run('inference.yml'), run('ci-images-pr.yml'), run('docs-pr.yml')]; + assert.equal((await evaluate({ files, depot: true, runs: legacy })).state, 'pending'); + assert.equal((await evaluate({ files, depot: true, runs: protectedRuns })).state, 'success'); + assert.equal((await evaluate({ files, depot: true, runs: protectedRuns.slice(0, -1) })).state, 'pending'); + assert.equal((await evaluate({ files, runs: legacy })).state, 'success'); + + const pr = { head: { sha, repo: { id: 42 } }, base: { ref: 'main', repo: { id: 42 } } }; + const sameRepository = [run('ci.yml', 3, { event: 'pull_request_target' }), ...protectedRuns.slice(1)]; + assert.equal((await evaluate({ files, pr, depot: true, runs: sameRepository })).state, 'success'); +}); + test('latest run and attempt govern reruns; old cancellations do not poison new results', async () => { const runs = [run('ci.yml'), run('inference.yml', 2, { conclusion: 'cancelled' }), run('inference.yml', 3)]; assert.equal((await evaluate({ runs })).state, 'success'); diff --git a/.github/scripts/pr-trigger-paths.cjs b/.github/scripts/pr-trigger-paths.cjs index dfefdb3b..58cc6902 100644 --- a/.github/scripts/pr-trigger-paths.cjs +++ b/.github/scripts/pr-trigger-paths.cjs @@ -34,16 +34,17 @@ function workflowPaths(workflow, eventName) { return rules; } -function expectedWorkflows(files, sameRepositoryPR = false) { +function expectedWorkflows(files, sameRepositoryPR = false, depot = false) { const filenames = files.flatMap(({ filename, previous_filename }) => [filename, previous_filename]).filter(Boolean); const expected = new Map(); for (const [workflow, defaultEvent] of producers) { const eventName = workflow === 'ci.yml' && sameRepositoryPR ? 'pull_request_target' : defaultEvent; - const rules = workflowPaths(workflow, eventName); + const producer = depot && eventName === 'pull_request' ? workflow.replace('.yml', '-pr.yml') : workflow; + const rules = workflowPaths(producer, eventName); // GitHub applies matching path patterns in order, with the last match // determining whether each changed file is included. if (filenames.some(filename => rules.findLast(rule => rule.regex.test(filename))?.include)) { - expected.set(`.github/workflows/${workflow}`, eventName); + expected.set(`.github/workflows/${producer}`, eventName); } } return expected; diff --git a/.github/workflows/ci-image-builds.yml b/.github/workflows/ci-image-builds.yml new file mode 100644 index 00000000..54cf9494 --- /dev/null +++ b/.github/workflows/ci-image-builds.yml @@ -0,0 +1,130 @@ +name: Build CI images +on: + workflow_call: + inputs: + image-set: + description: Select CPU, GPU, or both sets of compiler images. + type: string + default: all + outputs: + cpu-artifact-id: + value: ${{ jobs.cpu-build.outputs.artifact_id }} + cpu-image-id: + value: ${{ jobs.cpu-build.outputs.image_id }} + gpu-matrix: + value: ${{ jobs.matrix.outputs.gpu }} +permissions: + contents: read +jobs: + matrix: + name: Validate compiler image targets + if: >- + github.repository == 'Mesh-LLM/skippy' && + (inputs.image-set != 'cpu' || + (github.event_name == 'pull_request' && vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true')) + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} + timeout-minutes: 5 + outputs: + gpu: ${{ steps.plan.outputs.gpu }} + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 + with: + ref: ${{ github.sha }} + persist-credentials: false + - id: plan + run: | + set -euo pipefail + matrix="$(jq -ce ' + .include as $rows + | select(($rows | map([.backend, .arch]) | sort) == [ + ["cuda12", "amd64"], ["cuda12", "arm64"], ["cuda13", "amd64"], + ["cuda13", "arm64"], ["rocm", "amd64"]]) + | select(all($rows[]; (.toolkit_version | test("^[0-9]+[.][0-9]+[.][0-9]+$")) and + (.toolkit_base | test("@sha256:[a-f0-9]{64}$")))) + ' ci/image-targets.json)" + printf 'gpu=%s\n' "$matrix" >> "$GITHUB_OUTPUT" + cpu-build: + name: Build and test CPU image + if: >- + github.repository == 'Mesh-LLM/skippy' && + (inputs.image-set != 'gpu' || + (github.event_name == 'pull_request' && vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true')) + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} + timeout-minutes: 45 + outputs: + artifact_id: ${{ steps.image.outputs.artifact-id }} + image_id: ${{ steps.metadata.outputs.image_id }} + env: + SKIPPY_CI_IMAGE_ID: ${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }} + SOURCE_REVISION: ${{ github.sha }} + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false + - uses: ./.github/actions/setup + with: + cache: 'false' + - run: just ci-image-build + - run: time just ci-image-smoke + - id: metadata + run: | + echo "image_id=$(docker image inspect --format '{{.Id}}' skippy-ci-cpu:build)" >> "$GITHUB_OUTPUT" + docker image inspect --format 'Uncompressed image size: {{.Size}} bytes' skippy-ci-cpu:build + - run: just ci-image-export + - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + id: image + with: + name: skippy-ci-cpu-${{ github.run_id }}-${{ github.run_attempt }} + path: target/ci-image/skippy-ci-cpu.tar + if-no-files-found: error + retention-days: 7 + gpu-build: + name: Build and test ${{ matrix.backend }} image (${{ matrix.arch }}) + needs: matrix + runs-on: >- + ${{ matrix.arch == 'arm64' && (vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-arm-4' || 'ubuntu-24.04-arm') || + (vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04') }} + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.matrix.outputs.gpu) }} + env: + SKIPPY_CI_IMAGE_ID: ${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.backend }}-${{ matrix.arch }} + SOURCE_REVISION: ${{ github.sha }} + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false + - uses: ./.github/actions/setup + with: + cache: 'false' + - name: Free unused runner disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h / + - name: Build image + env: + BACKEND: ${{ matrix.backend }} + ARCH: ${{ matrix.arch }} + TOOLKIT_BASE: ${{ matrix.toolkit_base }} + TOOLKIT_VERSION: ${{ matrix.toolkit_version }} + run: just ci-gpu-image-build "$BACKEND" "$TOOLKIT_BASE" "$TOOLKIT_VERSION" "$ARCH" + - name: Smoke test image + run: time just ci-gpu-image-smoke '${{ matrix.backend }}' '${{ matrix.arch }}' + - name: Free build cache before export + run: | + docker builder prune -f + df -h / + - name: Export tested image + run: just ci-gpu-image-export '${{ matrix.backend }}' + - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + # A publish-only retry can reuse the successful build's archive. + name: skippy-ci-${{ matrix.backend }}-${{ matrix.arch }}-${{ github.run_id }} + path: | + target/ci-image/skippy-ci-${{ matrix.backend }}.tar.gz + target/ci-image/skippy-ci-${{ matrix.backend }}.id + compression-level: 0 + if-no-files-found: error + overwrite: true + retention-days: 7 diff --git a/.github/workflows/ci-images-pr.yml b/.github/workflows/ci-images-pr.yml new file mode 100644 index 00000000..7551dca1 --- /dev/null +++ b/.github/workflows/ci-images-pr.yml @@ -0,0 +1,15 @@ +name: CI images PR +on: + pull_request: + paths: ['.github/workflows/ci-images.yml', '.github/workflows/ci-images-pr.yml', '.github/workflows/ci-image-builds.yml', 'ci/image-targets.json', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile'] +jobs: + validation: + if: >- + github.repository == 'Mesh-LLM/skippy' && vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' + permissions: + contents: read + actions: read + packages: read + pull-requests: read + cache-mode: none + uses: Mesh-LLM/skippy/.github/workflows/ci.yml@main diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml index 991e2e98..c8d6e8a2 100644 --- a/.github/workflows/ci-images.yml +++ b/.github/workflows/ci-images.yml @@ -1,56 +1,40 @@ name: CI images on: pull_request: - paths: ['.github/workflows/ci-images.yml', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile'] + paths: ['.github/workflows/ci-images.yml', '.github/workflows/ci-images-pr.yml', '.github/workflows/ci-image-builds.yml', 'ci/image-targets.json', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile'] push: branches: [main] - paths: ['.github/workflows/ci-images.yml', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile'] + paths: ['.github/workflows/ci-images.yml', '.github/workflows/ci-images-pr.yml', '.github/workflows/ci-image-builds.yml', 'ci/image-targets.json', 'ci/Dockerfile*', 'ci/targets.json', 'rust-toolchain.toml', 'Justfile'] workflow_dispatch: + inputs: + build_only: + description: Build and test images without publishing + type: boolean + default: false permissions: contents: read concurrency: - group: skippy-ci-images-${{ github.event.pull_request.number || 'main' }} + group: skippy-ci-images-${{ github.workflow }}-${{ github.event.pull_request.number || 'main' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: cpu-build: - name: Build and test CPU image - runs-on: ubuntu-24.04 - timeout-minutes: 45 - outputs: - artifact_id: ${{ steps.image.outputs.artifact-id }} - image_id: ${{ steps.metadata.outputs.image_id }} - env: - SKIPPY_CI_IMAGE_ID: ${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }} - SOURCE_REVISION: ${{ github.sha }} - steps: - - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - with: - persist-credentials: false - - uses: ./.github/actions/setup - with: - cache: 'false' - - run: just ci-image-build - - run: time just ci-image-smoke - - id: metadata - run: | - echo "image_id=$(docker image inspect --format '{{.Id}}' skippy-ci-cpu:build)" >> "$GITHUB_OUTPUT" - docker image inspect --format 'Uncompressed image size: {{.Size}} bytes' skippy-ci-cpu:build - - run: just ci-image-export - - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - id: image - with: - name: skippy-ci-cpu-${{ github.run_id }}-${{ github.run_attempt }} - path: target/ci-image/skippy-ci-cpu.tar - if-no-files-found: error - retention-days: 7 + if: github.event_name != 'pull_request' || vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' + uses: ./.github/workflows/ci-image-builds.yml + with: + image-set: cpu + gpu-build: + if: github.event_name != 'pull_request' || vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' + uses: ./.github/workflows/ci-image-builds.yml + with: + image-set: gpu cpu-publish: name: Publish tested CPU image needs: cpu-build if: >- github.repository == 'Mesh-LLM/skippy' && github.ref == 'refs/heads/main' && - (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - runs-on: ubuntu-24.04 + (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.build_only)) + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 permissions: contents: read @@ -58,11 +42,11 @@ jobs: steps: - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: - artifact-ids: ${{ needs.cpu-build.outputs.artifact_id }} + artifact-ids: ${{ needs.cpu-build.outputs.cpu-artifact-id }} path: image - name: Load and verify tested image env: - EXPECTED_IMAGE_ID: ${{ needs.cpu-build.outputs.image_id }} + EXPECTED_IMAGE_ID: ${{ needs.cpu-build.outputs.cpu-image-id }} run: | set -euo pipefail docker image load --input image/skippy-ci-cpu.tar @@ -82,97 +66,28 @@ jobs: docker image push "$image:$build_tag" docker image tag skippy-ci-cpu:build "$image:latest" docker image push "$image:latest" - gpu-build: - name: Build and test ${{ matrix.backend }} image (${{ matrix.arch }}) - runs-on: ${{ matrix.runner }} - timeout-minutes: 120 - strategy: - fail-fast: false - matrix: &gpu-image-matrix - include: - - backend: cuda12 - arch: amd64 - runner: ubuntu-24.04 - toolkit_version: '12.9.2' - toolkit_base: 'nvidia/cuda:12.9.2-devel-ubuntu24.04@sha256:420850a3fd665171b3f1fd08946c51d50468d732a46d6c42345ea04444755048' - - backend: cuda12 - arch: arm64 - runner: ubuntu-24.04-arm - toolkit_version: '12.9.2' - toolkit_base: 'nvidia/cuda:12.9.2-devel-ubuntu24.04@sha256:fd13aa4b2b769b9ffece066fbf6ca7cf733509f85fef4b5e432fe7c0b5782f70' - - backend: cuda13 - arch: amd64 - runner: ubuntu-24.04 - toolkit_version: '13.1.2' - toolkit_base: 'nvidia/cuda:13.1.2-devel-ubuntu24.04@sha256:952e42d23230610a2714c8484f38e9c934ed68e6f9c9c7fac62dcd5f98858a6e' - - backend: cuda13 - arch: arm64 - runner: ubuntu-24.04-arm - toolkit_version: '13.1.2' - toolkit_base: 'nvidia/cuda:13.1.2-devel-ubuntu24.04@sha256:369b61cfc40a36830d246f0a14004a716aee72f4c520ee719b73d2b47e8bd9ce' - - backend: rocm - arch: amd64 - runner: ubuntu-24.04 - toolkit_version: '7.2.4' - toolkit_base: 'rocm/dev-ubuntu-24.04:7.2.4@sha256:bdc8e61026cbb844ede93d44d2c50055f51ebb2041906b60182bf3bee3139054' - env: - SKIPPY_CI_IMAGE_ID: ${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.backend }}-${{ matrix.arch }} - SOURCE_REVISION: ${{ github.sha }} - steps: - - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 - with: - persist-credentials: false - - uses: ./.github/actions/setup - with: - cache: 'false' - - &gpu-disk-cleanup - name: Free unused runner disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc - df -h / - - name: Build image - env: - BACKEND: ${{ matrix.backend }} - ARCH: ${{ matrix.arch }} - TOOLKIT_BASE: ${{ matrix.toolkit_base }} - TOOLKIT_VERSION: ${{ matrix.toolkit_version }} - run: just ci-gpu-image-build "$BACKEND" "$TOOLKIT_BASE" "$TOOLKIT_VERSION" "$ARCH" - - name: Smoke test image - run: time just ci-gpu-image-smoke '${{ matrix.backend }}' '${{ matrix.arch }}' - - name: Free build cache before export - run: | - docker builder prune -f - df -h / - - name: Export tested image - run: just ci-gpu-image-export '${{ matrix.backend }}' - - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - with: - # A publish-only retry can reuse the successful build's archive. - name: skippy-ci-${{ matrix.backend }}-${{ matrix.arch }}-${{ github.run_id }} - path: | - target/ci-image/skippy-ci-${{ matrix.backend }}.tar.gz - target/ci-image/skippy-ci-${{ matrix.backend }}.id - compression-level: 0 - if-no-files-found: error - overwrite: true - retention-days: 7 gpu-publish: name: Publish tested ${{ matrix.backend }} image (${{ matrix.arch }}) needs: gpu-build if: >- github.repository == 'Mesh-LLM/skippy' && github.ref == 'refs/heads/main' && - (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - runs-on: ${{ matrix.runner }} + (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.build_only)) + runs-on: >- + ${{ matrix.arch == 'arm64' && (vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-arm-4' || 'ubuntu-24.04-arm') || + (vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04') }} timeout-minutes: 30 strategy: fail-fast: false - matrix: *gpu-image-matrix + matrix: ${{ fromJSON(needs.gpu-build.outputs.gpu-matrix) }} permissions: contents: read packages: write steps: - - *gpu-disk-cleanup + - name: Free unused runner disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h / - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: skippy-ci-${{ matrix.backend }}-${{ matrix.arch }}-${{ github.run_id }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 00000000..0bc7af79 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,47 @@ +name: CI PR +on: + pull_request: + # Include the inference-only inputs as well as the code filter. + paths: + - 'crates/**' + - 'skippy-api-rs/**' + - 'skippy_api/**' + - 'llama_cpp/**' + - 'tools/**' + - 'scripts/**' + - '.cargo/**' + - '.github/actions/**' + - '.github/scripts/**' + - '.github/path-filters.yml' + - '.github/workflows/ci.yml' + - '.github/workflows/ci-pr.yml' + - '.github/workflows/inference.yml' + - '.github/workflows/llama-upgrade.yml' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' + - 'Justfile' + - 'ci/targets.json' + - 'ci/llama-canary/**' + - '.gi/templates.yaml' + - 'ci/inference-ladder.json' + - 'ci/inference-artifacts.json' + - 'ci/inference-quality.json' + - '!**/*.md' + - '!**/*.mdx' + - '!**/*.rst' + - '!**/*.adoc' + - '!**/docs/**' + - '!docs-site/**' +jobs: + validation: + if: >- + github.repository == 'Mesh-LLM/skippy' && vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && + (github.event.pull_request.head.repo.id != github.event.repository.id || github.base_ref != 'main') + permissions: + contents: read + actions: read + packages: read + pull-requests: read + cache-mode: read + uses: Mesh-LLM/skippy/.github/workflows/ci.yml@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74a89f7c..aef60ffe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ on: - '.github/scripts/**' - '.github/path-filters.yml' - '.github/workflows/ci.yml' + - '.github/workflows/ci-pr.yml' - '.github/workflows/inference.yml' - '.github/workflows/llama-upgrade.yml' - 'Cargo.toml' @@ -47,6 +48,7 @@ on: - '.github/scripts/**' - '.github/path-filters.yml' - '.github/workflows/ci.yml' + - '.github/workflows/ci-pr.yml' - '.github/workflows/inference.yml' - '.github/workflows/llama-upgrade.yml' - 'Cargo.toml' @@ -79,6 +81,7 @@ on: - '.github/scripts/**' - '.github/path-filters.yml' - '.github/workflows/ci.yml' + - '.github/workflows/ci-pr.yml' - '.github/workflows/inference.yml' - '.github/workflows/llama-upgrade.yml' - 'Cargo.toml' @@ -98,9 +101,9 @@ on: workflow_dispatch: inputs: profile: - description: Short checks or complete native/package qualification + description: Short checks, complete native/package qualification, or Depot sccache smoke type: choice - options: [pr, full] + options: [pr, full, sccache] default: full cuda_architecture_mode: description: CUDA architectures for the assigned GPU or the release architecture set @@ -153,13 +156,67 @@ env: # reports nothing. The key is a public ingestion token, not a secret. SKIPPY_POSTHOG_KEY: ${{ inputs.artifact_scope == 'release' && vars.SKIPPY_POSTHOG_KEY || '' }} jobs: + # Inherit cache-mode so callers of this reusable workflow can cap their access. + sccache_seed: + name: Populate the Depot compiler cache + if: >- + github.workflow_ref == 'Mesh-LLM/skippy/.github/workflows/ci.yml@refs/heads/main' && + github.event_name == 'workflow_dispatch' && inputs.profile == 'sccache' + runs-on: depot-ubuntu-24.04-4 + timeout-minutes: 10 + outputs: + scope: ${{ steps.scope.outputs.value }} + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + ref: ${{ github.sha }} + persist-credentials: false + - uses: ./.github/actions/setup + with: + cache: 'false' + - id: scope + run: echo "value=smoke-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT" + - uses: ./.github/actions/sccache + with: + scope: ${{ steps.scope.outputs.value }} + - run: just --justfile ci/sccache-smoke.just run seed + sccache_read: + name: Verify Depot compiler cache hits and read-only misses + needs: sccache_seed + runs-on: depot-ubuntu-24.04-4 + timeout-minutes: 10 + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + ref: ${{ github.sha }} + persist-credentials: false + - uses: ./.github/actions/setup + with: + cache: 'false' + - uses: ./.github/actions/sccache + with: + scope: ${{ needs.sccache_seed.outputs.scope }} + read-only: 'true' + - run: just --justfile ci/sccache-smoke.just run read + pr_image_builds: + # Enter through a reusable already on main. GitHub resolves the outer + # caller's ref even when its job is skipped during the cutover PR. + if: >- + github.repository == 'Mesh-LLM/skippy' && github.event_name == 'pull_request' && + vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && + startsWith(github.workflow_ref, 'Mesh-LLM/skippy/.github/workflows/ci-images-pr.yml@') + uses: ./.github/workflows/ci-image-builds.yml changes: name: Select checks by path if: >- github.repository == 'Mesh-LLM/skippy' && + (github.event_name != 'workflow_dispatch' || inputs.profile != 'sccache') && + (github.event_name != 'pull_request' || + vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' || + startsWith(github.workflow_ref, 'Mesh-LLM/skippy/.github/workflows/ci-pr.yml@')) && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.id != github.event.repository.id || github.base_ref != 'main') && (github.event_name != 'pull_request_target' || github.event.pull_request.head.repo.id == github.event.repository.id) - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 5 permissions: contents: read @@ -170,6 +227,14 @@ jobs: inference: ${{ github.event_name == 'pull_request_target' && steps.paths.outputs.inference == 'true' }} hosted_requires_native: ${{ github.event_name == 'pull_request' && steps.paths.outputs.inference == 'true' }} steps: + - name: Reject custom candidate inputs on pull requests + if: >- + github.event.pull_request != null && + (inputs.source_ref != '' || inputs.candidate_artifact != '' || inputs.candidate_sha != '' || + (inputs.artifact_scope != '' && inputs.artifact_scope != 'ci')) + run: | + echo '::error::Pull requests must use the source from their event.' + exit 1 - name: Reuse qualification from the exact promoted release id: release if: github.event_name == 'push' && github.ref == 'refs/heads/main' @@ -229,7 +294,7 @@ jobs: name: Validate build targets needs: changes if: needs.changes.outputs.code == 'true' || needs.changes.outputs.inference == 'true' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 env: SKIPPY_CI_PROFILE: ${{ github.event.pull_request && 'pr' || inputs.profile || (github.event_name == 'schedule' && 'full' || 'pr') }} @@ -282,7 +347,7 @@ jobs: LIBCLANG_PATH: /usr/lib/llvm-22/lib SKIPPY_REQUIRE_SCCACHE: '1' SCCACHE_GHA_ENABLED: 'true' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} permissions: contents: read packages: read @@ -424,7 +489,7 @@ jobs: name: Build, package, and smoke · macOS ARM64 CPU needs: [plan, quality] if: needs.plan.outputs.profile == 'full' - runs-on: macos-15 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-macos-15' || 'macos-15' }} timeout-minutes: 240 env: SKIPPY_CI_PROFILE: ${{ needs.plan.outputs.profile }} @@ -438,6 +503,7 @@ jobs: runtime-id: darwin-aarch64-cpu host-id: darwin-aarch64 build-cli: 'true' + setup-host: 'true' candidate-artifact: ${{ inputs.candidate_artifact }} candidate-sha: ${{ inputs.candidate_sha }} package_darwin_aarch64_metal: @@ -472,7 +538,7 @@ jobs: needs: [plan, quality] if: needs.plan.outputs.profile == 'full' # The shared CLI must also run in the Ubuntu 24.04 CUDA toolchain images. - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 240 env: SKIPPY_CI_PROFILE: ${{ needs.plan.outputs.profile }} @@ -486,13 +552,14 @@ jobs: runtime-id: linux-x86_64-cpu host-id: linux-x86_64 build-cli: 'true' + setup-host: 'true' candidate-artifact: ${{ inputs.candidate_artifact }} candidate-sha: ${{ inputs.candidate_sha }} package_linux_x86_64_cuda12: name: Build, package, and smoke · Linux x64 CUDA 12 needs: [plan, quality, package_linux_x86_64_cpu] if: needs.plan.outputs.profile == 'full' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} permissions: contents: read packages: read @@ -567,7 +634,7 @@ jobs: name: Build, package, and smoke · Linux ARM64 CPU needs: [plan, quality] if: needs.plan.outputs.profile == 'full' - runs-on: ubuntu-24.04-arm + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-arm-4' || 'ubuntu-24.04-arm' }} timeout-minutes: 240 env: SKIPPY_CI_PROFILE: ${{ needs.plan.outputs.profile }} @@ -581,13 +648,14 @@ jobs: runtime-id: linux-aarch64-cpu host-id: linux-aarch64 build-cli: 'true' + setup-host: 'true' candidate-artifact: ${{ inputs.candidate_artifact }} candidate-sha: ${{ inputs.candidate_sha }} package_linux_aarch64_cuda12: name: Build, package, and smoke · Linux ARM64 CUDA 12 needs: [plan, quality, package_linux_aarch64_cpu] if: needs.plan.outputs.profile == 'full' - runs-on: ubuntu-24.04-arm + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-arm-4' || 'ubuntu-24.04-arm' }} permissions: contents: read packages: read @@ -635,7 +703,7 @@ jobs: name: Build, package, and smoke · Linux ARM64 CUDA 13 needs: [plan, quality, package_linux_aarch64_cpu] if: needs.plan.outputs.profile == 'full' - runs-on: ubuntu-24.04-arm + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-arm-4' || 'ubuntu-24.04-arm' }} permissions: contents: read packages: read @@ -689,7 +757,7 @@ jobs: release_smoke_linux_x86_64_cuda12, release_smoke_linux_aarch64_cuda12, release_smoke_linux_aarch64_cuda13 ] if: always() && needs.changes.result != 'skipped' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 5 steps: - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml new file mode 100644 index 00000000..cb9e1753 --- /dev/null +++ b/.github/workflows/docs-pr.yml @@ -0,0 +1,13 @@ +name: Documentation PR +on: + pull_request: + paths: + - 'docs-site/**' +jobs: + validation: + if: >- + github.repository == 'Mesh-LLM/skippy' && vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' + permissions: + contents: read + cache-mode: none + uses: Mesh-LLM/skippy/.github/workflows/docs.yml@main diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3e47a590..e9e0e2f3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,23 +21,29 @@ on: permissions: contents: read concurrency: - group: skippy-docs-${{ github.event.pull_request.number || github.ref }} + group: skippy-docs-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: documentation: name: Documentation - runs-on: ubuntu-24.04 + if: >- + github.repository == 'Mesh-LLM/skippy' && + (github.event_name != 'pull_request' || + vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' || + startsWith(github.workflow_ref, 'Mesh-LLM/skippy/.github/workflows/docs-pr.yml@')) + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: - ref: ${{ inputs.source_ref || github.sha }} + ref: ${{ (github.event_name != 'pull_request' && inputs.source_ref) || github.sha }} persist-credentials: false - uses: ./.github/actions/setup - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version: '22.23.0' - cache: npm + cache: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' && 'npm' || '' }} + package-manager-cache: false cache-dependency-path: docs-site/package-lock.json - name: Build searchable documentation site run: | @@ -45,7 +51,7 @@ jobs: just docs-build - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: - name: ${{ inputs.artifact_scope || 'ci' }}-docs-site + name: ${{ (github.event_name != 'pull_request' && inputs.artifact_scope) || 'ci' }}-docs-site path: docs-site/out if-no-files-found: error overwrite: true diff --git a/.github/workflows/inference.yml b/.github/workflows/inference.yml index 6f5620df..d3042082 100644 --- a/.github/workflows/inference.yml +++ b/.github/workflows/inference.yml @@ -89,7 +89,7 @@ jobs: if: >- github.event_name != 'pull_request_target' || contains(github.event.pull_request.labels.*.name, 'qualify') - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 outputs: source: ${{ steps.admission.outputs.source || github.event.pull_request.head.sha || github.sha }} @@ -125,7 +125,7 @@ jobs: fail-fast: false max-parallel: 3 matrix: ${{ fromJSON(needs.plan.outputs.matrix) }} - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: ${{ matrix.profile == 'pr' && 100 || 360 }} env: EVIDENCE: target/ci-evidence/inference-${{ matrix.id }} @@ -168,7 +168,7 @@ jobs: always() && !cancelled() && github.event_name == 'schedule' && github.repository == 'Mesh-LLM/skippy' && github.ref == 'refs/heads/main' && needs.plan.result == 'success' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 permissions: contents: read @@ -207,7 +207,7 @@ jobs: summary: needs: [plan, qualification, nightly_publish] if: always() - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 5 steps: - name: Publish the source-bound qualification result @@ -246,7 +246,7 @@ jobs: report: needs: [plan, qualification, summary] if: always() && github.event_name == 'pull_request_target' && needs.plan.result == 'success' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 10 permissions: contents: read diff --git a/.github/workflows/llama-upgrade.yml b/.github/workflows/llama-upgrade.yml index cbd65678..a1c7520a 100644 --- a/.github/workflows/llama-upgrade.yml +++ b/.github/workflows/llama-upgrade.yml @@ -226,7 +226,7 @@ jobs: publish: needs: [candidate, candidate_ci, candidate_families, independent_ci, independent_families] if: needs.candidate.outputs.changed == 'true' - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 30 steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 759cfe0e..8d81d807 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -3,7 +3,7 @@ on: pull_request_target: types: [opened, synchronize, reopened, ready_for_review] workflow_run: - workflows: [CI, Documentation, CI images, Inference qualification] + workflows: [CI, CI PR, Documentation, Documentation PR, CI images, CI images PR, Inference qualification] types: [in_progress, completed] check_run: types: [created, completed] @@ -25,7 +25,7 @@ jobs: github.event_name == 'pull_request_target' || github.event_name == 'check_run' || github.event_name == 'status' || contains(fromJSON('["pull_request", "pull_request_target"]'), github.event.workflow_run.event) - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 5 steps: # Only protected code runs with the status-writing token. No candidate code, @@ -35,6 +35,10 @@ jobs: ref: main persist-credentials: false - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + DEPOT_RUNNERS_ENABLED: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED }} with: script: | - await require('./.github/scripts/pr-checks.cjs')({ github, context, core }); + await require('./.github/scripts/pr-checks.cjs')({ + github, context, core, depot: process.env.DEPOT_RUNNERS_ENABLED === 'true' + }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4050cfb4..cfd5529a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: if: github.repository == 'Mesh-LLM/skippy' && github.ref == 'refs/heads/main' permissions: contents: write - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 outputs: tag: ${{ steps.admit.outputs.tag }} @@ -88,7 +88,7 @@ jobs: JIANYANG_INFERENCE_SSH_KEY: ${{ secrets.JIANYANG_INFERENCE_SSH_KEY }} verify: needs: [admission, validation, inference, documentation_validation] - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 60 steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 @@ -116,7 +116,7 @@ jobs: needs: [admission, verify] if: ${{ !inputs.canary }} environment: release - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 60 permissions: contents: write @@ -221,7 +221,7 @@ jobs: run: gh release edit "$RELEASE_TAG" --draft=false --prerelease="$PRERELEASE" documentation: needs: [admission, publish] - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 @@ -232,7 +232,8 @@ jobs: - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version: '22.23.0' - cache: npm + cache: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED != 'true' && 'npm' || '' }} + package-manager-cache: false cache-dependency-path: docs-site/package-lock.json - name: Install pinned documentation tooling run: just docs-install @@ -249,7 +250,7 @@ jobs: if: ${{ !cancelled() && needs.verify.result == 'success' && (inputs.canary || needs.documentation.result == 'success') }} permissions: contents: write - runs-on: ubuntu-24.04 + runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 10 steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 diff --git a/ci/README.md b/ci/README.md index 0e402060..83ba6052 100644 --- a/ci/README.md +++ b/ci/README.md @@ -6,8 +6,8 @@ require the full workflow result independently of the check name. The single required status is `PR checks`, the aggregate of all applicable PR workflows, checks and statuses. -`pr-checks.yml` evaluates that aggregate on a standard GitHub-hosted -`ubuntu-24.04` runner, using protected-main code and no Rust setup, candidate +`pr-checks.yml` evaluates that aggregate on the selected Ubuntu runner, using +protected-main code and no Rust setup, candidate execution, model inputs or lab credentials. It re-evaluates on PR events and producer workflow starts/completions, including reruns. Failed, cancelled, timed-out and startup-failed runs fail the gate; queued/running or missing @@ -110,21 +110,81 @@ produced by the protected-main llama upgrade workflow. `targets.json` defines four hosts and eleven runtimes. Three hosts and eight runtimes are active. Windows qualification and publication are deferred. After the quality and automation canary, each CPU job builds, packages and tests its -runtime on GitHub-hosted `ubuntu-24.04`, `ubuntu-24.04-arm` or `macos-15`. Each +runtime on the selected Ubuntu x64, Ubuntu ARM64, or macOS ARM64 runner. Each also produces the shared CLI for its platform. Linux x64 builds the shared CLI on Ubuntu 24.04 for compatibility with the CUDA toolchain images. Each backend job waits for its matching CPU job only. Linux x64 CUDA 12 and Linux ARM64 -CUDA 12 and 13 run on GitHub-hosted Ubuntu in the corresponding compiler images +CUDA 12 and 13 run on Ubuntu in the corresponding compiler images and check the packaged CLI and runtime artifact without a device. Linux x64 CUDA 13 and macOS Metal run device smoke on ephemeral JY runners. Tagged releases add device smoke for the other three CUDA packages using their exact archives. JY hardware jobs declare literal runner groups and labels. The full CI gate matches all package jobs to the plan and checks required device results. +### Depot runners + +The repository Actions variable `SKIPPY_DEPOT_RUNNERS_ENABLED=true` selects +Depot for every job that otherwise uses a GitHub-hosted runner. This includes +PR validation and its aggregate, code and package CI, compiler images and +publishing, documentation and deployment, release validation and publication, +the inference controllers, and the llama upgrade publisher. The Linux jobs +use four-core Ubuntu 24.04 runners of the existing architecture, and the +macOS CPU package uses Depot's macOS 15 ARM64 runner. Device jobs use their +specified JY groups. Clearing the variable or setting it to `false` restores +GitHub-hosted placement and direct PR workflow routing for subsequent runs. +[Depot runner labels](https://depot.dev/docs/github-actions/runner-types) + +The Depot runner group admits Skippy and uses exact protected workflow refs. +Allow these entries alongside the existing approved workflows: + +```text +Mesh-LLM/skippy/.github/workflows/ci.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/ci-images.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/ci-image-builds.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/docs.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/inference.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/llama-upgrade.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/pr-checks.yml@refs/heads/main +Mesh-LLM/skippy/.github/workflows/release.yml@refs/heads/main +``` + +With Depot enabled, `ci-pr.yml`, `ci-images-pr.yml`, and `docs-pr.yml` retain +GitHub's ordinary PR triggers and call their runner-owning workflows from +protected `main` without forwarding secrets. The image dispatcher enters +through `ci.yml`, which calls the read-only image builders at its protected +revision. The same builders supply exact artifacts for the image publishers. +The CI dispatcher requests `cache-mode: read` for sccache. The image and docs +dispatchers request `cache-mode: none`. All retain GitHub's fork-run approval +policy. +Same-repository PRs to main continue to use the protected `ci.yml` path for +code and native admission. The PR controller expects the producer for the +active route. Refresh affected open PRs with a new PR event after cutover so +their selected workflows run against the current head. + +Depot routes sccache's GitHub Actions backend to its repository-wide cache. +sccache writes only when building the exact protected `main` commit on push, +schedule, or manual dispatch with a write-capable job cache mode. PR and other +branch builds use `SCCACHE_GHA_RW_MODE=READ_ONLY`. Ordinary Depot jobs skip +shared Cargo, model, native source, and npm caches. +[Actions cache behavior](https://depot.dev/docs/cache/integrations/github-actions) +· [sccache Actions backend](https://github.com/mozilla/sccache/blob/main/docs/GHA.md) + +Leave `SKIPPY_DEPOT_RUNNERS_ENABLED` unset while merging the workflows and +configuring their runner-group refs. Add `ci-image-builds.yml` once it exists +on `main`. Dispatch `CI` on `main` with `profile=sccache` while the switch is +off. Check that the first Depot job writes a compiler cache entry and the +second job records one cache hit, one deliberate miss, and zero writes. + +After enabling the switch, verify full CI and `CI images` with +`build_only=true`, then check one ordinary PR and one same-repository PR +through the aggregate. + +### PR admission and quality + Same-repository PRs to `main` use the workflow definition on protected `main`. The workflow verifies repository identity, the PR author's write access and the exact candidate SHA before running candidate code. The ordinary PR workflow -runs approved forks on GitHub-hosted runners. Changes requiring native hardware +runs approved forks on the selected ephemeral runner. Changes requiring native hardware stay blocked until an isolated native runner path is available. Restrict each Skippy lab runner group to the protected workflow references @@ -137,7 +197,7 @@ Mesh-LLM/skippy/.github/workflows/release.yml@refs/heads/main Mesh-LLM/skippy/.github/workflows/llama-upgrade.yml@refs/heads/main ``` -The CPU-only `quality` job runs on GitHub-hosted `ubuntu-24.04` inside +The CPU-only `quality` job runs on Ubuntu 24.04 inside `ghcr.io/mesh-llm/skippy-ci-cpu:latest` for lint, tests and FFI binding freshness. The image supplies the pinned Rust toolchain, Just, sccache, build-essential, mold and LLVM/Clang 22 development inputs. The job verifies diff --git a/ci/image-targets.json b/ci/image-targets.json new file mode 100644 index 00000000..f4393110 --- /dev/null +++ b/ci/image-targets.json @@ -0,0 +1,34 @@ +{ + "include": [ + { + "backend": "cuda12", + "arch": "amd64", + "toolkit_version": "12.9.2", + "toolkit_base": "nvidia/cuda:12.9.2-devel-ubuntu24.04@sha256:420850a3fd665171b3f1fd08946c51d50468d732a46d6c42345ea04444755048" + }, + { + "backend": "cuda12", + "arch": "arm64", + "toolkit_version": "12.9.2", + "toolkit_base": "nvidia/cuda:12.9.2-devel-ubuntu24.04@sha256:fd13aa4b2b769b9ffece066fbf6ca7cf733509f85fef4b5e432fe7c0b5782f70" + }, + { + "backend": "cuda13", + "arch": "amd64", + "toolkit_version": "13.1.2", + "toolkit_base": "nvidia/cuda:13.1.2-devel-ubuntu24.04@sha256:952e42d23230610a2714c8484f38e9c934ed68e6f9c9c7fac62dcd5f98858a6e" + }, + { + "backend": "cuda13", + "arch": "arm64", + "toolkit_version": "13.1.2", + "toolkit_base": "nvidia/cuda:13.1.2-devel-ubuntu24.04@sha256:369b61cfc40a36830d246f0a14004a716aee72f4c520ee719b73d2b47e8bd9ce" + }, + { + "backend": "rocm", + "arch": "amd64", + "toolkit_version": "7.2.4", + "toolkit_base": "rocm/dev-ubuntu-24.04:7.2.4@sha256:bdc8e61026cbb844ede93d44d2c50055f51ebb2041906b60182bf3bee3139054" + } + ] +} diff --git a/ci/sccache-smoke.just b/ci/sccache-smoke.just new file mode 100644 index 00000000..9e615563 --- /dev/null +++ b/ci/sccache-smoke.just @@ -0,0 +1,3 @@ +[positional-arguments] +run phase: + @bash ../scripts/ci-sccache-smoke.sh "$1" diff --git a/scripts/ci-sccache-smoke.sh b/scripts/ci-sccache-smoke.sh new file mode 100644 index 00000000..be021058 --- /dev/null +++ b/scripts/ci-sccache-smoke.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -euo pipefail + +phase="${1:?expected seed or read}" +case "$phase" in + seed) mode=READ_WRITE; hits=0; writes=1 ;; + read) mode=READ_ONLY; hits=1; writes=0 ;; + *) echo "Unknown sccache smoke phase $phase" >&2; exit 1 ;; +esac + +if [[ "$SCCACHE_GHA_RW_MODE" != "$mode" ]]; then + echo "Expected sccache mode $mode, got $SCCACHE_GHA_RW_MODE" >&2 + exit 1 +fi + +work_dir="$GITHUB_WORKSPACE/target/sccache-smoke" +mkdir -p "$work_dir" +cd "$work_dir" + +compile() { + printf 'int skippy_sccache_smoke(void) { return %s; }\n' "$1" > smoke.c + "$SCCACHE" cc -c smoke.c -o smoke.o + test -s smoke.o +} + +compile 1 +if [[ "$phase" == read ]]; then + # This variant was never compiled by the seed job. + compile 2 +fi + +stats=$("$SCCACHE" --show-stats --stats-format json | jq '{ + remote: (.cache_location | startswith("ghac,")), + hits: (.stats.cache_hits.counts | add // 0), + misses: (.stats.cache_misses.counts | add // 0), + writes: .stats.cache_writes, + read_errors: .stats.cache_read_errors, + write_errors: .stats.cache_write_errors +}') +echo "$stats" +jq -e --argjson hits "$hits" --argjson writes "$writes" \ + '.remote and .hits == $hits and .misses == 1 and .writes == $writes + and .read_errors == 0 and .write_errors == 0' <<< "$stats" >/dev/null