-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Megalinter 7.x _REGEX path handling seems not fully compatible with 6.x #2744
Comments
@pfiaux you're right, it is probably related to relative paths management Did you try to send the list of files with relative path format ? Best regards |
I just checked, looks like I'm already sending the files with relative paths in the config: MEGALINTER_FILES_TO_LINT:
- teamA/mega-linter.yaml
- scripts/ci-lint.sh
- teamB/product1/main.go The outputs from megalinter such as |
I'm also fine with another solution even if it's not compatible with the v6 config, as long as we can filter by base path :) Sticking an absolute path in the config would be problematic tho, for us the absolute path isn't fixed and dependents on which linter instance will pickup the job (we run multiple replicas). |
I agree that it's an issue... Would you mind sharing the full log with If sensitive you can eventually send it to me to nicolas.vuillamy@gmail.com |
This issue has been automatically marked as stale because it has not had recent activity. If you think this issue should stay open, please remove the |
@nvuillam did you get my email / have a chance to take a look? Let me know if there's something I can look into from my side (we're stuck on v6 until we find a workaround/solution) |
I retested this with 7.2.0 today, results are still the same:
|
The filters for linters are applied in In In my case it's using Would it work if |
@pfiaux I apologize for the delay, the summer was full and not a lot of time for advanced issues :/ Any change you can reproduce the issue locally ? Or what if I add a custom debug variable that would display the values of variables in utils.py when filtering ? |
Well I can reproduce it in our CI, locally I'm on macOS with the virtualization performance it would take me ages to run it locally. I will bump to v7.3.0 and try again but from the changelog I don't think you change the paths so I expect I can reproduce it. From digging into the code I suspect the linter filters are passed absolute paths and so their relative path handling isn't leveraged at all. A debug statement might help confirm that, I wonder if there's a faster way to avoid too many loops between you add something and I test it. I need to check if I can add a debug myself or even maybe attempt a patch. |
I can confirm still happens in v7.3.0. |
It is definitely possible to edit the MegaLinter Python code directly in a MegaLinter Docker container and iterate more quickly that way. |
I'm having trouble testing in the large image in CI (nonroot image and other CI hardening) but I was able to reproduce it with a small gist locally. I suggest the following change as it seems to make it work from the perspective of the filtering: diff --git a/megalinter/MegaLinter.py b/megalinter/MegaLinter.py
index 8bcb894d5e..261394bb0d 100644
--- a/megalinter/MegaLinter.py
+++ b/megalinter/MegaLinter.py
@@ -630,7 +630,7 @@ class Megalinter:
all_files = list()
for file_to_lint in files_to_lint:
if os.path.isfile(self.workspace + os.path.sep + file_to_lint):
- all_files += [self.workspace + os.path.sep + file_to_lint]
+ all_files += [file_to_lint]
else:
logging.warning(
"[File listing] Input file " See here for a small example that should be easy to reproduce locally: |
This part has been tricky when switching from absolute to related paths in files... i'm afraid to break everything ^^ What if I add a config variable that would activate such behavior only if set to true ? |
I figured as it sits pretty early in the processing the impact could have a large blast radius. A config option would work for our use case. If you're willing to add that we'll be very happy to upgrade to V7 and to provide feedback if we run into other issues because of that option. The other alternative I thought of of would be to keep a list of both, say:
|
@pfiaux I think I just understood your use case, which is not so usual :) Do you confirm you send yourself the list of files using variable MEGALINTER_FILES_TO_LINT ? |
Correct, we set |
* Fix v7 issue when using MEGALINTER_FILES_TO_LINT Fixes #2744 * cspell
@pfiaux please can you check with beta version? |
Rolling it out now, did a quick test and it was working as expected so I think we're good. Thanks for the help 🙇 |
@pfiaux great, so you'll be able to upgrade to v7 at the next release :) ( should be in 2 weeks maximum ) |
Is there an ETA on when the next release is? |
@ashokm 2 weeks maximum :) |
I just tested against |
@ashokm if this is another problem, you should declare it in another issue :) |
* Fix v7 issue when using MEGALINTER_FILES_TO_LINT Fixes oxsecurity#2744 * cspell
Describe the bug
We're using regex to limit which paths specific linters run on (monorepo setting):
So our linter configs might look like this:
We use
^
in front to limit it to root folders, for example:scripts/*
files will be covered by the python linterteamA/scripts/*
shall not be covered by the python linterTo Reproduce
Assuming there are go file that would trigger a
revive
lint errors in:test/guilty.go
teamA/test/guilty.go
GO_REVIVE_FILTER_REGEX_INCLUDE: ^(test)
test/guilty.go teamA/test/guilty.go
For 6.22 only
test/guilty.go
shall remain after running the filters.For 7.x no files remain after running the filters.
Expected behavior
The ability to use to filter root of workspace level folders by linter in v7,
ideally via
_FILTER_REGEX_INCLUDE
to be backward compatible with v6.(another solution that achieves the same goal would also work)
Additional context
We're running mega-linter in ci (using the image with everything), and passing it a list of files to lint
determined by our pipeline.
I feel this could be due to the switch from relative paths to absolute paths, which would cause the
^teamA/...
to not match if the path is/tmp/.../teamA/...
The text was updated successfully, but these errors were encountered: