-
Notifications
You must be signed in to change notification settings - Fork 170
cookbook created by chef generate cookbook fails foodcritic due to test directory #1027
Comments
We are experiencing this same issue on CentOS 6 with ChefDK 18.30. I have to ask, why are we doing away with the Another use case might be one cookbook that runs on different operating systems. If my cookbook runs on both Windows and Linux it's probably not appropriate to check for the existence of config files in Wouldn't it make more sense and ease adoption if all the InSpec tests went in Thanks! |
+1
|
looks like this issue has been around for ever.. Foodcritic/foodcritic#148 |
@mattstratton did you see it as part of workflow? I ran into the same thing, and the bandaid is to use use config.json. I am curious about having a conversation around what's the correct place to fix it - probably foodcritic as default behavior should not scan non-cookbook files |
@vinyar nope. Just doing straight CLI foodcritic. I'm writing something up about chefdk and testing tools, without the context of Workflow, so |
@mattstratton then just use |
We need to fix this in Foodcritic itself. The default exclude needs to include the test dir. It causes issues in Delivery and also for any user just running Foodcritic from the CLI. |
GOOD NEWS: Foodcritic no longer fails due to the test directory. BAD NEWS: Foodcritic now fails for a completely different reason, that is arguably Foodcritic's fault, not the cookbook's fault:
|
Should we keep looking at this here, or should we take it to Foodcritic/foodcritic#503 ? |
This to me is a perfectly reasonable reason for FoodCritic to fail. It would be nice if you could set that somehow (CLI flag and/or knife.rb config), however, I think this is a markedly different failure than failing because the fundamental layout of your cookbook dir structure is "incorrect". |
Neither FC064 nor FC065 are tagged with Output from foodcritic is not an indication of failure, the exit code should be checked for that. If you want to ensure both the output and the command are only showing results of testing for rules tagged with correctness you need to use |
I believe this issue can now be closed. What do you say @mattstratton? |
Foodcritic now excludes test/ dirs by default as of Foodcritic/foodcritic@aa69442 |
Expect a release of Foodcritic within the next few days, which will ship in next months Chef-DK |
Still an issue in ChefDK 1.3.43
The interesting thing, is that with foodcritic 11.0.0 it actually gets a tiny bit worse as it's now failing on
|
At this point our own tooling is executing foodcritic with Is there a strong need from customers to pass out of the box without setting the metadata correctly for Supermarket? |
So we're going to have a hard time with this going forward. Foodcritic sat idle for about 2 years, but I've added 7 rules in the last week. There's going to be a lot more rules coming, which will constantly add new requirements. Also keep in mind that and and out of the box cookbook SHOULD NOT pass. It's not a functional cookbook. It's just a generated skeleton that needs modification before it's ready. |
We might need to find a compromise by which out-of-the-box cookbooks can pass foodcritic in an Automate Workflow context. Because Automate uses the initial project skeleton commit to test out the pipeline, if there's a pipeline failure in the foodcritic phase, then that'll break the pipeline until the project passes. Not a deal breaker, but I think it impacts the use cases that @vinyar sees. @vinyar: Am I putting words in your mouth? |
@charlesjohnson when this issue was first opened the issue was that foodcritic was generating erroneous errors based on changes to the default test framework (i.e.: the change over from ServerSpec to InSpec). The change in directory structure caused FoodCritic to incorrectly find that there was no README.md, etc. for the "cookbook" in the The errors posted by @vinyar are not erroneous however. These are errors that I would expect to receive until you fix them. These indicate there is something wrong with your cookbook. Your cookbook should have an issues and source URL, even if they're the same (they are in our environment for instance), your cookbook should declare platforms it supports, etc. As these errors are not erroneous and are reporting things that are wrong in the cookbook, I don't think these failures really fit in with the original bug report. In my opinion, the fix for the original issue reported by @mattstratton an update to ChefDK, the fix for @vinyar problem is to update his metadata. I would even argue further that these SHOULD cause automate/foodcritic to explode, if I'm collaborating with a team (pushing cookbooks through Automate or not) then it's even more important to tell people where you can find source, what platforms my cookbook supports, etc. Our standard for communicating that information is to put it in the Metadata. (Having said that, it would be nice to be able to set these as part of the |
@mattstratton is your issue resolved? @vinyar What do you think of the discussion since your update? |
From my perspective, my issue has been resolved. |
Initial issue is closed and the other issue is both by design and unrelated. |
@charlesjohnson the use-case you described is what I was after. If the initial commit fails, the config.json will need to be modified. That puts onus on the user to re-enable testing with the very next commit, or in a less desireable case - at some point in the future. |
Description
After creating a skeleton cookbook with
chef generate cookbook
, it results in a cookbook that fails foodcritic validation due to some of the files in thetest/
directory.Example:
ChefDK Version
ChefDK version:
Platform Version
OS X Sierra
Replication Case
To replicate, create a new cookbook using
chef generate cookbook
and then executefoodcritic .
in that directory.The text was updated successfully, but these errors were encountered: