Fix Swift Package Manager example
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). Runningswift package updateupdates all dependencies to the latest eligible versions and updates thePackage.resolved. You can commitPackage.resolvedto 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 addPackage.resolvedfile to.gitignorefile and haveswift package resolvecommand in charge of resolving the dependencies (swift package resolveis invoked by most SwiftPM commands).
We mustn't use restore-keys for spm cache.
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.
- name: Cache uses: actions/[email protected] - name: Cache uses: actions/[email protected] ``- name: Cache uses: actions/[email protected]
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.