is there some funky magic going on with yamllint a...
# general
h
is there some funky magic going on with yamllint and yaml files in
.github/
? i’m trying to use pants to lint my workflow files, but yamllint seems to be ignoring those files altogether (
yamllint .
raises errors but
pants lint ::
says yamllint passed without any errors). I thought the issue might be that i needed to add a
resources
target, but the file is ignored by pants in the
.github/
directory. (see in thread)
/BUILD
Copy code
resources(
    name="yml-one",
    sources=[".github/dependabot.yml"],
)

resources(
    name="yml-two",
    sources=["github/dependabot.yml"],
)
Copy code
➜  ✗ touch .github/dependabot.yml 
➜  ✗ touch github/dependabot.yml 
➜  ✗ pants dependencies --transitive //:yml-one
13:54:46.78 [WARN] Unmatched glob from //:yml-one's `sources` field: ".github/dependabot.yml"

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.19/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
➜  ✗ pants dependencies --transitive //:yml-two
//github/dependabot.yml:../yml-two
g
It's likely hitting this default setting: https://www.pantsbuild.org/2.19/reference/global-options#pants_ignore. Pants ignores all dot-files unless otherwise noted
🙌 1
c
the link in the WARN message is relevant 😉
h
ah, it’s the default then. I noticed the warning but I wasn’t actually setting
pants_ignore
so I didn’t understand why it would be getting ignored
is there a reason for the default not to be blank/ equivalent to what exists in
.gitignore
? seems more intuitive to me 🤷‍♂️
c
good point, so the current value of
pants_ignore
could be included in that message making it more illustrative.
💯 2
the default is to ignore known files commonly not used by pants, so you don't need to set it up every time.
in light of the above, it could make sense to have
!.github
by default as well, as those files are more of a source code kind..
🙌 1
f
with this you'll be able to run
pants lint .github::
Copy code
diff --git a/pants.toml b/pants.toml
index 6d2dd3d..adae927 100644
--- a/pants.toml
+++ b/pants.toml
@@ -4,10 +4,12 @@ ignore_warnings = [
   '$regex$DEPRECATED',
 ]
 pythonpath = ["%(buildroot)s/pants-plugins"]
+pants_ignore.add = ["!.github/" ]
 
 backend_packages = [
   "pants.backend.shell",
   "pants.backend.python",
+  "pants.backend.experimental.tools.yamllint",
   "pants.backend.python.lint.black",
   "pants.backend.python.lint.flake8",
   "pants.backend.python.lint.docformatter",
it may be not obvious that you can use the special
.add
syntax that Pants is able to parse
allowing
.github
directory sounds sensible to me, I raised https://github.com/pantsbuild/pants/pull/20471
🎉 1
h
@fresh-cat-90827 yup, have that set up! the issue was that it wasn’t finding
.github/
🙌 1