-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache - excluding files or folders with ! not working #713
Comments
Any updates here? |
There is a workaround. Excluding works if you have all patterns in the same "level", for example
this is what we use in apache/pulsar, full example here: https://github.com/apache/pulsar/blob/master/.github/workflows/ci-integration-process.yaml#L55-L65 |
Was trying to cache apt, using
But it still gives me a permission error for trying to access the partial folder in the Post Cache Dependencies Step: |
Thanks for the workaround in #713 (comment). It works like a charm. Here are my findings: # 1. This will cache everything recursively inside `/a` excluding `/a/b`
path: |
/a/*
!/a/b
# 2. This will cache everything recursively inside `/a` including `/a/b`
path: |
/a
!/a/b
# 3. This will cache everything recursively inside `/a` including `/a/b`
# with an unexpectedly huge total cache size (~6x, your mileage might vary)
# and I don't see any visible differences when compared to 1. and 2.
path: |
/a/**
!/a/b
# Conclusion
# Just use 1. for the best of both worlds until the glob issue is fixed.
# Worth mentioning that modifying the value of `path` will affect the caches with the exact same `key`,
# so each cache is unique by its own `key` and `path`. |
Hi guys. Was hitting this as well. Some digging in the code about the likely reason:
(Note: can observe this by enabling step debug logging, see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) Other observation: the negative patterns must come after the positive one, otherwise a last positive match will always win (see
Fix suggestion: pass
In the mean time, the workaround of expanding the paths with |
Trying to exclude pdfs actions/toolkit#713
Just wasted way too much time trying to figure this out. GitHub should really pay more attention to the inconsistencies of glob patterns between different parts of Actions. |
Note that none of the fixes here work if the levels are deeper and there are multiple paths that need to be matched, for example: # Works
path: |
/a/*
!/a/b
# Doesn't work
path: |
/a/*
!/a/b/c
# Works
path: |
/a/*/*
!/a/b/c
path: |
/a/*/*
!/a/b/c
!/a/b/c/d # No longer works |
Describe the bug
Excluding a file or folder does not work as expected with caching. For example,
is matching:
I think this is because caching uses
implicitDescendants: false
. Since we're not traversing any descendants, the negation pattern does not match anything.One option is to just set
implicitDescendants: true
, but this may add inefficiencies as we will need to enumerate all the files and generate a large "includes file" fortar
. We essentially need it to scan the descendants but stop whenever the entire folder is included. For example, the following files:with the glob patterns of
~/cache
and!~/cache/bin
should produce the list:To Reproduce
See https://github.com/dhadka/cache-test-exclusion
Expected behavior
Negated files / folders are excluded from the cache.
The text was updated successfully, but these errors were encountered: