Skip to content

Commit 31f7dd5

Browse files
Merge remote-tracking branch 'origin/main' into fix/thread-citation-unavailable
2 parents 1af0e43 + c3309ca commit 31f7dd5

897 files changed

Lines changed: 38342 additions & 9077 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Server CI
2+
description: Run the server suite on a hosted shard or an isolated Linux worker.
3+
inputs:
4+
shard:
5+
description: Optional Vitest shard, such as 1/8
6+
default: ""
7+
max-workers:
8+
description: Optional Vitest worker limit
9+
default: ""
10+
runs:
11+
using: composite
12+
steps:
13+
- uses: ./.github/actions/setup-ci-deps
14+
- name: Setup Rust
15+
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
16+
with:
17+
toolchain: stable
18+
- name: Install Chromium
19+
shell: bash
20+
run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
21+
- name: Test server
22+
shell: bash
23+
env:
24+
TEST_SHARD: ${{ inputs.shard }}
25+
MAX_WORKERS: ${{ inputs.max-workers }}
26+
run: |
27+
args=()
28+
if [[ -n "$TEST_SHARD" ]]; then
29+
[[ "$TEST_SHARD" =~ ^[1-9][0-9]*/[1-9][0-9]*$ ]]
30+
args+=(--shard "$TEST_SHARD")
31+
fi
32+
if [[ -n "$MAX_WORKERS" ]]; then
33+
[[ "$MAX_WORKERS" =~ ^[1-9][0-9]*$ ]]
34+
args+=(--maxWorkers "$MAX_WORKERS")
35+
fi
36+
vp run --filter t3 test "${args[@]}"

‎.github/actions/setup-apt-mirrors/action.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ runs:
55
steps:
66
- shell: bash
77
run: |
8-
# Replace the existing Blacksmith mirror list as well as direct sources.
98
printf '%s\tpriority:%s\n' \
109
https://archive.ubuntu.com/ubuntu 1 \
1110
https://mirrors.edge.kernel.org/ubuntu 2 \
1211
https://mirror.math.princeton.edu/pub/ubuntu 3 \
13-
| sudo tee /etc/apt/blacksmith-ubuntu-mirrors.txt > /dev/null
12+
| sudo tee /etc/apt/ci-ubuntu-mirrors.txt > /dev/null
1413
1514
# APT's mirror transport retries each file against the next server.
1615
sudo find /etc/apt -maxdepth 2 -type f \( -name '*.list' -o -name '*.sources' \) \
1716
-exec sed -i -E \
18-
's#https?://(([^/]+\.)?archive|security)\.ubuntu\.com/ubuntu/?#mirror+file:/etc/apt/blacksmith-ubuntu-mirrors.txt#g' {} +
17+
's#https?://(([^/]+\.)?archive|security)\.ubuntu\.com/ubuntu/?#mirror+file:/etc/apt/ci-ubuntu-mirrors.txt#g' {} +
1918
2019
# Move on to a fallback before an unreachable server exhausts the job.
2120
printf '%s\n' 'Acquire::http::Timeout "15";' 'Acquire::https::Timeout "15";' \

‎.github/actions/setup-ci-deps/action.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ runs:
8686
8787
# Filtered installs prefer the current full store, which holds every package,
8888
# over an older store of their own.
89-
# The pnpm store stays a cache tarball on the runner's own disk. A store on a
90-
# Blacksmith sticky disk mounts in under a second, but pnpm then copies every
91-
# package across filesystems instead of hard-linking it: install took 28-49s
92-
# against 9s plus an 11s restore.
89+
# Keep the pnpm store on the workspace filesystem so installs can hard-link packages.
9390
- name: Restore pnpm store
9491
id: pnpm_cache
9592
if: inputs.install == 'true'
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
"""Keep workflow runner selection on hosted pools.
2+
3+
This repository has no self-hosted runners. Pull requests from forks can propose
4+
workflow changes, and a workflow that selects a private runner would put
5+
untrusted code on hardware that holds credentials and reaches the internal
6+
network. Every `runs-on` value must name a standard GitHub-hosted image.
7+
8+
Two modes:
9+
10+
check-runner-labels.py
11+
Scan `.github/workflows/*.yml` and fail on `self-hosted` or a
12+
private-runner label (`linux-runner`, `windows-runner`,
13+
`macos-runner`, `bench-*`). Comments are ignored.
14+
15+
check-runner-labels.py --runner LABEL [--verify-runner LABEL]
16+
Validate labels passed to a reusable workflow, where the static scan
17+
cannot see through `${{ inputs.runner }}`.
18+
"""
19+
20+
import argparse
21+
import os
22+
import re
23+
import sys
24+
from pathlib import Path
25+
26+
WORKFLOWS_DIR = Path(__file__).resolve().parent.parent / "workflows"
27+
28+
# Excludes paid larger runners and third-party pools.
29+
HOSTED_LABEL = re.compile(r"^(?:ubuntu-(?:latest|22\.04|24\.04|26\.04)(?:-arm)?|macos-(?:latest|14|15|26)(?:-intel)?|windows-(?:latest|2022|2025|11-arm))$")
30+
31+
# Runner labels that name hardware this account owns. `-runner` is a stronger
32+
# signal than `-hosted`, so a label such as `linux-runner` is private by
33+
# construction; `self-hosted` is GitHub's own selector.
34+
PRIVATE_LABEL_HINT = ("self-hosted", "-runner")
35+
36+
# What the static scan looks for in workflow text: GitHub's self-hosted
37+
# selector, the private labels this repository used to have, and the `bench-*`
38+
# capacity pool. `android-emulator-runner` and other action names do not match.
39+
FORBIDDEN_REFERENCE = re.compile(
40+
r"blacksmith-[a-z0-9.-]+|self-hosted|\b(?:linux|windows|macos)-runner\b|\bbench-[a-z0-9][a-z0-9.-]*"
41+
)
42+
43+
44+
def strip_comment(line):
45+
"""Drop a trailing YAML comment without touching quoted `#` characters."""
46+
quote = None
47+
for index, char in enumerate(line):
48+
if quote:
49+
if char == quote:
50+
quote = None
51+
elif char in ("'", '"'):
52+
quote = char
53+
elif char == "#" and (index == 0 or line[index - 1] in " \t"):
54+
return line[:index]
55+
return line
56+
57+
58+
def scan_workflows(workflows_dir=WORKFLOWS_DIR):
59+
"""Return one message per workflow line that references a private runner."""
60+
problems = []
61+
paths = sorted(workflows_dir.glob("*.yml")) + sorted(workflows_dir.glob("*.yaml"))
62+
for path in paths:
63+
for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
64+
code = strip_comment(line)
65+
match = FORBIDDEN_REFERENCE.search(code)
66+
if match:
67+
problems.append(
68+
f"{path.name}:{number}: references private runner {match.group(0)!r}: "
69+
f"{code.strip()}"
70+
)
71+
return problems
72+
73+
74+
def check_label(name, label, required):
75+
"""Return a message when `label` is empty-but-required or not a hosted pool."""
76+
if not label:
77+
if required:
78+
return f"inputs.{name} is empty; this workflow needs a hosted runner label"
79+
return None
80+
if any(hint in label for hint in PRIVATE_LABEL_HINT) or not HOSTED_LABEL.match(label):
81+
return (
82+
f"inputs.{name}={label!r} is not a hosted runner label; "
83+
"use a standard GitHub-hosted Ubuntu, macOS or Windows image"
84+
)
85+
return None
86+
87+
88+
def check_labels(runner, verify_runner):
89+
"""Validate the runner inputs of a reusable workflow."""
90+
problems = [
91+
message
92+
for message in (
93+
check_label("runner", runner, required=True),
94+
check_label("verify_runner", verify_runner, required=False),
95+
)
96+
if message
97+
]
98+
return problems
99+
100+
101+
def report(message):
102+
prefix = "::error::" if os.environ.get("GITHUB_ACTIONS") else "error: "
103+
print(f"{prefix}{message}", file=sys.stderr)
104+
105+
106+
def main(argv=None):
107+
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
108+
parser.add_argument(
109+
"--runner",
110+
help="runner input of a reusable workflow; validates labels instead of scanning",
111+
)
112+
parser.add_argument(
113+
"--verify-runner",
114+
help="optional verify_runner input; empty means the workflow has no verify job",
115+
)
116+
parser.add_argument(
117+
"--workflows-dir",
118+
type=Path,
119+
default=WORKFLOWS_DIR,
120+
help=f"directory to scan (default: {WORKFLOWS_DIR})",
121+
)
122+
args = parser.parse_args(argv)
123+
124+
if args.runner is None and args.verify_runner is None:
125+
problems = scan_workflows(args.workflows_dir)
126+
checked = "workflow runner references"
127+
else:
128+
# A caller may pass neither flag through the shell, so both are checked.
129+
problems = check_labels(args.runner or "", args.verify_runner or "")
130+
checked = "runner inputs"
131+
132+
for problem in problems:
133+
report(problem)
134+
if problems:
135+
return 1
136+
print(f"All {checked} name hosted runner pools.")
137+
return 0
138+
139+
140+
if __name__ == "__main__":
141+
sys.exit(main())
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import importlib.util
2+
import tempfile
3+
import unittest
4+
from pathlib import Path
5+
6+
spec = importlib.util.spec_from_file_location(
7+
"check_runner_labels", Path(__file__).with_name("check-runner-labels.py")
8+
)
9+
labels = importlib.util.module_from_spec(spec)
10+
spec.loader.exec_module(labels)
11+
12+
13+
class ScanWorkflowsTests(unittest.TestCase):
14+
def setUp(self):
15+
self.temp = tempfile.TemporaryDirectory()
16+
self.addCleanup(self.temp.cleanup)
17+
self.workflows = Path(self.temp.name)
18+
19+
def scan(self, filename, text):
20+
(self.workflows / filename).write_text(text, encoding="utf-8")
21+
return labels.scan_workflows(self.workflows)
22+
23+
def test_accepts_hosted_pools(self):
24+
self.assertEqual(self.scan("build.yml", """
25+
jobs:
26+
build:
27+
runs-on: ubuntu-24.04
28+
verify:
29+
runs-on: windows-11-arm
30+
lint:
31+
runs-on: ubuntu-24.04-arm
32+
mac:
33+
runs-on: macos-26
34+
"""), [])
35+
36+
def test_rejects_self_hosted(self):
37+
problems = self.scan("build.yml", " runs-on: [self-hosted, linux]\n")
38+
self.assertEqual(len(problems), 1)
39+
self.assertIn("build.yml:1", problems[0])
40+
self.assertIn("self-hosted", problems[0])
41+
42+
def test_rejects_private_runner_labels(self):
43+
for label in ("linux-runner", "windows-runner", "macos-runner", "bench-32vcpu", "blacksmith-8vcpu-ubuntu-2404"):
44+
with self.subTest(label=label):
45+
self.workflows.joinpath("build.yml").unlink(missing_ok=True)
46+
problems = self.scan("build.yml", f" runs-on: {label}\n")
47+
self.assertEqual(len(problems), 1, problems)
48+
49+
def test_rejects_matrix_values(self):
50+
problems = self.scan("release.yml", """
51+
strategy:
52+
matrix:
53+
runner: [ubuntu-24.04, bench-arm64]
54+
runs-on: ${{ matrix.runner }}
55+
""")
56+
self.assertEqual(len(problems), 1)
57+
self.assertIn("bench-arm64", problems[0])
58+
59+
def test_ignores_comments_and_action_names(self):
60+
self.assertEqual(self.scan("notes.yml", """
61+
# A private runner would be self-hosted or linux-runner.
62+
jobs:
63+
emulator:
64+
runs-on: ubuntu-24.04
65+
steps:
66+
- uses: reactivecircus/android-emulator-runner@v2
67+
"""), [])
68+
69+
def test_ignores_trailing_comments(self):
70+
self.assertEqual(self.scan("build.yml", "runs-on: ubuntu-24.04 # not self-hosted\n"), [])
71+
72+
def test_strip_comment_keeps_hash_inside_quotes(self):
73+
self.assertEqual(
74+
labels.strip_comment('run: echo "a # b" # mentions linux-runner'),
75+
'run: echo "a # b" ',
76+
)
77+
78+
79+
class CheckLabelsTests(unittest.TestCase):
80+
def test_accepts_hosted_labels(self):
81+
self.assertEqual(
82+
labels.check_labels("ubuntu-24.04", "windows-2025"), []
83+
)
84+
self.assertEqual(labels.check_labels("ubuntu-24.04-arm", ""), [])
85+
86+
def test_rejects_private_labels(self):
87+
for label in ("self-hosted", "linux-runner", "bench-32vcpu", "macos-26-runner", "blacksmith-8vcpu-ubuntu-2404", "macos-15-large", "macos-15-xlarge"):
88+
with self.subTest(label=label):
89+
problems = labels.check_labels(label, "")
90+
self.assertEqual(len(problems), 1, problems)
91+
self.assertIn("inputs.runner", problems[0])
92+
93+
def test_rejects_verify_runner_on_a_private_pool(self):
94+
problems = labels.check_labels("ubuntu-24.04", "linux-runner")
95+
self.assertEqual(len(problems), 1)
96+
self.assertIn("inputs.verify_runner", problems[0])
97+
98+
def test_requires_runner_but_not_verify_runner(self):
99+
self.assertEqual(len(labels.check_labels("", "")), 1)
100+
self.assertIn("inputs.runner is empty", labels.check_labels("", "")[0])
101+
102+
103+
class MainTests(unittest.TestCase):
104+
def test_scan_mode_passes_on_the_repository_workflows(self):
105+
self.assertEqual(labels.scan_workflows(), [])
106+
107+
108+
if __name__ == "__main__":
109+
unittest.main()

0 commit comments

Comments
 (0)