Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a22e907
ci: use local caches on self-hosted runners
kixelated Oct 20, 2026
aaedc05
ci: make the merge-queue runner configurable
kixelated Oct 20, 2026
f6fddbf
ci: refuse non-queue jobs on persistent local caches
kixelated Oct 20, 2026
31aeaf3
Merge remote-tracking branch 'origin/main' into ci/local-cache
kixelated Oct 20, 2026
33738fc
ci: provide a reusable persistent runner VM
kixelated Oct 20, 2026
afaf35f
docs: reference the evaluated host through flake self
kixelated Oct 20, 2026
fb6c069
ci: allow the runner to lock 64 MiB for ring tests
kixelated Oct 20, 2026
c5ab968
style(ci): format the runner integration test
kixelated Oct 20, 2026
a9b7f84
ci: support isolated runner VMs for multiple repositories
kixelated Oct 20, 2026
05e88f2
fix(ci): reject spoofed guest replies and conflicting host NAT
kixelated Oct 20, 2026
fa3eb94
Merge origin/main and keep runner checks in nightly CI
kixelated Oct 20, 2026
6d80a01
docs(ci): clarify hosted and persistent queue cache behavior
kixelated Oct 20, 2026
07d5a26
Merge origin/main and preserve hosted R2 caches
kixelated Oct 20, 2026
08a049c
test(ci): cover local and hosted R2 cache selection
kixelated Oct 20, 2026
6f39914
fix(ci): restart persistent runner VMs after unexpected exits
kixelated Oct 20, 2026
7fe7b1f
docs(ci): require external workflow approvals before public runner re…
kixelated Oct 20, 2026
98eb702
Merge remote-tracking branch 'origin/main' into ci/local-cache
kixelated Oct 20, 2026
0d89b96
fix(ci): preserve host networking around runner VMs
kixelated Oct 20, 2026
b69acf6
Merge origin/main and retain queue-only runner routing
kixelated Oct 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/actions/rust-cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Rust cache
description: Install mbx, put its Cargo shim on PATH, and back it with the R2 build cache that `main` and its merge queue write.
description: Install mbx and its Cargo shim, using local storage in runner VMs and R2 on hosted runners.

inputs:
access-key-id:
Expand All @@ -12,6 +12,13 @@ inputs:
runs:
using: composite
steps:
- name: Require merge queue on self-hosted runners
if: runner.environment == 'self-hosted' && github.event_name != 'merge_group'
shell: bash
run: |
echo "::error::Persistent self-hosted caches require a merge_group job." >&2
exit 1

# Runs on `main` and in its merge queue write; everything else reads. A
# queued pull request is about to become `main`, so its code is trusted
# like `main`'s, and publishing from the queue keeps the cache current
Expand All @@ -28,6 +35,7 @@ runs:
# building on would leave every reader cold with nothing to say why. Half
# a pair is a broken secret on any job, never a fork's empty one.
- name: Cache credentials
if: runner.environment != 'self-hosted'
shell: bash
env:
KEY_ID: ${{ inputs.access-key-id }}
Expand Down Expand Up @@ -70,7 +78,7 @@ runs:
- uses: jdx/mr-boxington-action@47ce49b32025d93a7a2f4570815afaa2b7092240 # v1.7.2
with:
version: 1.25.0
backend: ${{ inputs.access-key-id != '' && inputs.secret-access-key != '' && 'remote' || 'local' }}
backend: ${{ runner.environment != 'self-hosted' && inputs.access-key-id != '' && inputs.secret-access-key != '' && 'remote' || 'local' }}
remote-url: s3://mbx-moq-dev
namespace: ${{ runner.os }}-${{ runner.arch }}

Expand All @@ -80,7 +88,7 @@ runs:
# come out read-write, or nothing would publish and every reader would
# drift cold unnoticed.
- name: Check the cache
if: inputs.access-key-id != '' && inputs.secret-access-key != ''
if: runner.environment != 'self-hosted' && inputs.access-key-id != '' && inputs.secret-access-key != ''
shell: bash
run: |
report=$(mbx doctor --json || true)
Expand Down
4 changes: 4 additions & 0 deletions .github/justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set working-directory := '..'

# Build and test the persistent NixOS runner VM on x86_64 Linux.
runner-vm:
nix build --no-link .#checks.x86_64-linux.github-runner-vm .#checks.x86_64-linux.github-runner-vm-image .#checks.x86_64-linux.github-runner-vm-config --print-build-logs

# Lint GitHub Actions workflows, their alert coverage, and that every step runs a recipe.
check:
actionlint
Expand Down
67 changes: 0 additions & 67 deletions .github/workflows/cache.yml

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
# A close/merge run exists only to cancel the superseded in-flight build via
# the concurrency group above.
if: github.event.action != 'closed' && (github.event_name != 'pull_request' || github.base_ref == 'release')
runs-on: ubuntu-24.04-arm
# Leave the variable unset until the local runner is online and verified.
runs-on: ${{ github.event_name == 'merge_group' && vars.MOQ_QUEUE_RUNNER || 'ubuntu-24.04-arm' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce trusted routing outside PR-controlled workflows

When this persistent runner is registered to the public MoQ repository, a pull request can modify or add a workflow that targets the runner's default self-hosted label, bypassing this event expression entirely. The fresh evidence beyond the earlier cache finding is that the new refusal exists only inside .github/actions/rust-cache, so the attacker-controlled job can omit that action and directly poison the persistent mbx state later consumed by merge-group jobs. Restrict assignment outside PR-controlled YAML, such as with a runner group limited to a trusted workflow/ref, or do not attach this persistent runner to the public repository.

AGENTS.md reference: AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: PR-controlled event guards do not constrain runner assignment. Public registration and queue routing remain disabled. The consuming host now refuses registration unless GitHub requires approval for all external contributor workflows, and the shared setup guide documents that policy and the need to review code before approving execution. The maintainer has not yet approved changing the repository policy, so this PR is draft pending that decision.

(written by GPT-6)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maintainer approved the external workflow approval policy, and the repository setting now reads all_external_contributors. Registration also checks that policy outside PR-controlled YAML and refuses to proceed if it differs. PR checks remain GitHub-hosted; the persistent runner is selected only for merge groups. Maintainers must inspect any workflow and code before approving external execution. The runner remains unregistered and MOQ_QUEUE_RUNNER unset until the host passes deployment verification.

(written by GPT-6)

# `main` and its merge queue write the Rust cache; see .github/actions/rust-cache.
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/gh-readonly-queue/main/')) && 'cache-write' || '' }}
# Backstop a hang instead of holding the runner for the 6-hour default.
Expand All @@ -58,7 +59,7 @@ jobs:
CI_BASE: ${{ github.base_ref == 'release' && '--all' || github.event.merge_group.base_sha }}

- uses: ./.github/actions/nix
if: steps.scope.outputs.needed == 'true'
if: steps.scope.outputs.needed == 'true' && runner.environment != 'self-hosted'
- uses: DeterminateSystems/flake-checker-action@786422608c7bded2bbc9741ad9f91356842bf520 # main
if: steps.scope.outputs.needed == 'true'

Expand Down Expand Up @@ -88,7 +89,8 @@ jobs:
test:
name: Test
if: github.event.action != 'closed' && (github.event_name != 'pull_request' || github.base_ref == 'release')
runs-on: ubuntu-24.04-arm
# Leave the variable unset until the local runner is online and verified.
runs-on: ${{ github.event_name == 'merge_group' && vars.MOQ_QUEUE_RUNNER || 'ubuntu-24.04-arm' }}
# `main` and its merge queue write the Rust cache; see .github/actions/rust-cache.
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/gh-readonly-queue/main/')) && 'cache-write' || '' }}
timeout-minutes: 60
Expand All @@ -112,7 +114,7 @@ jobs:
CI_BASE: ${{ github.base_ref == 'release' && '--all' || github.event.merge_group.base_sha }}

- uses: ./.github/actions/nix
if: steps.scope.outputs.needed == 'true'
if: steps.scope.outputs.needed == 'true' && runner.environment != 'self-hosted'

# Reads and writes like the `check` job above.
- name: Rust cache
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ concurrency:
cancel-in-progress: true

jobs:
runner-vm:
uses: ./.github/workflows/runner-vm.yml

# The path-filtered gates main PRs skip; release PRs still run them.
x11:
uses: ./.github/workflows/x11.yml
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/runner-vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Runner VM

on:
workflow_call:
pull_request:
branches: [release]
types: [opened, synchronize, reopened, edited, closed]
paths:
- "nix/**"
- "flake.nix"
- "flake.lock"
- ".github/justfile"
- ".github/workflows/runner-vm.yml"

permissions:
contents: read

concurrency:
group: runner-vm-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
if: github.event.action != 'closed'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/just
- uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main
with:
determinate: false
- run: just gh runner-vm
6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
{
nixosModules = {
moq-relay = import ./nix/modules/moq-relay.nix;
github-runner-vm = import ./nix/modules/github-runner-vm.nix;
};

overlays.default = import ./nix/overlay.nix { inherit crane; };
Expand Down Expand Up @@ -661,7 +662,10 @@
test -f "${overlayPkgs.moq-boy.src}/rs/moq-video/src/frame/nv12_resize.ptx"
touch "$out"
'';
};
}
// pkgs.lib.optionalAttrs (system == "x86_64-linux") (
import ./nix/runner/checks.nix { inherit pkgs; }
);
}
);
}
Loading