Wikidata / soweego

Link Wikidata items to large catalogs
https://meta.wikimedia.org/wiki/Grants:Project/Hjfocs/soweego_2
GNU General Public License v3.0
96 stars 9 forks source link

Replace Travis with pre-commit #429

Closed marfox closed 3 years ago

marfox commented 3 years ago

you may look into pre-commit to automatically run type checking, linting, formatting, etc. on commit

Very interesting suggestion! We currently have a similar mechanism in place on Travis CI, see this dotfile. However, it's a bit hacky and doesn't run mypy type hints check. From a first glimpse, it looks like pre-commit is a much better solution:

Originally posted by @marfox in https://github.com/Wikidata/soweego/issues/428#issuecomment-911864333

marfox commented 3 years ago

I tried to reproduce the same invocation of isort, autoflake, black as in .travis.yml in the terminal, but the output is different.

/app/soweego# pre-commit run -a

Here's the .pre-commit-config.yaml I used:

repos:
    - repo: https://github.com/pycqa/isort
      rev: 4.3.21
      hooks:
          - id: isort
            args: [-y, -rc, -s soweego/cli.py]
    - repo: https://github.com/myint/autoflake
      rev: v1.4
      hooks:
          - id: autoflake
            args: [-i, -r, --remove-all-unused-imports, --remove-unused-variables]
    - repo: https://github.com/psf/black
      rev: 19.10b0
      hooks:
          - id: black
            args: [-S, -l 80]

Let'see what happens with the CI service

marfox commented 3 years ago

Same behavior, see https://results.pre-commit.ci/run/github/140611498/1630691079.k3f9-icXTHa0TMrXcVJTUA

marfox commented 3 years ago

It looks like the isort hook doesn't work as expected: for instance, it ignores the -s soweego/cli.py option, and actually runs on that file, too.