Skip to content
Open
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
1 change: 1 addition & 0 deletions .claude/rules/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ paths:
- 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.
- 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.
- "Compile Generated Mocks on Linux" runs `Scripts/compile-generated-mocks.py` on a change that touches the sources: seven fixed graphs generated and compiled with `-DDEBUG`, about six minutes on four processors after a debug build of the tool, the library and the macros (about five minutes with no cache). It fails on a module the compiler refuses and prints the first errors; a module above a refused one is not compiled. Add a graph as one file under `Scripts/compile-generated-mocks/`, with a `// module: NAME` line before each module's declarations when it has more than one; the fixtures are input, so `.swiftformat` leaves them alone.
- `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.
- **A restored build compiles every test target again when what the tests are compiled against changed.** A restored build did not always compile a test target again when a module it imports changed, and linked tests compiled for an enum of SafeDICore without its new case, which crashed them; such a target can as well pass a test that should fail. `.github/scripts/stamp-source-times.sh` therefore gives a file under `Tests` a time from its content and from `Sources`, the test support target and the manifest together, so a change to any of those compiles every test target again. A job that restores a build of the tests stamps first. To rule a restored build out of one result, label the pull request `clean-build` and re-run (every restore of a SwiftPM or xcodebuild build in `ci.yml` is skipped; the label is read as it is now), or pass `verify.yml` `-f clean=true`.
Expand Down
1 change: 1 addition & 0 deletions .claude/rules/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ What each script is for. Read this before running or changing one, and before wr
- `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/compile-generated-mocks.py TOOL BIN_PATH DIRECTORY` is "Compile Generated Mocks on Linux": it generates fixed graphs (`--list`) with a debug build's tool and compiles each module's generated code, mocks included, as a debug build does; a graph whose generated code once failed to compile joins as a file under `Scripts/compile-generated-mocks/`.
- `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
71 changes: 69 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,7 @@ jobs:
# leaves the builds for the next run or for eviction.
prune-build-caches:
name: Delete Older Build Directories
needs: [spm, linux-build, linux-latest-swift-group, generate-time, example-integrations, stack-position]
needs: [spm, linux-build, linux-latest-swift-group, generate-time, compile-generated-mocks, example-integrations, stack-position]
if: ${{ !cancelled() && needs.stack-position.outputs.stacked-under == '' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
Expand All @@ -2236,7 +2236,7 @@ jobs:
REF: ${{ github.ref }}
COMMIT: ${{ github.sha }}
run: |
for prefix in spm-release-v2-macOS-xcode-26.0- spm-release-v2-Linux-swift-6.2- spm-debug-v2-Linux-swift- generate-time-build-v1-Linux-swift-6.2-; do
for prefix in spm-release-v2-macOS-xcode-26.0- spm-release-v2-Linux-swift-6.2- spm-debug-v2-Linux-swift- generate-time-build-v1-Linux-swift-6.2- compile-generated-mocks-build-v1-Linux-swift-6.2-; do
if ! builds=$(gh api -X GET "repos/$REPOSITORY/actions/caches" -f key="$prefix" -f ref="$REF" -F per_page=100 --jq '.actions_caches[] | "\(.id) \(.key)"' 2>&1); then
echo "::warning::Listing $REF's builds under $prefix failed: $(printf '%s' "$builds" | tr '\r\n' ' ')"
continue
Expand Down Expand Up @@ -3648,6 +3648,73 @@ jobs:
# run's, which may be days older.
retention-days: 30

# The generated code of fixed graphs, mocks included, compiled as an
# app's debug build compiles it (Scripts/compile-generated-mocks.py): the
# lifelike chain at five features with and without screens that open
# screens above them, the calling-mocks shape, an app of 150 mocked
# features, and each graph under Scripts/compile-generated-mocks/ that a
# release candidate's code did not compile for. The tests compare the
# generator's text and the graph fuzzer compiles small drawn graphs, so
# code the compiler refuses in a shape an app has was otherwise found
# only by an app-sized build. A debug build of the tool, the library and its
# macros, which no other job builds with these arguments, so the job
# keeps a build cache of its own, keyed as "Check Generate Time on
# Linux" keys its release build.
compile-generated-mocks:
name: Compile Generated Mocks on Linux
needs: [changes, stack-position]
if: ${{ !cancelled() && needs.stack-position.outputs.stacked-under == '' && needs.changes.outputs.source != 'false' }}
runs-on: ubuntu-latest
container: swift:6.2
permissions:
contents: read
defaults:
run:
shell: bash
steps:
- name: Checkout Repo
uses: actions/checkout@v7
# Retried for the reason "Install curl for Codecov" gives.
- name: Install Python
uses: ./.github/actions/retry
with:
command: command -v python3 >/dev/null || { timeout 120 apt-get -o Acquire::http::Timeout=20 -o Acquire::Retries=0 update && timeout 120 apt-get -o Acquire::http::Timeout=20 -o Acquire::Retries=0 install -y --no-install-recommends python3; } || { sed -i -E 's#http://(archive|security)\.ubuntu\.com/ubuntu#http://azure.archive.ubuntu.com/ubuntu#' /etc/apt/sources.list.d/ubuntu.sources; false; }
- name: Check the Script
run: python3 -I Scripts/compile-generated-mocks.py --self-test "$RUNNER_TEMP/compile-generated-mocks-self-test"
# For the reason "Build Tests on Linux" gives.
- name: Stamp Source Times
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
.github/scripts/stamp-source-times.sh
- name: Restore Build Directory
if: ${{ needs.stack-position.outputs.clean-build != 'true' }}
uses: actions/cache/restore@v6
with:
path: .build
key: compile-generated-mocks-build-v1-${{ runner.os }}-swift-6.2-${{ hashFiles('Package.resolved') }}-${{ github.sha }}
restore-keys: |
compile-generated-mocks-build-v1-${{ runner.os }}-swift-6.2-${{ hashFiles('Package.resolved') }}-
compile-generated-mocks-build-v1-${{ runner.os }}-swift-6.2-
- name: Resolve Package Dependencies
uses: ./.github/actions/retry
with:
command: swift package resolve
# The tool, and the library with the macros its users' modules expand.
- name: Build SafeDITool, SafeDI and the Macros
run: |
swift build --traits sourceBuild --product SafeDITool
swift build --traits sourceBuild --target SafeDI
- name: Save Build Directory
if: ${{ !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v6
with:
path: .build
key: compile-generated-mocks-build-v1-${{ runner.os }}-swift-6.2-${{ hashFiles('Package.resolved') }}-${{ github.sha }}
- name: Generate and Compile the Graphs
run: |
bin=$(swift build --traits sourceBuild --show-bin-path)
python3 -I Scripts/compile-generated-mocks.py --summary "$GITHUB_STEP_SUMMARY" "$bin/SafeDITool" "$bin" "$RUNNER_TEMP/compile-generated-mocks"

# Builds the SafeDITool of the pull request's base, which each fuzzer shard
# below runs beside this commit's over the shard's graphs
# (SafeDIToolBaseComparisonTests/longRun), comparing exit statuses,
Expand Down
2 changes: 2 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# The written-calls fixtures keep the Manual’s spellings (`ErasedInstantiator<(), …>`) and the type annotations that
# check what each call returns (`let _: Screen = …`), and a released copy must never change.
--exclude Scripts/release-checks/written-calls
# Graphs whose generated code a release candidate did not compile, kept as the files that were found.
--exclude Scripts/compile-generated-mocks

# format options
--indent tab
Expand Down
Loading
Loading