JohnnyMorganz / stylua-action

GitHub action for StyLua
MIT License
51 stars 6 forks source link

[Feature Request] Files-changed filter #37

Open Stanzilla opened 2 years ago

Stanzilla commented 2 years ago

Hey there! We have quite a big repo and running StyLua on all the files on every commit takes quite a bit (20min), and I was wondering if you'd be open to adding a filter to only run on changed files, like reviewdog does here https://github.com/reviewdog/reviewdog#filter-mode

JohnnyMorganz commented 2 years ago

Definitely sounds reasonable to add to me.

Slightly concerned about the 20min time to run the formatter though, I wouldn't expect it to take that long. Is there anything in particular that stands out in taking a long time to format for you? Although if its an extremely large repo, then maybe it makes sense

If you pass the --verbose flag to stylua on the command line, it outputs timings

JohnnyMorganz commented 2 years ago

Just wanted to also mention, you can probably do this already either by using git diff --name-only or something like https://github.com/marketplace/actions/changed-files, then piping the list of changed files in as arguments to stylua (maybe with xargs)

Stanzilla commented 2 years ago

Just wanted to also mention, you can probably do this already either by using git diff --name-only or something like github.com/marketplace/actions/changed-files, then piping the list of changed files in as arguments to stylua (maybe with xargs)

Yup was considering doing that!

Here's the 20min https://github.com/WeakAuras/WeakAuras2/runs/7940500923?check_suite_focus=true

JohnnyMorganz commented 2 years ago

Had a quick look, on my machine these file timings seems to be the slowest ones to me:

debug: formatted .\WeakAuras\Prototypes.lua in 4.3554156s
debug: formatted .\WeakAurasTemplates\TriggerTemplatesData.lua in 8.8273347s
debug: formatted .\WeakAurasModelPaths\ModelPathsClassic.lua in 128.721485s (!!)
debug: formatted .\WeakAurasModelPaths\ModelPathsBCC.lua in 401.1322888s (!!)
terminated on .\WeakAurasModelPaths\ModelPaths.lua, taking > 10mins

Everything else takes a second or less

Not too suprised on those ModelPaths ones (they are all large files, ModelPaths.lua is 13.3MB!) but I bet we can squeeze out some performance here. You may find that you just want to ignore the WeakAurasModelPaths directory in a .styluaignore file