Ellerbach / docfx-companion-tools

A suite of tools, pipelines templates to take the very best of DocFX
MIT License
64 stars 18 forks source link

Investigate how to create a megalinter plugin #30

Open Ellerbach opened 1 year ago

Ellerbach commented 1 year ago

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.

nvuillam commented 1 year ago

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

Ellerbach commented 1 year ago

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

nvuillam commented 1 year ago

@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 commented 1 year ago

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

DariuszPorowski commented 1 year ago

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

nvuillam commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

DariuszPorowski commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@Kurt-von-Laven will try, thanks!

DariuszPorowski commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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