Skip to content

ci: cache Linux Swift toolchains - #1670

Merged
steipete merged 1 commit into
steipete:mainfrom
Yuxin-Qiao:codex/ci-cache-linux-swift-toolchain
Jun 21, 2026
Merged

ci: cache Linux Swift toolchains#1670
steipete merged 1 commit into
steipete:mainfrom
Yuxin-Qiao:codex/ci-cache-linux-swift-toolchain

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cache the Linux swiftly home/toolchain state used by the build-linux-cli matrix
  • centralize the Swift version in workflow env.SWIFT_VERSION
  • keep the swiftly bootstrap download/init on every run, so CI never executes a cached swiftly bootstrap binary
  • install/verify Swift's Ubuntu prerequisites before swiftly install, independent of cache hit/miss behavior
  • print the Actions cache-hit value in the Swift install step for easier CI diagnosis

Why

Every PR runs the Linux x64 and arm64 CLI jobs, and each job currently installs Swift 6.2.1 through swiftly before building/testing the CLI. Caching ~/.local/share/swiftly lets warm runs reuse Swift toolchain state while keeping the existing swiftly install ... --use command as the correctness gate.

This does not change test coverage or branch-protection behavior. Cold runs still follow the existing download/init/install path. Warm runs still fetch the official swiftly bootstrap, verify required Ubuntu packages first, then let swiftly reuse cached toolchain state.

Safety

  • Cache path is limited to ~/.local/share/swiftly; ~/.local/bin/swiftly is not cached.
  • The install step always downloads the official swiftly bootstrap before running swiftly install.
  • ca-certificates, gpg, and libcurl4-openssl-dev are checked with dpkg-query before swiftly runs; apt-get update/install only runs when one is missing.
  • The swiftly install "$SWIFT_VERSION" --use call remains in place, so swiftly still validates/selects the requested toolchain.

Validation

  • workflow YAML parsed with yaml.safe_load
  • checked the build-linux-cli job contains actions/cache@v4 with an OS/arch/Swift-version scoped key
  • checked the cache path is limited to ~/.local/share/swiftly
  • checked the install step contains the cache-independent prerequisite package check
  • extracted the embedded Swift install shell step and ran bash -n
  • git diff --check

GitHub Actions proof

Warm-cache run for this commit: https://github.com/steipete/CodexBar/actions/runs/27857784562

  • changes: success
  • lint: success
  • build-linux-cli (linux-x64, ubuntu-24.04): success
    • Restore Swift toolchain cache: success
    • log: Cache restored from key: swift-Linux-X64-6.2.1-v2
    • log: Swift toolchain cache hit: true
    • log: Setting up libcurl4-openssl-dev:amd64
    • log: Swift version 6.2.1 (swift-6.2.1-RELEASE)
    • release build, Linux tests, and CLI smoke test: success
  • build-linux-cli (linux-arm64, ubuntu-24.04-arm): success
    • Restore Swift toolchain cache: success
    • log: Cache restored from key: swift-Linux-ARM64-6.2.1-v2
    • log: Swift toolchain cache hit: true
    • log: Setting up libcurl4-openssl-dev:arm64
    • log: Swift version 6.2.1 (swift-6.2.1-RELEASE)
    • release build, Linux tests, and CLI smoke test: success

This proves the warm-cache path still installs missing Ubuntu prerequisites before swiftly install, selects Swift 6.2.1, and completes the full Linux build/test/smoke matrix on both architectures.

@clawsweeper

clawsweeper Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed June 19, 2026, 10:57 PM ET / 02:57 UTC.

Summary
The PR modifies the CI workflow to cache swiftly’s Linux toolchain home by OS, architecture, and Swift version while keeping the swiftly bootstrap download and prerequisite package checks on every Linux CLI run.

Reproducibility: not applicable. as a bug reproduction; this is a CI workflow PR. The changed behavior is verifiable from the current-head GitHub Actions Linux matrix status and copied log excerpts in the PR discussion.

Review metrics: 2 noteworthy metrics.

  • Workflow surface: 1 workflow changed; 21 added, 4 removed. The entire patch changes CI setup, so review attention belongs on Actions cache behavior and Linux Swift installation.
  • Warm Linux matrix proof: 2 of 2 Linux jobs reported cache-hit true and succeeded. Both Linux architectures exercised the new warm-cache path before build, test, and smoke checks passed.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • No ClawSweeper repair lane is needed; the patch has no actionable review finding and should proceed through ordinary maintainer review and required checks.

Security
Cleared: The diff adds an official Actions cache step and prerequisite package checks without broadening secrets, permissions, or dependency sources beyond the intended cached Swift toolchain state.

Review details

Best possible solution:

Land the workflow change after normal required checks finish, keeping the cache scoped by OS, architecture, and Swift version while prerequisites are installed before the cache-sensitive swiftly install path.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction; this is a CI workflow PR. The changed behavior is verifiable from the current-head GitHub Actions Linux matrix status and copied log excerpts in the PR discussion.

Is this the best way to solve the issue?

Yes. The current diff uses a narrow cache boundary, keeps downloading and initializing swiftly each run, installs prerequisites before the cache-sensitive install call, and has warm-cache Linux proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0f85e05f1c3d.

Label changes

Label changes:

  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.

Label justifications:

  • P3: This is a low-risk CI performance cleanup with no direct app user-facing behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body and comments provide current-head GitHub Actions proof showing warm-cache restores, prerequisite installation, Swift 6.2.1 selection, and successful Linux build/test/smoke jobs on x64 and arm64.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and comments provide current-head GitHub Actions proof showing warm-cache restores, prerequisite installation, Swift 6.2.1 selection, and successful Linux build/test/smoke jobs on x64 and arm64.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read in full; its CI validation and read-only review guidance shaped this review. (AGENTS.md:1, 0f85e05f1c3d)
  • Current main baseline: Current main installs Swift 6.2.1 through swiftly in the Linux CLI matrix without an Actions cache restore step. (.github/workflows/ci.yml:144, 0f85e05f1c3d)
  • Current PR workflow source: The PR head adds actions/cache@v4 for ~/.local/share/swiftly, checks ca-certificates, gpg, and libcurl4-openssl-dev before swiftly, and keeps swiftly install "$SWIFT_VERSION" as the selector/verification step. (.github/workflows/ci.yml:147, 14765edbdec8)
  • Diff shape: The patch is limited to one workflow with 21 additions and 4 deletions; git diff --check reported no whitespace errors. (.github/workflows/ci.yml:1, 14765edbdec8)
  • Actions status evidence: The PR status rollup for head 14765ed shows changes, lint, and both Linux CLI matrix jobs succeeded; macOS shard checks were still queued at inspection time and should remain gated normally. (14765edbdec8)
  • Contributor proof: The PR body and latest contributor comment include warm-cache log excerpts for x64 and arm64 showing cache-hit true, libcurl prerequisite installation, Swift 6.2.1 selection, and successful build/test/smoke steps. (14765edbdec8)

Likely related people:

  • Yuxin-Qiao: GitHub commit history for .github/workflows/ci.yml shows several recent merged CI workflow changes by this contributor, including Linux lint and macOS shard changes. (role: recent area contributor; confidence: high; commits: 669d1e9b08ee, 10dd11fb7e67, 5e38f6beb98d; files: .github/workflows/ci.yml)
  • steipete: GitHub commit history shows multiple prior CI workflow commits by steipete, and local blame attributes the current baseline Linux CLI job to release commit 33a5f43. (role: adjacent workflow owner; confidence: medium; commits: 33a5f4362eab, 06770308831e, 71c124e6646f; files: .github/workflows/ci.yml)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jun 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 056b5787aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +150 to +152
path: |
~/.local/share/swiftly
~/.local/bin/swiftly

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Cache the Swift command shims too

In the cache-hit path this restores the toolchain directory and only the swiftly executable, but not the swift, swiftc, etc. shims that swiftly documents as SWIFTLY_BIN_DIR symlinks for toolchain commands. Because swiftly's install path also treats an already-present exact version as already installed rather than a new install, the later swiftly install "$SWIFT_VERSION" --use can leave a fresh runner without ~/.local/bin/swift, so swift --version and the Linux build fail after the first cache is saved. Cache the whole bin directory or explicitly recreate/select the shims on cache hits.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/ci.yml
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> "$GITHUB_ENV"

swiftly install 6.2.1 --use --assume-yes --post-install-file "$POST_INSTALL_SCRIPT"
swiftly install "$SWIFT_VERSION" --use --assume-yes --post-install-file "$POST_INSTALL_SCRIPT"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Install Swift system packages on cache hits

When this toolchain is restored from cache on a fresh Ubuntu runner, swiftly install "$SWIFT_VERSION" can report the exact version as already installed and skip generating the --post-install-file; swiftly's docs describe that file as being written only when the toolchain being installed has extra post-install steps. That means the sudo bash "$POST_INSTALL_SCRIPT" branch never runs on cache hits, so required apt packages that are not part of the runner image are no longer installed before swift build/swift test. Install the dependency script independently of the cached toolchain, or force a path that re-emits/runs those dependencies.

Useful? React with 👍 / 👎.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/ci-cache-linux-swift-toolchain branch from 056b578 to 9281e25 Compare June 20, 2026 02:31
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I revised the cache boundary in 9281e253 to address the cached-bootstrap concern from the prior review:

  • the cache path is now only ~/.local/share/swiftly
  • ~/.local/bin/swiftly is no longer cached
  • every run still downloads and initializes the official swiftly bootstrap before running swiftly install
  • the install step prints Swift toolchain cache hit: ... for future warm-cache diagnosis

Fresh run for this commit: https://github.com/steipete/CodexBar/actions/runs/27857529840

Linux matrix proof from that run:

  • x64: restore cache success, Swift install success, release build success, Linux tests success, CLI smoke test success
  • arm64: restore cache success, Swift install success, release build success, Linux tests success, CLI smoke test success
  • logs show expected first v2 cold cache misses for both keys and Swift version 6.2.1 (swift-6.2.1-RELEASE) on both architectures

The first v2 run is cold because the key intentionally changed after removing cached bootstrap execution. Subsequent runs should be warm for the toolchain state while still using the freshly downloaded swiftly bootstrap.

@clawsweeper

clawsweeper Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 20, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/ci-cache-linux-swift-toolchain branch from 9281e25 to 14765ed Compare June 20, 2026 02:42
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I addressed the cache-hit prerequisite finding in 14765edb:

  • ca-certificates, gpg, and libcurl4-openssl-dev are now checked with dpkg-query before swiftly install, independent of whether swiftly sees a cached/installed toolchain.
  • The cache still excludes ~/.local/bin/swiftly; each run downloads the official swiftly bootstrap.

Warm-cache proof run: https://github.com/steipete/CodexBar/actions/runs/27857784562

Key proof:

  • x64: Cache restored from key: swift-Linux-X64-6.2.1-v2, Swift toolchain cache hit: true, Setting up libcurl4-openssl-dev:amd64, Swift 6.2.1 selected, release build/tests/smoke all succeeded.
  • arm64: Cache restored from key: swift-Linux-ARM64-6.2.1-v2, Swift toolchain cache hit: true, Setting up libcurl4-openssl-dev:arm64, Swift 6.2.1 selected, release build/tests/smoke all succeeded.

@clawsweeper

clawsweeper Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jun 20, 2026
@steipete

Copy link
Copy Markdown
Owner

Maintainer verification on exact head 14765edbdec82881055e678c3254b45b358ca839:

  • required GitHub checks green, including both Linux architecture jobs and warm-cache proof
  • git diff --check origin/main...HEAD
  • isolated Codex autoreview: clean, no accepted/actionable findings

Landing this CI-only change.

@steipete
steipete merged commit 802d778 into steipete:main Jun 21, 2026
10 checks passed
@Yuxin-Qiao
Yuxin-Qiao deleted the codex/ci-cache-linux-swift-toolchain branch June 25, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants