@@ -26,14 +26,46 @@ jobs:
2626 python-version : [3.7]
2727 steps :
2828 - uses : actions/checkout@v2
29+ - name : Get Pants version
30+ id : pants_version
31+ run : |
32+ # Capture the "pants_version = " line from config.
33+ PANTS_VERSION=$(grep -E '^pants_version\s*=' pants.toml)
34+ echo "::set-output name=pants_version::$PANTS_VERSION"
2935 - uses : actions/cache@v2
30- id : cache
36+ id : cache_pants_setup
3137 with :
3238 path : |
3339 ~/.cache/pants/setup
34- ~/.cache/pants/lmdb_store
40+ key : pants-setup-${{ steps.pants_version.outputs.pants_version }}
41+ - uses : actions/cache@v2
42+ id : cached_named_caches
43+ with :
44+ path : |
3545 ~/.cache/pants/named_caches
36- key : ${{ runner.os }}-
46+ # The Python backend uses named_caches for Pip/PEX state,
47+ # so it is appropriate to invalidate on requirements.txt changes.
48+ key : named-caches-${{ runner.os }}-${{ hashFiles('pants.toml') }}-${{ hashFiles('requirements.txt') }}
49+ # Note that falling back to a restore key may give a useful partial result that will save time
50+ # over completely clean state, but will cause the cache entry to grow without bound over time.
51+ # See https://pants.readme.io/docs/using-pants-in-ci for tips on how to periodically clean it up.
52+ # Alternatively you may want to avoid using restore keys.
53+ restore-keys : |
54+ pants-setup-${{ runner.os }}-${{ hashFiles('pants.toml') }}-${{ hashFiles('requirements.txt') }}
55+ pants-setup-${{ runner.os }}-${{ hashFiles('pants.toml') }}-
56+ pants-setup-${{ runner.os }}-
57+ # If you're not using a fine-grained remote caching service (see https://www.pantsbuild.org/docs/remote-caching),
58+ # then you may also want to preserve the local Pants cache (lmdb_store). However this must invalidate for
59+ # changes to any file that can affect the build, so may not be practical in larger repos.
60+ # A remote cache service integrates with Pants's fine-grained invalidation and avoids these problems.
61+ - uses : actions/cache@v2
62+ id : cache_lmdb_store
63+ with :
64+ path : |
65+ ~/.cache/pants/lmdb_store
66+ key : pants-setup-${{ runner.os }}-${{ hashFiles('**/*') }}
67+ # Same caveat as above regarding the issues with restore keys.
68+ restore-keys : pants-setup-${{ runner.os }}-
3769 - name : Setup Python ${{ matrix.python-version }}
3870 uses : actions/setup-python@v1
3971 with :
0 commit comments