Hey there dear people! :slightly_smiling_face: I a...
# general
p
Hey there dear people! ๐Ÿ™‚ I am using pants in CI, but the caching is not working - everytime I push, all the tests from all projects are executed again. What am I doing wrong? my CI looks like:
Copy code
steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Setup python
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"
      - name: Setup pants
        uses: pantsbuild/actions/init-pants@v5-scie-pants
        with:
          # v0 makes it easy to remove the cache if needed
          # increase the integer to start with a fresh cache
          gha-cache-key: v0
          named-caches-hash: ${{ hashFiles('python_default.lock') }}
          cache-lmdb-store: "true"
      - name: Check BUILD files
        run: |
          pants tailor --check update-build-files --check ::
      - name: Lint
        run: |
          pants lint ::
      - name: Test
        run: |
          pants test ::
      - name: Delete pants cache if too big
        run: |
          # See: <https://www.pantsbuild.org/docs/using-pants-in-ci>
          source scripts/utils/utils.sh

          delete_cache_if_too_big ~/.cache/nce 512
          delete_cache_if_too_big ~/.cache/pants/named_caches 1024
      - name: Upload pants log
        uses: actions/upload-artifact@v3
        with:
          name: pants-log
          path: .pants.d/pants.log
        if: always()
Thanks so much! Really appreciate the help! ๐Ÿ™
b
Sorry for the trouble. Is there logging from the init pants action about downloading the cache?
p
Yep, there is - that's the stranger part ๐Ÿค” thanks so much for your help dear @broad-processor-92400!
b
Do you know what changed since it was last working?
Ah, another debugging tip: set https://www.pantsbuild.org/docs/reference-stats
Copy code
[stats]
log = true
(or
PANTS_STATS_LOG=true
env var), and compare the output between a run that definitely doesn't have the LMDB cache restored, and one that (attempts) to.
p
Thanks so much! ๐Ÿ™ could it be because I added these fields to pants.toml?
Copy code
local_store_dir = ".cache"
local_cache = true
local_execution_root_dir = "/tmp/pants"
so that pants tries to find cache in
.cache
instead of
~.cache
?
b
Yeah, that seems likely. if you move the cache from the default youโ€™ll need to save/restore it yourself, the action wonโ€™t be able to do it
p
I see! Thanks a lot ๐Ÿ™ so I basically add another step to the gha that simply copies it to the local folder set in pants.toml, before running lint and test - right? ๐Ÿ™‚
b
I think it may be better to run the caching action in yourself, do what the init pants action does but in your own code with custom pathโ€ฆ unless the action already supports custom paths?
๐Ÿ™Œ 1
p
makes a lot of sense! thanks a lot ๐Ÿ™‚
i will check for custom paths
@broad-processor-92400 I set up the right path, using the
named-caches-location
parameter, and it is working back with linting, but not with tests ๐Ÿค” do you know what might be causing this difference? In the post setup pants I get this logs:
Copy code
Cache Size: ~154 MB (161432652 B)
Cache saved successfully
Cache saved with key: pants-lmdb-store-Linux-v0-479432448f0215f4da53536a583000de2b7bccd6
Post job cleanup.
Cache hit occurred on the primary key pants-named-caches-Linux-v0-f4e0953fa68e59aef2feeb91dfb839b5c18d3e6a85f5c897703b00a7207b37d9-b4c764092de4751ce3094311b57b7e0d7dae75afaf66f6f88b9368f16c5a84a5, not saving cache.
Post job cleanup.
Cache hit occurred on the primary key pants-setup-***thon_distribution_hash=f3ff38b1ccae7dcebd8bbf2e533c9a984fac881de0ffd1636fbb61842bd924de pants_version=2.17.0, not saving cache.
Could it be related to the "not saving cache"? Or should I also set the
lmdb-store-location
parameter in the action?
Setting
lmdb-store-location
has worked, now it caches tests as well! ๐ŸŽ‰ thanks so much dear @broad-processor-92400 ๐Ÿ™ always appreciate a lot the support!
๐Ÿ‘ 1