Visitar URL original
Fix Swift Package Manager example by younke · Pull Request #895 · actions/cache · GitHub
Skip to content

Fix Swift Package Manager example - #895

Closed
younke wants to merge 4 commits into
actions:mainfrom
younke:main
Closed

younke wants to merge 4 commits into
actions:mainfrom
younke:main

Conversation

@younke

@younke younke commented Aug 10, 2022

Copy link
Copy Markdown

Previous example is somewhat misleading.

When new package is added, old cache is being restored, which may lead to package resolve errors as described here.

Considering this guide:

To ensure the CI workflow’s reliability, make sure it uses the appropriate version of package dependencies.
SwiftPM records the result of dependency resolution in Package.resolved (at the top-level of the package) and it's used when performing dependency resolution (rather than having SwiftPM searching the latest eligible version of each package). Running swift package update updates all dependencies to the latest eligible versions and updates the Package.resolved. You can commit Package.resolved to your Git repository to ensure it’s always up-to-date on the CI environment to prevent the CI from building your project with unexpected versions of package dependencies. Otherwise you can choose to add Package.resolved file to .gitignore file and have swift package resolve command in charge of resolving the dependencies (swift package resolve is invoked by most SwiftPM commands).

We mustn't use restore-keys for spm cache.

@younke
younke requested a review from a team as a code owner August 10, 2022 04:14
@github-actions
github-actions Bot requested a review from kotewar August 10, 2022 04:15
@kotewar kotewar added the documentation Improvements or additions to documentation label Sep 7, 2022
@kotewar

kotewar commented Sep 15, 2022

Copy link
Copy Markdown
Contributor

Hi @younke, thanks for your contribution. We have kept restore-key in examples for everyone to understand how the templates would look by default.

Your recommendation looks more like a good practice. Would you like to add a generic note instead in the Known practices and workarounds section?
The same thing would also apply to languages/frameworks like NodeJS, GoLang (for example), that maintain a similar resolved packages file package-lock.json or go.sum. So this note would help users having background in multiple technologies.

@kadoned

kadoned commented Oct 16, 2022

Copy link
Copy Markdown
  • name: Cache
    uses: actions/cache@v3.0.11
    - name: Cache
    uses: actions/cache@v3.0.11
    ``- name: Cache
    uses: actions/cache@v3.0.11

@kotewar

kotewar commented Oct 18, 2022 •

Copy link
Copy Markdown
Contributor

Closing this PR as there is no response. But to make this clearer, the readme will be updated by giving better insights on cache-hit and partial match restore-key. PR raised here.

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants