Skip to content
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

Formatters-only flavor #2921

Closed
withinfocus opened this issue Aug 29, 2023 · 18 comments · Fixed by #3071
Closed

Formatters-only flavor #2921

withinfocus opened this issue Aug 29, 2023 · 18 comments · Fixed by #3071
Assignees
Labels
enhancement New feature or request

Comments

@withinfocus
Copy link

Is your feature request related to a problem? Please describe.

We desire a dual-use model of Mega-Linter as a pre-commit hook and a GitHub action, with the separation being formatters-only with the former and the entire suite with the latter. Put another way, we only want to address matters that are format-related locally, ideally with autofixing, to keep commits reasonably fast.

Describe the solution you'd like

A flavor that is only formatters -- and not overall linters -- to run with mega-linter-runner.

Describe alternatives you've considered

A combination of other settings, but we still have too much running locally that we'd like to defer to later.

@nvuillam
Copy link
Member

nvuillam commented Aug 31, 2023

The idea looks interesting :)

And as we have a is_formatter property on linter descriptors, it should be doable :)

cc @Kurt-von-Laven @bdovaz @echoix what do you think ?

@nvuillam nvuillam self-assigned this Aug 31, 2023
@Kurt-von-Laven
Copy link
Collaborator

@withinfocus, are you already aware of the megalinter-incremental hook? We run it locally, and it's quite fast on a typical commit that doesn't touch every file in the repository, because it skips linters that run in project mode.

@withinfocus
Copy link
Author

@Kurt-von-Laven yes indeed and that's what we have in place today, but it can still output results that are not formatting-related and potentially block a commit. We desire format-only to require success from Mega-Linter and allow potentially-subjective results from non-formatters to run later and not block commit (or even merge, such as during PR review).

@Kurt-von-Laven
Copy link
Collaborator

In that case, I can't think of a better solution than a formatter-only flavor.

@echoix
Copy link
Collaborator

echoix commented Sep 1, 2023

I'd be interested in knowing for now, if the difference in image size would be worth building that additionnal flavor constantly, vs just deactivating the unneeded flavors. I expect that the set of linters change someday, but maybe we are quite close with what we have. Let's measure it with a proof of concept!

@withinfocus
Copy link
Author

A flavor is one option but I thought that easier to implement than another configuration variable during invocation. If it's better for the product to have a FORMATTERS_ONLY or somesuch I think that's also very usable, but the cost then is a larger image utilization on each run and that seems more wasteful computationally.

@nvuillam
Copy link
Member

nvuillam commented Sep 1, 2023

We probably can handle both: a Formatters flavor + an option to run only formatters in any MegaLinter flavor, including the big one :)

@Kurt-von-Laven
Copy link
Collaborator

We could rename --filesonly to --files-only (keeping the original name as an alias for backwards compatibility), and add --formatters-only to mega-linter-runner?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Oct 2, 2023
@withinfocus
Copy link
Author

Still desired!

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Oct 3, 2023
@nvuillam
Copy link
Member

nvuillam commented Oct 3, 2023

@withinfocus the backlog is big, and the available time is thin , you are right to post a reminder ;)

Copy link
Contributor

github-actions bot commented Nov 3, 2023

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Nov 3, 2023
@withinfocus
Copy link
Author

Still desired!

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Nov 4, 2023
nvuillam added a commit that referenced this issue Nov 4, 2023
Fixes #2921
Co-authored-by: Matt Bishop <1046132+withinfocus@users.noreply.github.com>
@nvuillam
Copy link
Member

nvuillam commented Nov 4, 2023

@withinfocus it's on the way :)

nvuillam added a commit that referenced this issue Nov 4, 2023
* [automation] Auto-update linters version, help and documentation

* trvy

* New formatters flavor

Fixes #2921
Co-authored-by: Matt Bishop <1046132+withinfocus@users.noreply.github.com>

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
@nvuillam
Copy link
Member

nvuillam commented Nov 5, 2023

@withinfocus the formatter flavor is available in beta :)

https://megalinter.io/beta/flavors/formatters/

@withinfocus
Copy link
Author

Amazing! We'll try this out shortly.

@withinfocus
Copy link
Author

This is successfully working in a private template repository. Anything we can help with to get this to leave beta? Testing was light but given the "is formatter" flag being the one real change used here it seems pretty safe to be considered stable.

@nvuillam
Copy link
Member

nvuillam commented Nov 6, 2023

@withinfocus it will be in the next minor release :)
Probably in the next 2 weeks ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants