Glob patterns should work for excludes
See original GitHub issueI was just trying to optimize the cache archive size in a project by excluding some unnecessary files like so:
path: |
~/.gradle/wrapper/dists
!~/.gradle/wrapper/dists/**/gradle*.zip
The zip files still get included, so glob patterns don’t seem to work for excludes.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
glob exclude pattern - python - Stack Overflow
You can't exclude patterns with the glob function, globs only allow for inclusion patterns. Globbing syntax is very limited (even a [!.
Read more >Tips for writing glob patterns in DeepSource configuration
exclude_patterns are a list of glob patterns that should be excluded when the analyses are run. These patterns should be relative to the ......
Read more >Exclude one pattern from glob match - Unix Stack Exchange
Suppose that you have some file foo.sh that you want exclude from your operation, yet you want to add csv to every other...
Read more >How to use --exclude glob patterns? #1928 - GitHub
Background I've been reading through issues like #759 and it seems that Universal Ctags does support some globbing patterns for --exclude.
Read more >glob() - Buck
exclude (defaults to [] ) A list of patterns that identify files that should be removed from the set specified by the first...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is still reproducible.
In practice, glob patterns do work for excludes, however, the semantics might be non-trivial.
cache
package resolves the patterns as follows: https://github.com/actions/toolkit/blob/9ad01e4fd30025e8858650d38e95cfe9193a3222/packages/cache/src/internal/cacheUtils.ts#L42-L53I believe the intention was like “prepare the list of directories to be added to the archive” to avoid having long list of the files.
In practice, the glob from description resolves to
~/.gradle/wrapper/dists
directory. In that case, the negative pattern has nothing to exclude, because, well, the first positive pattern does not really descend to the directory, and the full directory is added to the tar manifest.The fix could be a) Use
implicitDescendants=true
and ignore all the directories (== resolve the glob to the exact files, and pass them to tar). That would require code change intoolkit/packages/cache
. b) Workaround the behavior. In other words, avoid including the directory which might have excluded files. One could include the relevant subdirs explicitly.In other words, instead of
one could use
That pattern would work because the first one would enumerate all the files, it would get names like
gradle-6.6
,gradle-6.6-bin.zip
,gradle-6.6-bin.zip.lck
,gradle-6.6-bin.zip.ok
. Then the second negative would trigger and it would exclude the zip file.In practice, the only useful directory in that folder is like
wrapper/dists/gradle-6.6-bin/dflktxzwamd4bv66q00iv4ga9/gradle-6.6
, so the pattern could beThe trailing slash would select directories only which is exactly what the original pattern supposed to do.
PS. All of the above is not really needed in case https://github.com/burrunan/gradle-cache-action is used for caching or Gradle execution 😉