Created
January 13, 2018 21:02
-
-
Save pftg/92cb374182ffec19c37352c435fb3684 to your computer and use it in GitHub Desktop.
Pre-compile Assets and Cache for CircleCI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- restore_cache: | |
keys: | |
- v1-asset-cache-{{ arch }}-{{ .Branch }} | |
- v1-asset-cache- | |
- run: bundle exec rake assets:precompile | |
- save_cache: | |
key: v1-asset-cache-{{ arch }}-{{ .Branch }}-{{ epoch }} | |
paths: | |
- public/assets | |
- tmp/cache/assets/sprockets |
Oh, I remember, why I moved to SHA1, in order to not run assets precompilation on re-run
Good to know, thanks. My example above with branch-revision should do mostly the same. At least I observe that on re-run it catch the latest branch cache.
update: I ended up hashing all files which may cause assets change and do exact match. Better not to reuse partial cache to avoid bloat and unexpected issues for little if any perf gain. Hashing with the following command git ls-tree HEAD $(<.circleci/asset_paths) > tmp/assets_related_checksums
, then using key v1-asset-cache-{{ checksum "tmp/assets_related_checksums" }}
.
For full PR you can see 3scale/porta#2630
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yep,
BuildNum
also works, any incremental counter.arch
is from the CircleCI default example.this is an old snippet, some updates you can find here https://github.com/jetthoughts/jt_tools/blob/master/lib/install/.circleci/config.yml
I extracted all such tips into a rails app generator
you can cache even bootsnap and other stuff