Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/rules/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
- **Manage CI without asking.** macOS runners are few, and every push to a pull request queues a set of macOS jobs. An agent may always cancel a run in flight — one a newer push superseded, one whose result nobody will read, one holding runners a more urgent run waits for — and start it again later. Cancel, never delete: a cancelled run keeps its record and logs. When several agents work at once, the one coordinating them decides which runs hold the runners.
- No job, and no step that builds, tests, fuzzes or measures, has a `timeout-minutes`: a limit sized from past runs fails work that is only slower than those runs, speed is checked where it is measured ("Check Generate Time on Linux", the growth rows), and GitHub's six hours end a step that hangs. Only a step that fetches, downloads, uploads, resolves or installs keeps a short one, against a stalled server. Never a per-test timeout either, which makes CI flaky: Swift Testing's `.timeLimit` also counts the time a test waits for a thread behind the rest of the suite, and tests that do a fraction of a second of work have waited more than ten minutes on a loaded runner. A test that never ends is stopped when its run is cancelled or at six hours, and the log then holds no verdict for it: save the step's log and `Scripts/unfinished-tests.py LOG` names every test that started and did not finish. The Linux test jobs run the test bundle directly, which writes each line as it happens, so a hung test is listed alone. A step that runs `swift test` off a terminal gets the tests' output in blocks and loses the last one when it is stopped, so its list also holds tests that passed; the script says when a log was cut.
- No scheduled or unattended check without a path that turns its findings into fix pull requests.
- **Performance measures are reported, not failed.** A performance row over its limit fails no check: wall time, peak memory, `.safedi` size, and a growth row's time, memory, size and code. A wall time differs between runners and between runs of one, so a failure on it was answered by running the job again; a change that moved another measure was answered by a commit that moved a limit and a run of every check again. "Check Generate Time on Linux" (`--report-measures`) and "Check Function Compile Time on Linux" (`--report-only`) therefore report a row over its limit as a warning, and "Post Timing to the Pull Request" writes both reports, with the change's tool against the newest release's, into one comment on the pull request that every run rewrites. The limits stay, as what the report calls over, and a change still does not raise one without approval. `Scripts/perf-watch.py --commit SHA [--before-commit SHA]` lists from a run's report every row over its limit, its ratio and limit, and how it moved since an earlier run: run it on each landing on main and on a release branch's heads, and give each row over a limit or worse an owner, so a regression is listed debt with a fix planned and never unseen. A shape or a row the tool cannot generate, or does not finish, still fails, as do the checks of correctness. A new check of a performance measure joins that comment (an artifact named `timing-comment-…` holding a Markdown report) and fails only when it measured nothing. Only that job has `pull-requests: write`, and it runs none of the pull request's code.
- **Performance measures are reported, not failed.** A performance row over its limit fails no check: wall time, peak memory, `.safedi` size, and a growth row's time, memory, size and code. A wall time differs between runners and between runs of one, so a failure on it was answered by running the job again; a change that moved another measure was answered by a commit that moved a limit and a run of every check again. "Check Generate Time on Linux" (`--report-measures`) and "Check Function Compile Time on Linux" (`--report-only`) therefore report a row over its limit as a warning, and "Post Timing to the Pull Request" writes both reports, with the change's tool against the newest release's, into one comment on the pull request that every run rewrites. The limits stay, as what the report calls over, and a change still does not raise one without approval. `Scripts/perf-watch.py --commit SHA [--before-commit SHA]` lists from a run's report every row over its limit, its ratio and limit, and how it moved since an earlier run: run it on each landing on main and on a release branch's heads, and give each row over a limit or worse an owner, so a regression is listed debt with a fix planned and never unseen. A shape or a row the tool cannot generate, or does not finish, still fails, as do the checks of correctness. The job also counts the instructions the tool executes generating each growth row at its two sizes, with callgrind (`--growth-instructions`): a count is the same on every run to within a thousandth, so it shows work that grows and writes nothing more where the row's wall time shows noise. A row over its "instructions" limit (else its "time" limit) is reported with the others, and a row that could not be counted fails. A new check of a performance measure joins that comment (an artifact named `timing-comment-…` holding a Markdown report) and fails only when it measured nothing. Only that job has `pull-requests: write`, and it runs none of the pull request's code.
- New Linux jobs use the container and setup of "Build Tests on Linux" and "Build and Test on Linux" in `ci.yml`, except "Build and Test on Latest Swift" (`swift:latest`), "Lint Swift" (`swift:6.3`, a release build of SwiftFormat), and "Build Release SafeDITool on Linux", which runs `publish.yml`'s Linux build command in `publish.yml`'s container, because publishing 2.3.0-alpha-1 crashed Swift 6.3.3 compiling that release build of code every CI job had passed. "Delete This Run's Scratch Ref" (`verify.yml`, `graph-fuzzer.yml`) and "Post Timing to the Pull Request" have no container: each runs only GitHub's API, the first git too.
- `ci.yml` runs every check on a branch with no pull request: `gh workflow run ci.yml --ref <branch>`. A landing stack is checked this way, never through a pull request opened only to carry its CI. The run counts every file as changed, reads no stack position, and compares "Check Generate Time on Linux" and the fuzzer's base comparison with the branch's merge base with main.
- `verify.yml` ("Verify on Linux") runs "Build Tests on Linux"'s build for one branch: `gh workflow run verify.yml --ref <branch> -f filter=<swift test filter>` (empty runs the suite; `-f pins=true` also checks the fuzzer's pins). It restores main's content-stamped build (`.github/scripts/stamp-source-times.sh`) and passed-compile-check caches; keep its container and `RELEASE_SWIFT_TEST_ARGUMENTS` in step with "Build Tests on Linux" and `graph-fuzzer.yml`'s coverage build, which restores its key. `-f mode=fast` needs a filter and builds in debug without coverage, from "Warm the Fast Verify Build Cache"'s cache. `-f mode=function-compile-time` runs only "Check Function Compile Time on Linux"'s build and check ("Verify Function Compile Time on Linux"; keep the two jobs' container, command and check in step) and tests nothing: run it before a pull request that adds or grows a long function under `Sources/SafeDICore` joins a stack, because the limit is about Linux's Swift 6.2 and CI runs on a stack's top only.
Expand Down
2 changes: 1 addition & 1 deletion .claude/rules/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ What each script is for. Read this before running or changing one, and before wr
- `Scripts/multi-module-repro.sh [--conditions DEBUG,X] ROOT MODULE…` runs `generate` per module as Bazel and Tuist do and compiles the modules in order.
- `Scripts/unexecuted-lines.py` is "Check Line Coverage on Linux": it needs both test jobs' reports, so it cannot check a local run. `.claude/rules/ci.md` says how to read a CI run's result locally.
- Tools only agents run are skills under `.claude/skills/`: `verify-touched` runs the suites a branch touches, before any full Verify. Before a review, run `pre-review` on the final head and put its block in the hand-back: lint, the touched suites, every fuzzer corpus with its pins on CI when the change owes them, and the lists a reviewer would otherwise ask for (32 of the 49 findings of one day's review rounds were ones an existing command shows).
- `Scripts/generate-time-check.py BASE_TOOL HEAD_TOOL DIRECTORY` is "Check Generate Time on Linux": it times two builds of `SafeDITool` generating synthetic seam, inline and public mock graphs in alternating runs. It fails when the head tool cannot generate a shape; under `--report-measures`, which CI passes, a measure over its limit (wall time, peak memory, `.safedi` size, a growth row) is reported and fails nothing ("Performance measures are reported" in `.claude/rules/ci.md`).
- `Scripts/generate-time-check.py BASE_TOOL HEAD_TOOL DIRECTORY` is "Check Generate Time on Linux": it times two builds of `SafeDITool` generating synthetic seam, inline and public mock graphs in alternating runs. It fails when the head tool cannot generate a shape; under `--report-measures`, which CI passes, a measure over its limit (wall time, peak memory, `.safedi` size, a growth row) is reported and fails nothing ("Performance measures are reported" in `.claude/rules/ci.md`). `--growth-instructions HEAD_TOOL DIRECTORY` counts the instructions the tool executes generating each growth row at its two sizes (callgrind) against the row's limit.
- `Scripts/perf-watch.py [--before EARLIER_REPORT] REPORT`, or `--commit SHA [--before-commit SHA]`, reads that check's report (a file, or the artifact of a commit's newest CI run) and lists every row over its limit with its ratio and limit, how it moved since the earlier run, and every other row that got worse.
- `Scripts/check-claude-instruction-files.sh` fails when an instruction file could be truncated or would load at launch by mistake, when a rules file is missing from the table under "Where the rest lives", when an instruction file names a Swift symbol no other tracked file contains (`Scripts/check-instruction-symbols.py`), or when reading one tracked file would load more rules than a budget allows (`Scripts/check-instruction-load.py`, whose `--report FILE…` prints what a file loads); "Check Markdown links" runs it.

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3592,6 +3592,33 @@ jobs:
with:
path: .generate-time/cached
key: generate-time-tool-${{ runner.os }}-swift-6.2-${{ steps.commits.outputs.head }}
# The instructions the change's tool executes generating each growth
# row at its two sizes, counted by callgrind, against the row's limit
# (`--growth-instructions`): work that grows faster than the graph and
# writes nothing more moves no other measure but wall time, and one
# tool's count on one graph is the same on every run to within a
# thousandth (a row counted twice gave 291,455,905 and 291,258,972),
# where a row's wall time moves by a tenth and more. A row over its
# limit is reported with the other measures (`--report-measures`) and
# joins the pull request's timing comment; a row whose instructions
# could not be counted fails. Every row at both sizes was 330 billion
# instructions for the tool of 33773fa, which took 15 minutes four
# runs at a time on a four-core Linux machine. valgrind is installed
# here, since the image has none and no other step uses it.
- name: Install valgrind
if: ${{ !cancelled() && hashFiles('.generate-time/head/SafeDITool') != '' }}
uses: ./.github/actions/retry
with:
command: command -v valgrind >/dev/null || { apt-get update && apt-get install -y --no-install-recommends valgrind; }
- name: Count the Growth Rows' Instructions
if: ${{ !cancelled() && hashFiles('.generate-time/head/SafeDITool') != '' }}
run: |
mkdir -p "$RUNNER_TEMP/timing-comment"
status=0
python3 -I Scripts/generate-time-check.py --growth-instructions --report-measures --summary "$RUNNER_TEMP/timing-comment/3-growth-instructions.md" \
.generate-time/head/SafeDITool "$RUNNER_TEMP/growth-instructions" || status=$?
cat "$RUNNER_TEMP/timing-comment/3-growth-instructions.md" >> "$GITHUB_STEP_SUMMARY" || true
exit "$status"
# The newest release's tool, for the comparison below, saved once per
# release by the first push to main that finds none: a pull request's
# run can restore what main saved and nothing a pull request saves
Expand Down
Loading
Loading