Implementation of caching functionality for setup-go action#228
Implementation of caching functionality for setup-go action#228dmitry-shibanov merged 63 commits intoactions:mainfrom
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.
No cache folders exist on disk -> 'There are no cache folders on the disk'
There was a problem hiding this comment.
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.
Do we need async here ?
There was a problem hiding this comment.
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.
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.
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
cacheandcache-dependency-pathwere added.For now,
cacheinput 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-pathinput 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-pathinput 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:
cacheinput onlycachealong withcache-dependency-pathLinked ADR: #217
What's done: