mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
* ci: port block workflows to the shared repository * ci: preserve policy self-exclusion at the root path * ci: check block documentation relative links * ci: keep the block post-merge-review check on hosted runners The job's own comment records that it ended in 'Set up job' with no log on every self-hosted runner, and the source repository ran it on ubuntu-latest. The port made it follow BLOCK_RUNNER_LABEL, so setting the variable would bring that failure back for every labelled same-repository PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: publish block releases from hosted runners The release job holds contents: write and packages: write and logs in to GHCR, and builds its images with the runner's Docker. Following BLOCK_RUNNER_LABEL put it on the persistent pool that same-repository PR test jobs also use, whose Docker and build cache those jobs can leave state in, and whose Docker setup is still listed as unvalidated. The source repository published from ubuntu-latest; keep that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: refuse a block release without notes before pushing images The notes file was first checked in the last step, after both images (and, for the highest stable tag, :alpha) were already pushed to GHCR, so a tag without docs/releases/vX.Y.Z.md left the images published and no GitHub release. Check it with the tag format, before anything is pushed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: run the block documentation link check from root scripts The Relative documentation links step called .github/scripts/doc-links-check.py and its test inside seaweed-block/, but neither the imported module nor upstream seaweed-block has them, so the unit suite would fail once the step runs. Add the checker and its test under .github/block/scripts/ with the other port scripts and point the step and its contract test there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: use the integrated root documentation link checker * ci(block): bound runner disk use and clean job workspaces * ci(block): pin merge evidence and refuse control changes * ci(block): refuse workspace aliases before cleanup * fix(block-ci): refresh test evidence before reporting readiness * block-ci: judge known bugs with the module helper; list only live reproductions The inline loop called an empty -run match or a skip a fix, and the list still named #188 (closed, test passes) and #189 (test absent), so every nightly run failed. Use known-bugs.sh and its controls, as the module workflow does, and keep only #186: #187's reproduction passes at this revision because values.yaml sets blockmaster.stateHostPath. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: let a release rerun replace the assets of a published tag gh release create fails once the tag's release exists, after both image pushes have already run again. Keep the imported helper's existing-release path: edit the prerelease flag and upload with --clobber. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: list both sides of a move when planning unit packages Without --no-renames a file moved out of core/storage/ shows only its new path, so the planner skipped the package it left. The sibling scope scripts already pass the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: give each master push its own Block Test concurrency group A group admits one running and one pending run; a newer push cancels the pending one even with cancel-in-progress off, so a burst of merges left some without a post-merge result. Key pushes on the commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: refuse only control changes the PR itself makes The two-dot diff against current master listed every block workflow master changed after the PR branched, so an older docs-only PR hit workflow_review_required for good. Diff from the merge base; the gate already requires the tested base to be current master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: check host paths in a labelled post-merge-review PR The changed-path list holds module paths and block controls only, so a labelled PR that also changed host files passed on its module part. Add every other changed path with its root name; the allow list refuses it. The spec-trace scope stays module-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: keep the public-text adapter in step with the module checker The root adapter carried the v1.1.0 signatures: it passed /home/<user>/ paths and run metadata, and an empty docs/spec/**/recorded-* artifact, which the module checker refuses. Take the module's pattern and artifact path check, keep module-relative paths, skip the root adapter's own pattern when run from the root, and run the module self-test against the adapter so the two cannot drift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: match doc links per paragraph, with nested parentheses and long fences A link whose label wraps onto the next line was never checked, a target such as guide(v2).md was cut at its first ')', and a three-backtick line inside a four-backtick fence closed it. Close a fence only with the same character at least as long, keep one level of balanced parentheses in a destination, and match links over each paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: test the root wiring the active workflows use The nested self-tests read the module's inactive test.yml, deploy/ Dockerfiles and chunkstore-scope.sh. Assert the docs-only gates in block-test.yml, that each root image refuses every binary it builds, and that the root classifier selects run for chunkstore, storage and durable edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: refuse host files in a labelled PR outside the allow list Host paths went through the module allow list, where "*_test.go", "*.md" and "docs/*" also match root files, so a labelled PR changing weed/example_test.go or README.md passed. List host changes separately and fail on any of them; the module list still runs. The port test now runs the step in a scratch repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * block-ci: keep root block CI files clean under the public-text scan The port test fixture spelled out a recorded-artifact path, and the unit group test a pid literal, so the checker flagged both as added lines of any PR that touches them. Build the fixture path from parts, name the pid through a variable, and scan the root block CI files with the checker's own pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block-ci): normalize artifact paths from both checker entry points * fix(block-ci): refuse ambiguous merge bases in readiness checks * fix(block-ci): mask code spans that wrap lines before matching links Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block-ci): publish the draft a rerun of block-release finds An interrupted first run can leave the tag with an unpublished draft. The rerun took the existing-release branch, replaced the assets and exited 0 with the release still a draft. Publish after the uploads, keeping it off the repository's Latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(block-ci): require complete matching code-span delimiters * fix(block-ci): preserve escapes and context when masking code * fix(block-ci): preserve original link destination bytes * fix(block-ci): validate original destination syntax * test(block-ci): cover masked whitespace in reference destinations --------- Co-authored-by: pingqiu <pingqiu@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
5.2 KiB
Python
124 lines
5.2 KiB
Python
"""Run the three default unit groups concurrently on the current runner.
|
|
|
|
Usage: run-unit-groups.py PLAN_DIR EVIDENCE_DIR TMP_DIR RECORDER [RECORDER_ARG ...]
|
|
The recorder accepts OUTPUT followed by go-test flags and packages. Each group
|
|
owns its logs/events; they are combined only after all group processes exit.
|
|
"""
|
|
from contextlib import ExitStack
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import signal
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
|
|
def stop(_signum, _frame):
|
|
raise KeyboardInterrupt
|
|
|
|
|
|
def terminate(processes):
|
|
for process in processes:
|
|
try:
|
|
if os.name == "posix": os.killpg(process.pid, signal.SIGTERM)
|
|
elif process.poll() is None: process.terminate()
|
|
except ProcessLookupError:
|
|
pass
|
|
if os.name == "posix":
|
|
# The leader may exit on TERM while its descendants remain in the group.
|
|
# Bound the grace period by group lifetime, never by leader lifetime.
|
|
deadline = time.monotonic() + 5
|
|
remaining = list(processes)
|
|
while remaining and time.monotonic() < deadline:
|
|
alive = []
|
|
for process in remaining:
|
|
process.poll() # Reap an exited leader without forgetting its PGID.
|
|
try:
|
|
os.killpg(process.pid, 0)
|
|
alive.append(process)
|
|
except ProcessLookupError:
|
|
pass
|
|
remaining = alive
|
|
if remaining: time.sleep(.05)
|
|
for process in remaining:
|
|
try: os.killpg(process.pid, signal.SIGKILL)
|
|
except ProcessLookupError: pass
|
|
for process in processes:
|
|
try:
|
|
process.wait(timeout=5)
|
|
except subprocess.TimeoutExpired:
|
|
process.kill()
|
|
process.wait(timeout=5)
|
|
|
|
|
|
|
|
def run(plan, evidence, temp, recorder):
|
|
groups = {g: (plan / (g + ".txt")).read_text().splitlines() for g in ("g1", "g2", "g3")}
|
|
evidence.mkdir(parents=True, exist_ok=True)
|
|
started = time.monotonic()
|
|
processes, results, times = {}, {}, {}
|
|
with ExitStack() as files:
|
|
try:
|
|
for group, packages in groups.items():
|
|
results[group] = {"packages": len(packages), "status": 0, "elapsed_seconds": 0}
|
|
if not packages:
|
|
print(f"{group}: no packages selected by scope", flush=True)
|
|
continue
|
|
out = evidence / group; out.mkdir(parents=True, exist_ok=True)
|
|
scratch = temp / group; scratch.mkdir(parents=True, exist_ok=True)
|
|
# /proc/self/fd exposes resolved paths; preserve fixture identity even
|
|
# when the runner temp directory is a symlink to its data disk.
|
|
scratch = scratch.resolve(strict=True)
|
|
log = files.enter_context((out / "console.log").open("w", encoding="utf-8"))
|
|
command = recorder + [str(out / "go-test.json"), "-p=" + ("4" if group == "g3" else "1"), "-short", "-count=1", "-timeout", "20m", *packages]
|
|
times[group] = time.monotonic()
|
|
processes[group] = subprocess.Popen(command, stdout=log, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL,
|
|
env=dict(os.environ, TMPDIR=str(scratch)), start_new_session=os.name == "posix")
|
|
print(f"{group}: started {len(packages)} packages", flush=True)
|
|
remaining = set(processes)
|
|
while remaining:
|
|
for group in tuple(remaining):
|
|
status = processes[group].poll()
|
|
if status is not None:
|
|
results[group]["status"] = status
|
|
results[group]["elapsed_seconds"] = round(time.monotonic() - times[group], 3)
|
|
remaining.remove(group)
|
|
if remaining: time.sleep(.05)
|
|
except BaseException:
|
|
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
terminate(processes.values())
|
|
raise
|
|
for group in processes:
|
|
print(f"--- {group} ---", flush=True)
|
|
print((evidence / group / "console.log").read_text(errors="replace"), flush=True)
|
|
summary = {"elapsed_seconds": round(time.monotonic() - started, 3), "groups": results}
|
|
try:
|
|
(evidence / "unit-groups.json").write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8")
|
|
with (evidence / "go-test.json").open("ab") as combined:
|
|
for group in processes:
|
|
events = evidence / group / "go-test.json"
|
|
if events.exists(): combined.write(events.read_bytes())
|
|
except OSError as error:
|
|
print(f"test evidence unavailable: {error}", file=sys.stderr)
|
|
print(json.dumps(summary), flush=True)
|
|
return int(any(r["status"] != 0 for r in results.values()))
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) < 5:
|
|
print(__doc__.strip(), file=sys.stderr)
|
|
return 2
|
|
signal.signal(signal.SIGTERM, stop)
|
|
try:
|
|
return run(Path(argv[1]), Path(argv[2]), Path(argv[3]), argv[4:])
|
|
except KeyboardInterrupt:
|
|
return 130
|
|
except (OSError, ValueError) as error:
|
|
print(f"unit groups: {error}", file=sys.stderr)
|
|
return 2
|
|
|
|
|
|
if __name__ == "__main__": sys.exit(main(sys.argv))
|