-
Notifications
You must be signed in to change notification settings - Fork 104
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
PDK validate should have the ability to exclude directories #329
Comments
It looks like the validators could use a bit more strict
Until this is fixed, you can |
With the following Rakefile puppet-lint and puppet syntax checks should be excluding certain paths but this isn't working: PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.send('disable_trailing_comma')
PuppetLint.configuration.send('disable_arrow_on_right_operand_line')
exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
bundle/**/*
.bundle/**/*
spec/**/*
)
Rake::Task[:lint].clear
PuppetLint::RakeTask.new :lint do |config|
# Pattern of files to ignore
config.ignore_paths = exclude_paths
# Should puppet-lint prefix it's output with the file being checked,
# defaults to true
config.with_filename = false
# Should the task fail if there were any warnings, defaults to false
config.fail_on_warnings = true
# Format string for puppet-lint's output (see the puppet-lint help output
# for details
config.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
# Print out the context for the problem, defaults to false
config.with_context = true
# Enable automatic fixing of problems, defaults to false
config.fix = false
# Show ignored problems in the output, defaults to false
config.show_ignored = true
# Compare module layout relative to the module root
config.relative = true
end
PuppetSyntax.exclude_paths = exclude_paths |
@DavidS
I could run each validator individually, but this means I could no longer use |
There is also a |
@brwyatt good point. I discovered there is a poorly documented rubocop option that could be passed As a workaround for rubocop issues, you should be able to set specific cop exclusions for the affected files in
Normally, you shouldn't have anything in the fixtures folder when validate runs, but an aborted unit test run will skip the cleanup step and leave fixtures sitting around that can get picked up by validate. If you run unit tests again to completion that should be resolved. |
Odd, the unit tests are running to completion... so maybe there's an additional bug here, as they don't seem to be getting cleaned up after the unit test run (though it does claim to have cleaned up). Either way, the exclusions should really be working, especially since Until then, is there a way to make rubocop run with |
Not sure what's going on there then. You might want to open a separate issue on that.
Agreed. My guess is that PDK will ultimately handle all file inclusion / exclusions at some point instead of deferring that responsibility to the individual tools and their separate config files. This will probably be a better story for new users, but it is causing some trouble at the moment. @DavidS do you have anything you can share on the intent here?
No, that was just a crazy idea I had. PDK doesn't support arbitrary options, but, if you ask me, it sounds like a good flag to tack on if better support for exclusions is going to be hard to add. |
Adding exclude_paths array should be possible to all rake tasks I would think. So I don’t think passing this to all jobs should be hard. |
@cdenneen Opened https://tickets.puppetlabs.com/browse/PDK-663 to track adding support for some of the existing configuration patterns. @jeremy-asher @brwyatt @jacobmw the PDK currently has no provisions for working in a control-repo. Some folks, like https://github.com/example42/psick had some success retrofitting their control-repo to look like a module to the PDK, but that is not what we ultimately want as a workflow. |
@DavidS I discovered this issue when I ran Do you have any suggestions how the exclusions can be addressed in the PDK codebase? I'd be happy to take a stab at a PR. |
@jeremy-asher This issue starts with "I am using pdk on my control repo and would like the ability to ignore everything under my modules directory", if you have a different use-case/failure/issue, please open a new one describing your experience. |
@DavidS ah, sorry. I must be blind. Didn't mean to hijack this issue, but it was related. I can open another more general exclusion issue. |
@DavidS yeah, while this issue is "control-repo" related I did send the same similar "module" issue to the mailinglist about it happening with non "control-repo" as well. Not sure where that sits but that would be better related to @jeremy-asher issue. |
This is also painful when trying to add plans to a module, where the validation will need to be slightly different. |
#586 should help with plan validation errors. |
Still new to Puppet, but... If I run the following on a 64-bit Windows 10 box (using PDK 1.17.0), this still seems to be an issue:
It seems that PDK VALIDATE is still ignoring the exclusions in the .rubocop.yml file....? |
Hmmm, rubocop should only be checking files that end in |
I can't seem to replicate this.
AllCops:
DisplayCopNames: true
TargetRubyVersion: '2.1'
Include:
- "./**/*.rb"
Exclude:
#- bin/*
- ".vendor/**/*"
- "**/Gemfile"
- "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
@RFBennet Can you verify the contents of your |
I ran this just now on my Win10 box running PDK 1.17.0:
and here's the first portion of the .rubocop.yml file:
And for whatever its worth, I ran the same basic set of commands on a Mac running Catalina OS (and PDK 1.17.0), and didn't see all the gunk from PDK VALIDATE (it was nice and clean as I'd expect). So it looks like this issue could maybe be limited to Windows only....? |
That's even stranger because I ONLY use Windows... will try your repro instructions again. |
Hrmm...
Do you have a Ref - https://rubocop.readthedocs.io/en/latest/configuration/#config-file-locations Also try using
|
Yep, I've got the typical .rubocop.yml file in the root of the new project, and didn't see any in other spots that would potentially be impacting this project (only files within the C:\Projects directory are some .PS1 files I was tinkering with, and C:\ just has two .sys files). Only other thing that may be in play that I can think of offhand is that I'm on an Active Directory bound 64-bit Windows 10 computer. Not sure if a domain account versus a local account could be an issue. Here is the output from trying things with a brand new module (if you notice in the below contents, my Active Directory home directory is mapped as H:):
|
Oh interesting. Thanks for that @RFBennet |
I've started a discussion here for any interested parties wanting to define how we go about implementing a global include/exclude list for all validators in the PDK: #1066 |
@RFBennet I could not reproduce the issue you were seeing with PDK 2.1 on a Windows host following the steps you provided. Can I confirm if you're still seeing this issue? |
As mentioned above the conversation around include/exclude functionality has been moved to #1066 . I'm going to close this issue, but @RFBennet , please do raise another issue if you're still encountering issues and we'll try to get to the bottom of it. |
I am using pdk on my control repo and would like the ability to ignore everything under my modules directory and only test my code.
something like:
'pdk validate --exclude modules/'
The text was updated successfully, but these errors were encountered: