mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +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>
165 lines
7.4 KiB
YAML
165 lines
7.4 KiB
YAML
name: Block spec trace
|
|
|
|
# Every PR description carries the spec trace (see the PR template); this
|
|
# check fails a PR whose description does not.
|
|
#
|
|
# pull_request_target: the workflow and the script come from the base branch,
|
|
# so a PR cannot change its own check. The PR's code is never checked out or
|
|
# run: only its commit is fetched, for the file list. The description is read
|
|
# from the event through an environment variable, never interpolated.
|
|
on:
|
|
pull_request_target:
|
|
paths:
|
|
- "seaweed-block/**"
|
|
- ".github/workflows/block-*.yml"
|
|
- ".github/block/**"
|
|
- ".github/dockerfiles/block-*.Dockerfile"
|
|
# edited: the check reads the description and the base.
|
|
types: [opened, synchronize, reopened, edited]
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: seaweed-block
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: block-spec-trace-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
trace:
|
|
name: spec trace
|
|
# The base-owned check defaults to a disposable hosted runner. Only a
|
|
# same-repository PR may opt into the registered BLOCK_RUNNER_LABEL.
|
|
runs-on: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository) && vars.BLOCK_RUNNER_LABEL || 'ubuntu-latest' }}
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Runner free space
|
|
working-directory: ${{ runner.temp }}
|
|
run: |
|
|
python3 -I - <<'PY'
|
|
import os
|
|
import shutil
|
|
import sys
|
|
required = 10_000_000_000
|
|
for path in dict.fromkeys((os.environ["GITHUB_WORKSPACE"], os.environ["RUNNER_TEMP"])):
|
|
try:
|
|
free = shutil.disk_usage(path).free
|
|
except OSError as err:
|
|
print(f"runner_disk_check_failed path={path!r} error={err}")
|
|
sys.exit(75)
|
|
if free < required:
|
|
print(f"runner_disk_low path={path!r} free_bytes={free} required_bytes={required}")
|
|
sys.exit(75)
|
|
print(f"runner_disk_ok path={path!r} free_bytes={free} required_bytes={required}")
|
|
PY
|
|
|
|
- name: Checkout base
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
# github.sha is the tip of the base branch when the event fires; the
|
|
# PR's base.sha can predate this workflow's own scripts.
|
|
ref: ${{ github.sha }}
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
# spec-trace-check.sh builds the trusted sametokens.go; a self-hosted
|
|
# runner has no Go on its PATH unless the job sets it up.
|
|
- name: Set up Go
|
|
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
|
with:
|
|
go-version-file: seaweed-block/go.mod
|
|
cache: false
|
|
|
|
- name: Check spec trace
|
|
env:
|
|
BASE: ${{ github.event.pull_request.base.sha }}
|
|
HEAD: ${{ github.event.pull_request.head.sha }}
|
|
PR: ${{ github.event.pull_request.number }}
|
|
BODY: ${{ github.event.pull_request.body }}
|
|
TITLE: ${{ github.event.pull_request.title }}
|
|
run: |
|
|
set -euo pipefail
|
|
bash .github/scripts/spec-trace-check-test.sh
|
|
python3 -B .github/scripts/model-trace-check-test.py
|
|
bash .github/scripts/changed-go-blobs-test.sh
|
|
# fsckObjects: a PR's objects are checked as they arrive, so a tree
|
|
# with a '..' or '.git' entry is refused here.
|
|
git -c fetch.fsckObjects=true fetch --no-tags origin "+refs/pull/${PR}/head:refs/remotes/pr/head"
|
|
printf '%s' "$BODY" >body.txt
|
|
bash ../.github/block/scripts/post-merge-review-changed.sh "$BASE" "$HEAD" >changed.bin
|
|
# Old and new blobs of each changed non-test Go file, for kind DOCS
|
|
# (objects only; a path that would leave blobs/ is refused).
|
|
mb=$(git merge-base "$BASE" "$HEAD")
|
|
bash ../.github/block/scripts/changed-go-blobs.sh "$mb" "$HEAD" blobs
|
|
# Mapping and validator come from the trusted base checkout above.
|
|
bash .github/scripts/spec-trace-check.sh body.txt blobs .github/model-code-trace.tsv <changed.bin
|
|
# Internal names stay out of this public repository: added lines,
|
|
# commit messages, title and description (no PR code is run).
|
|
bash .github/scripts/public-text-check-test.sh
|
|
printf '%s' "$TITLE" >title.txt
|
|
bash ../.github/block/scripts/public-text-check.sh "$mb" "$HEAD" title.txt body.txt
|
|
|
|
- name: Invariants ledger anchors (report only)
|
|
# Every code and test anchor of docs/design/invariants.md must exist at
|
|
# the PR's commit (git objects only; nothing from the PR is run). It
|
|
# reports and does not fail the check while the known imprecise
|
|
# anchors are being corrected; then this step becomes gating.
|
|
continue-on-error: true
|
|
env:
|
|
HEAD: ${{ github.event.pull_request.head.sha }}
|
|
run: python3 -I ../.github/block/scripts/ledger_check.py "$GITHUB_WORKSPACE" "$HEAD" seaweed-block/docs/design/invariants.md seaweed-block/ || true
|
|
|
|
- name: Clean job workspace
|
|
# Hosted runners are disposable; their setup-go cache upload runs in
|
|
# a post action and still needs the checkout. Persistent runners do not
|
|
# upload that cache, and must release their checkout/build files here.
|
|
if: always() && runner.environment == 'self-hosted'
|
|
working-directory: ${{ runner.temp }}
|
|
run: |
|
|
python3 -I - <<'PY'
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
root = Path(os.environ["GITHUB_WORKSPACE"])
|
|
# Refuse aliases rather than resolving them. Open EVERY component without
|
|
# following symlinks, then keep cleanup anchored to the verified directory fd.
|
|
if not root.is_absolute() or ".." in root.parts or root == Path(root.anchor) or root.name != root.parent.name or root == Path(os.environ["RUNNER_TEMP"]):
|
|
print(f"runner_workspace_cleanup_refused path={str(root)!r}")
|
|
sys.exit(1)
|
|
flags = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW
|
|
fd = os.open(root.anchor, flags)
|
|
previous = os.open(".", flags)
|
|
errors = []
|
|
try:
|
|
for part in root.parts[1:]:
|
|
child = os.open(part, flags, dir_fd=fd)
|
|
os.close(fd)
|
|
fd = child
|
|
if not shutil.rmtree.avoids_symlink_attacks:
|
|
raise OSError("descriptor-safe directory removal is unavailable")
|
|
os.fchdir(fd)
|
|
for entry in os.scandir("."):
|
|
try:
|
|
if entry.is_dir(follow_symlinks=False):
|
|
shutil.rmtree(entry.name)
|
|
else:
|
|
os.unlink(entry.name)
|
|
except OSError as err:
|
|
errors.append(f"{entry.name}: {err}")
|
|
except OSError as err:
|
|
print(f"runner_workspace_cleanup_refused path={str(root)!r} error={err}")
|
|
sys.exit(1)
|
|
finally:
|
|
os.fchdir(previous)
|
|
os.close(previous)
|
|
os.close(fd)
|
|
if errors:
|
|
print("runner_workspace_cleanup_failed " + "; ".join(errors))
|
|
sys.exit(1)
|
|
print(f"runner_workspace_clean path={str(root)!r}")
|
|
PY
|