Store / Restore
Store and Restore generated files and folders. Increase the performance on your CI.
The store/restore commands are intended to be used in a CI system. The store command requires a destination folder, where the all generated folders and files are moved for later recovery. Restoring previous state can give a performance boost to your CI workflows, because it can leverage caching from your tasks over different pipelines.
Example workflow
To demonstrate the behavior we use the following example below. A simple node typescript project, that requires to install npm dependencies and compile the typescript source code.
The CI system uses the build task to build
on every commit. The goal of the store/restore functionality is to prevent unnecessary work in the CI. Together with the caching from hammerkit, the build command will be skipped if nothing regarding source code has changed. The npm install will be skipped as well and the node_modules folder will be restored if nothing has changed inside the package.json
and package-lock.json
file.
Saving state
After the store command completed, the hammerkit cache including all files from tasks that use the generate
property are saved in the given destination folder. The folder can now be cached with the available caching mechanism in your CI.
Restoring state
Before running the required tasks in your CI workflow the state should be restored. Make sure your CI caching mechanism restores the previous saved cache and then restore it with hammerkit.
Example with Gitlab CI
This example uses the gitlab ci caching to speed up the build time of the build
command. For further details, take a look at the demo repository.
Last updated