
it鈥檚 a bit tough to get github actions caching right because they have some odd rules about which branches can use the cache.
We use github actions caching pretty extensively across our repos and we have something of a standard template now:
slipstream/ci.yml at 2148aaee152335e9c2a61b62da6767d50658f0de 路 NFIBrokerage/slipstream 路 GitHub has code very similar to your workflow:
- name: Restore the deps cache
uses: actions/cache@v1
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-
- name: Restore the _build cache
uses: actions/cache@v1
id: build-cache
with:
path: _build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-
(this is the CI workflow, mainly does tests)
And we have a second workflow that only runs on pushes to main/master which builds up the cache: slipstream/refresh-docs-cache.yml at 2148aaee152335e9c2a61b62da6767d50658f0de 路 NFIBrokerage/slipstream 路 GitHub. Runs on other branches (e.g. new branches and tags) can use caches from the default branch
Before adding dialyzer to this particular build, we were averaging around 30s/build!






















