Run and lint solutions on the site
Test and publish the site / test (push) Successful in 1m23s
Test and publish the site / publish (push) Failing after 4m22s

A new admin-only solve page, /p/<name>/solve, edits a problem's code in
C++ or Python (a dropdown switches between them), runs it on custom
input or against the saved tests with per-test verdicts (AC, WA, RE,
TLE, unchecked) and compile errors, marks lint diagnostics in the
editor, and saves the code back as a commit ("Edit <name>"). Drafts
stay in the browser per problem and language until saved. LeetCode
problems are C++ only, since their tests run through driver.h.

Code never runs in the site, which holds the Claude, Gitea and S3
secrets. A separate runner service (cmd/usacorunner, Dockerfile.runner)
does it in a container meant to have no environment, an internal-only
network, a read-only root apart from /tmp, and memory, CPU and pids
limits, with tini to reap orphans. Runs copy the CLI: the same g++
flags with -DLOCAL and the repo's headers, <io>.in on disk and on
stdin, <io>.out or stdout as the output, and usaco test's comparison.
Unlike the CLI they have CPU, memory, file and wall-clock limits.

C++ lint is g++'s warnings plus clang-tidy with a new .clang-tidy
(bugprone, performance and a few readability checks; template.cpp is
clean). Python lint is a syntax check plus ruff. template.py is the
Python starter, with a stdio() helper like template.rs's.

CI builds, smoke-tests and rolls out the runner image before the site.
The web_server stack needs a usaco-runner service before that rollout
can succeed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 11:24:22 +01:00
co-authored by Claude Opus 5.5
parent 107ecab9da
commit c972fa9fd9
33 changed files with 4477 additions and 23 deletions
+34
View File
@@ -0,0 +1,34 @@
import os
import sys
# ----- FILE IO -----
# stdio("name") picks the mode from the directory it runs in, like template.rs:
# name.in exists -> read name.in, write name.out (USACO + the site's Run)
# name.in missing -> read stdin, write stdout (Codeforces submission)
# Like freopen in template.cpp, it points fds 0 and 1 at the files, so
# input(), print() and sys.stdin.buffer all follow without being swapped.
def stdio(name):
if os.path.exists(name + ".in"):
os.dup2(os.open(name + ".in", os.O_RDONLY), 0)
os.dup2(os.open(name + ".out", os.O_WRONLY | os.O_CREAT | os.O_TRUNC), 1)
# ----- INPUT -----
# Slurps the whole input (call it after stdio), then hands out tokens:
# n = int(next(tok))
# a = [int(next(tok)) for _ in range(n)]
# s = next(tok).decode()
def tokens():
return iter(sys.stdin.buffer.read().split())
def main():
stdio("problem")
tok = tokens()
t = int(next(tok))
for _ in range(t):
pass
main()