Skip to content

Added caching to windows, linux and mac CI#100

Open
MiaKoring wants to merge 2 commits into
amethystsoft:mainfrom
MiaKoring:add-caching
Open

Added caching to windows, linux and mac CI#100
MiaKoring wants to merge 2 commits into
amethystsoft:mainfrom
MiaKoring:add-caching

Conversation

@MiaKoring

@MiaKoring MiaKoring commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Added Swift build caching across Linux, macOS, and Windows CI workflows.
  • Added concurrency controls to Linux and Windows workflows to cancel outdated runs.
  • Updated example builds to run after tests and use appropriately sized runners.
  • Explicitly targeted amethyst-veinPackageTests in standard and Thread Sanitizer test scripts.

The shared caching and concurrency improvements should reduce CI time and resource usage while preventing redundant runs.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b0f0180-a055-4fb8-a06d-51e535215336

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Swift test scripts now target a specific test product. Linux, macOS, and Windows workflows add Swift package caching, while Linux and Windows also cancel superseded runs and sequence example builds after tests.

Changes

Swift CI updates

Layer / File(s) Summary
Targeted Swift test execution
Scripts/test.sh, Scripts/tsan-test.sh
Both Swift test invocations explicitly select amethyst-veinPackageTests while preserving their existing flags and environment variables.
Linux and Windows CI orchestration
.github/workflows/swift-test-linux.yml, .github/workflows/swift-test-windows.yml
Linux and Windows workflows add cancelable concurrency groups, cache Swift build artifacts, and make example builds depend on the corresponding test jobs.
macOS Swift Package Manager caching
.github/workflows/swift-test-mac.yml
The macOS test and example-build jobs cache .build and SwiftPM artifacts before running their existing commands.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding caching across Windows, Linux, and macOS CI workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MiaKoring

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/swift-test-mac.yml (2)

21-21: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin actions/cache to a commit SHA.

The new cache steps use mutable actions/cache@v4, whereas actions/checkout is already pinned. Pin the cache action to a verified full commit SHA to keep CI behavior reproducible and reduce supply-chain risk.

Also applies to: 45-45

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/swift-test-mac.yml at line 21, Replace both uses of
actions/cache@v4 in the workflow with the verified full commit SHA for the
intended cache action version, matching the existing actions/checkout pinning
style and preserving the current cache-step behavior.

20-28: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Use separate cache keys for the test and example-build jobs.

Both jobs cache .build under the identical key, while build-example can run independently of test. Concurrent runs may therefore save different TSAN/example artifacts under the same immutable key, making future cache contents nondeterministic and reducing cache effectiveness. Add job-specific key suffixes, or cache only the shared SwiftPM download directory.

Also applies to: 44-52

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/swift-test-mac.yml around lines 20 - 28, Update the Swift
Package Manager cache configuration so the test and build-example jobs do not
share an identical key for .build artifacts. Add distinct job-specific suffixes
to each job’s key and corresponding restore-keys, or restrict caching to the
shared SwiftPM download directory; preserve caching behavior otherwise.
.github/workflows/swift-test-linux.yml (1)

30-32: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make cache identity include the Swift toolchain. The current keys can reuse .build artifacts across future compiler or architecture changes.

  • .github/workflows/swift-test-linux.yml#L30-L32: add the Swift image/toolchain and architecture to the Linux test cache key.
  • .github/workflows/swift-test-linux.yml#L62-L64: use the same toolchain-aware key for the Linux example build.
  • .github/workflows/swift-test-windows.yml#L38-L40: add the configured Swift version and architecture to the Windows test cache key.
  • .github/workflows/swift-test-windows.yml#L67-L69: use the same toolchain-aware key for the Windows example build.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/swift-test-linux.yml around lines 30 - 32, Update the
cache keys and restore keys for both Swift test and example-build caches to
include the configured Swift image/toolchain or version and architecture, in
addition to the runner OS and Package.resolved hash. Apply the same
toolchain-aware key consistently at .github/workflows/swift-test-linux.yml lines
30-32 and 62-64, and .github/workflows/swift-test-windows.yml lines 38-40 and
67-69.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/swift-test-linux.yml:
- Line 27: Pin the cache action references to reviewed immutable commit SHAs
instead of mutable tags: update actions/cache@v4 at
.github/workflows/swift-test-linux.yml lines 27-27 and 59-59 and
.github/workflows/swift-test-windows.yml lines 33-33, and update
actions/cache/restore@v4 at .github/workflows/swift-test-windows.yml lines
62-62. Preserve each workflow’s existing cache behavior.

---

Nitpick comments:
In @.github/workflows/swift-test-linux.yml:
- Around line 30-32: Update the cache keys and restore keys for both Swift test
and example-build caches to include the configured Swift image/toolchain or
version and architecture, in addition to the runner OS and Package.resolved
hash. Apply the same toolchain-aware key consistently at
.github/workflows/swift-test-linux.yml lines 30-32 and 62-64, and
.github/workflows/swift-test-windows.yml lines 38-40 and 67-69.

In @.github/workflows/swift-test-mac.yml:
- Line 21: Replace both uses of actions/cache@v4 in the workflow with the
verified full commit SHA for the intended cache action version, matching the
existing actions/checkout pinning style and preserving the current cache-step
behavior.
- Around line 20-28: Update the Swift Package Manager cache configuration so the
test and build-example jobs do not share an identical key for .build artifacts.
Add distinct job-specific suffixes to each job’s key and corresponding
restore-keys, or restrict caching to the shared SwiftPM download directory;
preserve caching behavior otherwise.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 01d5df18-f97c-43fc-aa1f-36f22f7ccf38

📥 Commits

Reviewing files that changed from the base of the PR and between 4202a8e and 83a3927.

📒 Files selected for processing (5)
  • .github/workflows/swift-test-linux.yml
  • .github/workflows/swift-test-mac.yml
  • .github/workflows/swift-test-windows.yml
  • Scripts/test.sh
  • Scripts/tsan-test.sh

with:
persist-credentials: false
- name: Cache Swift build
uses: actions/cache@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow files =="
git ls-files .github/workflows || true

echo
echo "== cache action references in workflows =="
rg -n "uses:\s*actions/cache|actions/cache/(restore|save)?" .github/workflows || true

echo
echo "== surrounding pinned action context =="
for f in .github/workflows/swift-test-linux.yml .github/workflows/swift-test-windows.yml; do
  if [ -f "$f" ]; then
    echo "--- $f"
    nl -ba "$f" | sed -n '1,90p'
  fi
done

echo
echo "== all uses in workflows under .github/workflows =="
python3 - <<'PY'
from pathlib import Path
import re
for p in sorted(Path('.github/workflows').glob('*.yml')):
    for i,line in enumerate(p.read_text().splitlines(),1):
        m=re.search(r'uses:\s*(v4[\d.\-A-Za-z0-9_./#:`@-`]*)', line)
        if m:
            print(f"{p}:{i}: {line.strip()}")
PY

Repository: amethystsoft/vein

Length of output: 1033


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== swift-test-linux relevant lines =="
awk '{printf "%5d  %s\n", NR, $0}' .github/workflows/swift-test-linux.yml | sed -n '1,85p'

echo
echo "== swift-test-windows relevant lines =="
awk '{printf "%5d  %s\n", NR, $0}' .github/workflows/swift-test-windows.yml | sed -n '1,85p'

echo
echo "== all uses in workflow yaml files =="
python3 - <<'PY'
from pathlib import Path
import re
for p in sorted(Path('.github/workflows').glob('*.yml')):
    for i,line in enumerate(p.read_text().splitlines(),1):
        m=re.search(r'uses:\s*([^\s#]+)', line)
        if m:
            print(f"{p}:{i}: {line.strip()}")
PY

echo
echo "== cache pins context =="
python3 - <<'PY'
from pathlib import Path
import re
for p in sorted(Path('.github/workflows').glob('*.yml')):
    text=p.read_text().splitlines()
    for i,line in enumerate(text,1):
        if 'actions/cache' in line:
            print(f"{p}:{i}: {line.strip()}")
            for j in range(max(1,i-2), min(len(text), i+4)+1):
                print(f"  {j}: {text[j-1]}")
            print()
PY

Repository: amethystsoft/vein

Length of output: 8649


Pin the newly added cache actions to reviewed commit SHAs. These refs use mutable actions/cache tags, unlike the SHA-pinned checkout/Swift actions in the same workflows.

  • .github/workflows/swift-test-linux.yml#L27 and #L59: pin actions/cache@v4.
  • .github/workflows/swift-test-windows.yml#L33: pin actions/cache@v4.
  • .github/workflows/swift-test-windows.yml#L62: pin actions/cache/restore@v4.
📍 Affects 2 files
  • .github/workflows/swift-test-linux.yml#L27-L27 (this comment)
  • .github/workflows/swift-test-linux.yml#L59-L59
  • .github/workflows/swift-test-windows.yml#L33-L33
  • .github/workflows/swift-test-windows.yml#L62-L62
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/swift-test-linux.yml at line 27, Pin the cache action
references to reviewed immutable commit SHAs instead of mutable tags: update
actions/cache@v4 at .github/workflows/swift-test-linux.yml lines 27-27 and 59-59
and .github/workflows/swift-test-windows.yml lines 33-33, and update
actions/cache/restore@v4 at .github/workflows/swift-test-windows.yml lines
62-62. Preserve each workflow’s existing cache behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant