(pipelines): support caching in simple synth action
See original GitHub issueAllow for caching in SimpleSynthAction
Use Case
Allowing for caching in the SimpleSynthAction makes it easy to decrease build times - e.g. caching incremental typescript lambda builds, caching npm packages, or even re-use unchanged resources - which can become quite incredible when using CDK Pipelines (like when a re-build is triggered after a pipeline self-mutate).
Proposed Solution
This would simply add a couple additional optional fields (cache
and cachePaths
) onto the SimpleSynthAction static methods, which could be used like:
SimpleSynthAction.standardNpmSynth({
sourceArtifact,
cloudAssemblyArtifact,
installCommand: 'npm ci --cache .npm',
buildCommand: "npm run ci-build",
cachePaths: ['dist/**/*', '.npm/**/*', './.git/objects/**/*', '.git-hash'],
cache: Cache.bucket(new Bucket(this, 'Cache'))
});
Currently, you can either create the whole build configuration yourself or copy and modify the source of the SimpleSynthAction, but these both seem untenable considering how easy it is to pass these options to the constructed internals.
Other
These parameters just get passed along into the SimpleSynthAction without any direct transformation, so this is really simple:
const buildSpec = BuildSpec.fromObject({
....
cache: {
paths: this.props.cachePaths
}
});
and
const project = new PipelineProject(scope, 'CdkBuildProject', {
...
cache: this.props.cache
});
SimpleSynthAction docs SimpleSynthAction source CodeBuild caching
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:27
- Comments:8 (3 by maintainers)
Top GitHub Comments
I’ve got an application where this would be really helpful - it has a bunch of rust-based dockerized lambdas, which building from scratch can take 10 minutes, and most of that time is compiling all the dependencies from source. It would be really nice to be able to have those bits cached to cut out a substantial portion of that build time.
@hoegertn
Yes, I use a partialBuildSpec which configures caching for some folders. But there is no persistence without a PipelineProject cache like the OP is saying. Right now there are no way to share a yarn/npm cache between different pipelines invocation if I’m not mistaken.