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

Investigate how to create a megalinter plugin #30

Open
Ellerbach opened this issue May 16, 2023 · 16 comments
Open

Investigate how to create a megalinter plugin #30

Ellerbach opened this issue May 16, 2023 · 16 comments
Labels
enhancement New feature or request

Comments

@Ellerbach
Copy link
Owner

See https://megalinter.io/latest/plugins/
Megalinter allows to create plugin. This can be a nice and convenient way to get the tools integrated in a larger linter infrastructure.

@Ellerbach Ellerbach added the enhancement New feature or request label May 16, 2023
@nvuillam
Copy link

Great idea :)
If you need support, don't hesitate to ask in the repo issues :)

@Ellerbach
Copy link
Owner Author

@nvuillam feel free to help :-) PR very welcome as well ;-)

@nvuillam
Copy link

nvuillam commented May 19, 2023

@Ellerbach it is basically one YML descriptor file with some info about how to call our linter, + one (optional but recommended) README :)

Example:

Another even more simple example: https://github.com/kpj/jupyfmt/blob/master/mega-linter-plugin-jupyfmt/jupyfmt.megalinter-descriptor.yml

Much easier to write for people with the knowledge about the linters, so with my current backlog I'm afraid the PR won't come from me ^^

@Ellerbach
Copy link
Owner Author

Thanks, we'll definitely look at this. We'll ping you here/open issue if we have questions.

@DariuszPorowski
Copy link
Contributor

Hey @nvuillam :) I have a few Q? :)

  • How to run plugin together with documentation flavor?
  • How to use GITHUB_TOKEN passed to mega-linter for tool from plugin's descriptor?
  • How to use debian/ubuntu install style for tool's installation in plugin descriptor? know only RUN is possible but it looks like only alpine setup is supported, or I missed something?

@nvuillam
Copy link

nvuillam commented May 20, 2023

@DariuszPorowski glad to (again) see you onboard :)

Like any other plugin , using PLUGINS property :) -> https://megalinter.io/beta/plugins/#use-external-plugins
If docfx is dotnet based as I suspect, you should better use dotnet flavor to avoid to time required to install dotnet on documentation flavor ^^ ( example here -> https://megalinter.io/beta/descriptors/csharp_csharpier/#installation-on-mega-linter-docker-image )

With secured variables, it's not passed anymore -> https://megalinter.io/beta/configuration/#environment-variables-security
I could create a SECURED_VARIABLES_ALLOWED=GITHUB_TOKEN , or even linter_name_SECURED_VARIABLES_ALLOWED=GITHUB_TOKEN
Meanwhile you can override SECURED_ENV_VARIABLES_DEFAULT !

No debian/ubuntu, as it just runs the command on MegaLinter alpine-based image before running the linters :)

@DariuszPorowski
Copy link
Contributor

@nvuillam will look at vars, but Q around flavor was because I created the configuration exactly in that matter, but when I use docs flavor, it shows me no litter found. And it's not error from the litter container but ML config :D on full image all is good

@nvuillam
Copy link

There was a bug using plugins with flavors, but i think we solved it, did you try with beta version?

@DariuszPorowski
Copy link
Contributor

And one more, pulling GH action with ML takes 2-3 mins each time. Have you explored any options to cache it inside gh actions?

@DariuszPorowski
Copy link
Contributor

DariuszPorowski commented May 20, 2023

There was a bug using plugins with flavors, but i think we solved it, did you try with beta version?

Nop, the latest stable one. Will try with beta. :)

@nvuillam
Copy link

And one more, pulling GH action with ML takes 2-3 mins each time. Have you explored any options to cache it inside gh actions?

I think @Kurt-von-Laven tried it... me not personally yet ^^

If you have a simple recipe i'm all ears :)

@Kurt-von-Laven
Copy link

Yes, we created ScribeMD/docker-cache for this purpose. If you need still better performance, one could also add an argument to mega-linter-runner so that it pulls from ghcr.io by default in v7 but can still pull from Docker Hub.

@DariuszPorowski
Copy link
Contributor

@Kurt-von-Laven will try, thanks!

@DariuszPorowski
Copy link
Contributor

@Kurt-von-Laven @nvuillam tested, ScribeMD/docker-cache works, does the job, had to switch from official ml action to npx mega-linter-runner, but it looks like restore from cache is longer than pulling each time. pulling takes on avg ~35s, restoring from cache ~50s (documentation flavor). So probably for bigger images like full megalinter makes sens :)

@Kurt-von-Laven
Copy link

Shoot. docker-cache does have some overhead, because it has to extract and load the image from the cache rather than pull layers directly. I am glad you measured! Your best bet is probably to switch mega-linter-runner to use ghcr.io instead of Docker Hub then since that will get you the best pull times. Which runner did you test on for my awareness?

@DariuszPorowski
Copy link
Contributor

@Kurt-von-Laven used ubuntu-latest, will try with ghcr.io, and let you know :)

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

No branches or pull requests

4 participants