Skip to content

Instantly share code, notes, and snippets.

@pftg
Created January 13, 2018 21:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pftg/92cb374182ffec19c37352c435fb3684 to your computer and use it in GitHub Desktop.
Save pftg/92cb374182ffec19c37352c435fb3684 to your computer and use it in GitHub Desktop.
Pre-compile Assets and Cache for CircleCI
- 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
@pftg
Copy link
Author

pftg commented Sep 29, 2021

Oh, I remember, why I moved to SHA1, in order to not run assets precompilation on re-run

@akostadinov
Copy link

akostadinov commented Sep 29, 2021

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