Skip to content

Conversation

@theospears
Copy link
Collaborator

Summary

Speed up CI by using the cache action to save packages downloaded by SPM.

Validation

Verify this PR runs CI, and then uses cache the second time.

@theospears theospears requested a review from a team as a code owner October 14, 2025 04:24
run: cp BeeKit/Config.swift.sample BeeKit/Config.swift
- uses: actions/cache@v4
with:
path: /Users/runner/work/BeeSwift/BeeSwift/DerivedData/SourcePackages
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/actions/cache/blob/main/examples.md#swift---swift-package-manager

Shows how to use it for typical setups:

- uses: actions/cache@v4
  with:
    path: .build
    key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
    restore-keys: |
      ${{ runner.os }}-spm-

Copy link
Collaborator Author

@theospears theospears Oct 14, 2025

Choose a reason for hiding this comment

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

https://stackoverflow.com/questions/68081067/spm-cache-not-working-on-github-actions-any-ideas suggests that is true if you are using swift package directly, but not if the resolution is being done by xcodebuild, as is being done here

Copy link
Contributor

Choose a reason for hiding this comment

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

OK so we specify cloned_source_packages_path in scan/run_tests and replace path: .build with the path specified in run_tests' cloned_source_packages_path parameter.

https://itnext.io/effective-swift-package-manager-caching-with-fastlane-and-github-actions-b241585f0a4c

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I looks like specifying derived_data_path also works. Do you have strong opinions on which is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

I lean toward the cloned source option rather than the entire derived data. It seems more precisely targeted to what we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

And it seems CI does not take long at all to grab the spm managed packages currently.

11:55:31
11:54:58

🤞 the direct cache would be faster. It probably would be more efficient in any case.

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.

3 participants