-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP] Pronto Integration (v2) #500
Conversation
@@ -4,7 +4,7 @@ def rubocop_results | |||
rubocop = JSON.parse(`rubocop --format=json --no-display-cop-names #{rubocop_check_path}`) | |||
hamllint = JSON.parse(`haml-lint --reporter=json #{rubocop_check_path}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are probably going to need to change these two lines in the future to have the run in a different form. I manually fixed the files to get them into the "Pronto format", but that is not a good long term solution.
A few things worth noting here though:
- The
spec/workers/commit_monitor_handlers/commit_range/rubocop_checker/data/*/
directories are not git dirs, so they don't play well with Pronto's runners, since they assumegit
. - I had two potential approaches two this:
- Convert those directories to git, and use a
FakeResults
class (or something) that inherits from theCodeAnalysisMixin
to share that code - Create a set of fake libs for pronto that stub the git portions of the code to get the results we need.
- Convert those directories to git, and use a
I am not sure what is better at this point, because while the git
approach is probably less code overall, we would either have to do a git init && git add . && git commit -m "Initial"
as part of the block, or commit the .git
dir for each one of these directories, which is... fun. The other option adds a bunch of code we need to support, so not really a big fan of that either.
But decided to sideline fixing that for now to move this forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert those directories to git, and use a FakeResults class (or something) that inherits from the CodeAnalysisMixin to share that code
This sounds good to me, though I don't know why we need the FakeResults class?
commit the .git dir for each one of these directories
We do this in ManageIQ proper, and we didn't have an issue with it, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good to me, though I don't know why we need the FakeResults class?
Because CodeAnalysisMixin
is a module, and we need to be able to set @branch
and such to be able to use .pronto_result
miq_bot/app/workers/concerns/code_analysis_mixin.rb
Lines 32 to 39 in 6bd031c
def pronto_result | |
Pronto::GemNames.new.to_a.each { |gem_name| require "pronto/#{gem_name}" } | |
p_result = nil | |
# temporary solution for: download repo, obtain changes, get pronto result about changes | |
Dir.mktmpdir do |dir| | |
FileUtils.copy_entry(@branch.repo.path.to_s, dir) |
It would just be something really simple like:
class FakeResults
include CodeAnalysisMixin
def initialize(branch)
@branch = branch
end
end
# usage
FakeResults.new(branch).proto_results
We do this in ManageIQ proper, and we didn't have an issue with it, I think
Where? I am curious.
Also, not saying it isn't feasible, but it is kinda ugly checking in a bunch of extra git objects just to view a diff. I think I would rather have the unless File.exists?
be a bit smarter, and do the git repo initialization inside the block (if regenerating, and blow it away if it exists), but not check it in to this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this in ManageIQ proper, and we didn't have an issue with it, I think
Where? I am curious
Okay, I think you are talking about these:
https://github.com/ManageIQ/manageiq/tree/master/spec/fixtures/git_repos
Which those are bare repos. Probably would still work, but would rather avoid checking in a bunch of nest git files, as show for on of those:
$ tree spec/fixtures/git_repos/no_master.git/
spec/fixtures/git_repos/no_master.git/
├── HEAD
├── config
├── objects
│ ├── 43
│ │ └── 0ff1dcee43d2e8a12c3ba36f5ff20e46136152
│ ├── 44
│ │ └── f84e202a8eb9d8d35fc183ae8637db3b003aa8
│ ├── 78
│ │ └── 3878cb3ed5964c75767141176c80f7d528abb5
│ ├── 95
│ │ └── 99fdeb034597d90d72d2f58396dee096885b79
│ ├── ae
│ │ └── fde3a01f6e10d72fd4899ce14c8b2654d3eb45
│ ├── e3
│ │ └── 16f7d7548ea8f874c872ff3be04f4e9849833b
│ ├── e6
│ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│ └── fd
│ └── b4bc8c22f4b3ca8279c2e1eb92670893473d05
├── packed-refs
└── refs
└── tags
├── tag1
└── tag2
11 directories, 13 files
Just for a few specs, especially when the git
part is very inconsequential. It also seems like it would be hard to modify as end users as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah those are it. FWIW, I think having those in core is also weird, so maybe whatever you choose we can do something similar in core as well.
While working on a CLI prototype, I ran into this above: Marking this PR as |
6bd031c
to
2378d4e
Compare
2378d4e
to
aa10142
Compare
Integration of pronto required to add few new gems and to update some of the gems. The old method which provided the linter launching was reworked to launch pronto which provide the linter launching. The output of pronto is the result of all linters. The pronto result is transformed into a structure which match the original one. This integration required to change few tests and add new ones. Closes ManageIQ#192
Request in ManageIQ#406 to remove files in lib/linter/ which are not used
Variable "inspected_file_count" in the result of the linters has been removed due to missing use. It was not used in the pull request comment describing the offenses detected by linters in the source code.
Pronto runners (linters) expected to run will be automatically required in the CodeAnalysisMixin based on Gemfile specifications for pronto runners (linters).
bfb06ce
to
7da63bd
Compare
So working on getting this across the finish line: The last commit simplifies the However, it seems like I might need to tweak some things, because currently it isn't reporting any problems in a PR where I introduced them:
(Edit: The "Good example" was actually a "happy accident" (mistake) that I accidentally opened, but turned out to be helpful 😆 🌲 🌲 ) (Edit 2: Forgot the bot will delete old versions of the comment, so I can't "permalink" to it while I run some tests. The screenshot will be a historical representation of what it was before I made some fixes) Might be related to this comment by Jason: https://github.com/ManageIQ/miq_bot/pull/406/files#r170294743 But will report back when I find out more. |
This makes use of the newly working (I hope) Repo#git_fetch, as well as removes some of the `mktmpdir` logic that shouldn't be required because we are using Rugged.
This pulls back in some deleted code to handle errors with the Rubocop linter (but sets up a pattern for it moving forward).
Our configs for manageiq-ui-classic (which I am using for testing) require newer versions of Rubocop configs to function, so to facilitate the, I have included `manageiq-style` into this repo for testing this PR. Might be required moving forward, but this is just for testing for now.
Right now, what ever is on the "fetched master" for the linter configs will be what is used by Pronto, and not what is up to date with the branch being checked against. This "attempts" to generate a config based on the git blob for the branch we are checking, but it is still not quite working.
7da63bd
to
5331ffc
Compare
Been struggling with this for a few days now, but our configs for Will look more tomorrow and such... |
Checked commits NickLaMuro/miq_bot@aad33e6~...5331ffc with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint Gemfile
app/workers/concerns/code_analysis_mixin.rb
|
So, had a frustrating realization... and unfortunately, it isn't an issue with configs being loaded incorrectly... Turns out that https://github.com/ManageIQ/miq_bot/blob/master/lib/linter/base.rb#L56 And instead, basically assumes that you have checked out the content of the entire branch to disk to then run pronto against it: https://github.com/prontolabs/pronto#local-changes Which is just not how Really kinda sucks, because I honestly think this is just going to be more trouble than it is worth to convert to using Do we start from scratch? Do just continue with our workflow? Do we extract what we have into our own gem? Not really sure at the moment what makes the most sense. |
This pull request is not mergeable. Please rebase and repush. |
Going to close as I don't see this happening. Can reopen if it does. |
This is a rebase of #406 so please view that PR for further details.
Currently, it depends on #498 to be merged first, as they are both changing a lot of the same gems.
Rebased a few commits together to remove some commit noise, but otherwise mostly everything is the same as it was.