fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
335 stars 51 forks source link

Use Flake 8 to test builds? #107

Closed fralau closed 8 months ago

fralau commented 2 years ago

In #106 it was proposed to use Flake 8.


Just a question but would it be possible to get something simple like a flake8 action/workflow/job to run on changes to this repo to hopefully prevent something like this from happening in the future?

_Originally posted by @mriedem in https://github.com/fralau/mkdocs_macros_plugin/issues/106#issuecomment-976597595_


@fralau Have a look at the workflow we're (@WoltLab) are using to test that our mkdocs documentation builds successfully:

https://github.com/WoltLab/docs.woltlab.com/blob/5.5/.github/workflows/test.yml

Just commit that file to the repository (make the necessary adjustments, e.g. for setup.py) and it will automatically be active. It detected the bad merge: https://github.com/WoltLab/docs.woltlab.com/runs/4300011035?check_suite_focus=true

Full documentation is here: https://docs.github.com/en/actions

_Originally posted by @TimWolla in https://github.com/fralau/mkdocs_macros_plugin/issues/106#issuecomment-976610153_

Guts commented 2 years ago

IMHO I would suggest to promote using flake8 as a git hook through precommit to allow developers check out errors before committing to the project and, optionally, run it in CI through precommit ci.

If you want, I can push a PR and some flake8 configuration that I'm using in the RSS plugin development.

fralau commented 2 years ago

@Guts Thanks a lot for you kind offer for a PR, and with pleasure!

Perhaps you could describe here (for people like me with limited knoweldge of that kind of tools) what it does... and what kind of errors it would catch, not catch, and (if there is any chance of that) erroneously catch?

timvink commented 2 years ago

flake8 is great, but makes a lot of stylistic checks also. I've had it raise errors for things I don't want to 'fix'. Using it requires some work on defining which rules you want to ignore.

I recommend pyflakes, which:

[...] will try very, very hard to never emit false positives.

It would have catched the merge conflict error in #106 :

echo "<<<<<<< HEAD
=======
>>>>>>> new_branch_to_merge_later" > test.py
pyflakes test.py
#> test.py:1:1: invalid syntax
#> <<<<<<< HEAD
Guts commented 2 years ago

@timvink flake8 is built over pyflakes: https://github.com/PyCQA/flake8/blob/main/setup.cfg#L44

You can use flake8 to spot only a selection of errors (white-list) instead of ignoring others (black list). Let me know.

timvink commented 2 years ago

Yes. Just trying to help.