oclapi2: one unattended command that runs the PR checks in an isolated local stack and cleans up after itself
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- docker, docker-compose, elasticsearch, github-actions, postgresql, python
- 领域
- devops, infrastructure, testing
调研方向
Read .github/workflows/pr.yml, docker-compose.ci.yml, coverage.sh, and AGENTS.md to trace the current CI commands, service setup, and local instructions. Start by comparing the workflow steps with the acceptance criteria, then identify how the gate can run them against the mounted worktree and clean up its isolated stack. Done means the command, fast module form, safe cleanup, and updated AGENTS.md meet the listed criteria.
由索引模型根据 Issue 内容生成。
描述
Why
To run oclapi2's PR checks locally you need a Postgres and Elasticsearch stack and a ~21 GB image, and a full run takes up to ~45 minutes. AGENTS.md tells an agent to docker exec into the developer's running oclapi2-api-1 container. That's fine with a person at the keyboard, but not for an agent session working a ticket unattended in its own git worktree:
- Wrong code under test. The shared container runs another checkout's code, so the tests don't exercise the worktree's change.
- Shared state. Two sessions at once share one database and one set of search indexes.
- No cleanup. Nothing removes what a session started.
The FHIR work (OpenConceptLab/ocl_online#451) has run the checks by hand with a five-command docker compose recipe. The recipe works, but it is copied by hand, and it never cleans up: dozens of leftover gate volumes sit on the shared dev Mac now.
This ticket adds one command to this repo that runs the checks unattended and safely, so that agent sessions can take oclapi2 tickets end to end. ocl_issues#2883 is waiting on it.
What the command must do
-
One command, no prompts.
- It runs from any worktree and needs no TTY.
- It exits non-zero on any failure.
- It ends with a one-line summary and prints where the coverage report is.
- A fast form runs one module's tests (e.g.
core.fhir) for the edit-and-test loop.
-
It runs what
.github/workflows/pr.ymlruns, in the same order and with the same environment. As of4b331a0b, that's:pylint -j0 core/;manage.py search_index --create;- the tests without the
estag, withTEST_ES=offand--parallel=4; - the
es-tagged tests, with--parallel=1; coverage combine, thencoverage report --include=core/* --fail-under=97;- all with
ENVIRONMENT=ci,PYTHONHASHSEED=2andCOVERAGE_CORE=sysmon.
pr.ymlchanged three times on Oct 26, so a copy of its commands would drift. Eitherpr.ymland the gate call one shared script, or a test fails when their commands differ.coverage.shcould become that script, but today it's out of date: one serial run with a 95% minimum. -
It tests the worktree's own code. It bind-mounts the current directory, as
docker-compose.ci.ymlalready does. It neverdocker execs into another stack, and never re-tags a shared image from one worktree's build. -
It's isolated.
- Its own compose project,
oclapi2-gate-<name>, and nocontainer_name:. - No host ports: it uses
run --rm. - Service images pinned to CI's:
postgres:14.7andelasticsearch:8.15.2. - It waits on health checks, not sleeps.
- On OrbStack, it runs
orb startfirst.
- Its own compose project,
-
It cleans up. It runs
down -vwhen it finishes, pass or fail. A separate cleanup command removes stacks that a crash left behind. That command:- matches only a label the gate puts on its own stacks, never the
oclapi2-*name prefix; - never touches a volume labeled
ocl.keep=true(seeded content that takes hours to rebuild), or the developer's ownoclapi2andoclapi2-api-*projects; - never runs machine-wide (no
docker system pruneordocker volume prune).
- matches only a label the gate puts on its own stacks, never the
-
No secrets and no outside services. It reads no
.envand no~/.ocl, and makes no calls to staging or production. Compose reads a.envin the project directory by default, so the gate has to turn that off. -
It shares the image. It uses the dependency-only arm64 image
oclapi2-local:deps-<hash>, where<hash>is the first 12 hex digits of sha256(requirements.txt+Dockerfile), and builds it only when it's missing.- The build script that exists today moves into this repo, with the same tag formula, so existing images and their other users keep working.
- The image has no
ENVIRONMENT=ciand no test-only entrypoint baked in. The gate sets them, so the same image can also run a long-lived local API.
-
It doesn't compete for memory.
- It refuses to start while a corpus seed is loading the local stack, for example by checking a lock file the seed holds.
- It never runs pylint and the tests at the same time: the ES tests flake under load.
Docs: add a "Run the checks unattended" section to AGENTS.md. The docker exec advice can stay for interactive work, but unattended sessions use the gate. The same edit fixes the PR base branch: AGENTS.md says to branch from develop (GitFlow), but only master exists.
Acceptance criteria
- A full run on a warm image passes on
master's head in about 45 minutes or less, and agrees with CI on the same commit: the same pass or fail, and coverage within 0.1%. - The fast form runs a single module.
- Gates on two worktrees at once share no database, index or container, and both clean up.
- A run killed halfway leaves a stack that the cleanup command removes. A test shows the cleanup leaves
ocl.keep=truevolumes and other projects alone. - A change to a
pr.ymltest step either reaches the gate as well (shared script) or fails a test. - The
AGENTS.mdsection is written, and its base branch is corrected.
Out of scope
- The long-lived local API and the FHIR parity tooling from ocl_online#451. They reuse the image and nothing else.
- Changing what CI checks.
- 主要语言
- 没有语言数据
- 星标
- 4
- 派生
- 2
- 平均合并
- 2 小时 12 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenConceptLab/ocl_issues 的其他 Issue
-
component/fhir type/bug
难度 2/5 1-3 小时 新手友好度 82/100
OpenConceptLab/ocl_issues#3026 ·
-
component/api decision/human-review signal/needs-access signal/quick-win signal/small-scope signal/well-specified stage/triaged type/bug
难度 2/5 1-3 小时 新手友好度 72/100
OpenConceptLab/ocl_issues#3012 · 2 条评论 ·
-
component/design-system decision/ai-ready signal/low-risk signal/quick-win signal/small-scope signal/well-specified stage/triaged type/docs
难度 2/5 半天 新手友好度 70/100
OpenConceptLab/ocl_issues#2983 · 1 条评论 ·
-
component/mapper decision/ai-ready signal/low-risk signal/quick-win signal/small-scope signal/well-specified stage/triaged type/bug
难度 2/5 1-3 小时 新手友好度 78/100
OpenConceptLab/ocl_issues#2966 · 2 条评论 ·
-
component/mapper component/web decision/human-review signal/low-risk signal/needs-human signal/quick-win signal/small-scope signal/well-specified stage/triaged type/bug
难度 2/5 1-3 小时 新手友好度 76/100
OpenConceptLab/ocl_issues#2920 · 1 条评论 ·
查看 OpenConceptLab/ocl_issues 的全部 Issue
相似的 Issue
-
bug linux
难度 2/5 1-3 小时 新手友好度 74/100
hiddify/hiddify-app#2535 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 91/100
unicef/adt-studio#1112 ·
维护者通常 2 天内回复
-
approved-direction kind/documentation stage/010-actionable triage/accepted
难度 2/5 1-3 小时 新手友好度 84/100
projectbluefin/testsuite#1173 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
kubernetes-sigs/aws-iam-authenticator#1125 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
stfc/qiskit-machine-learning#1092 ·
维护者通常 4 天内回复