-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of caching functionality for setup-go action #228
Conversation
Such inputs as 'cache' and 'cache-dependency-path' were added along with their descriptions.
Divided building procedure into two, one for main job, another for post-job.
Such files as cache-restore.ts, cache-utils.ts, constants.ts, cache-save.ts we added. Main.ts file now incorporates logic for using files mentioned above.
If caching is not enabled by action.yml input, save of the cache won't occur in the post-job.
Changes were applied to some debug messages.
Change modules-manager to package-manager in action.yml file.
File package-managers.ts was added.
src/cache-save.ts
Outdated
); | ||
|
||
if (nonExistingPaths.length === cachePaths.length) { | ||
throw new Error(`No cache folders exist on disk`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No cache folders exist on disk
-> 'There are no cache folders on the disk'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved, review again, please.
src/cache-utils.ts
Outdated
packageManagerInfo: PackageManagerInfo | ||
) => { | ||
let pathList = await Promise.all( | ||
packageManagerInfo.cacheFolderCommandList.map(async command => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need async here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved, review again, please.
README.md file was updated, removed async declaration in cache-utils file and changed the error message in cache-save file.
src/cache-restore.ts
Outdated
); | ||
} | ||
|
||
const primaryKey = `${platform}-go${versionSpec}-${fileHash}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to use a standard format for cache keys.
- For Node, it looks like:
node-cache-${platform}-${packageManager}-${fileHash}
- For Python / Pip, it looks like
${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}
Now I know those aren't the same, but I think we should follow one or the other so we don't drift so much. That will help if we're ever able to consolidate the setup-
caching logic in some package.
@@ -0,0 +1,62 @@ | |||
import * as cache from '@actions/cache'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the caching implementation has a lot in common with other setup-
actions. Many of the functions are similar to those used in setup-node
, for example.
I think it would be much better either to put these in @actions/cache
. Or we could create a shared "@actions/setup
" package that encapsulates all the common logic among setup-
actions. That will make sure all setup-
actions behave consistently.
IvanZosimov/modules-caching
80d911f
to
9031bf2
Compare
In the scope of this pull request, the possibility of caching go dependency files and compiler's build outputs was added. Such input parameters as
cache
andcache-dependency-path
were added.For now,
cache
input will accept the following values:true - enable caching for go dependency files and build outputs
false - disable caching for go dependency files and build outputs (default value)
cache-dependency-path
input is used to specify the path to a dependency file - go.sumDescription
Action will try to search go.sum file in the repository root or in any other location which is specified in
cache-dependency-path
input and throw an error if no one is found. The hash of the found file will be used as a cache key ( the same approach as actions/cache recommends). The following key cache will be used: ${{ runner.os }}-go${{ go-version }}-${{ hashFiles('<go.sum-path>') }}Examples of use-cases:
cache
input onlycache
along withcache-dependency-path
Linked ADR: #217
What's done: