From ef677268d902707c1041f15d6d02eb13a8c68847 Mon Sep 17 00:00:00 2001 From: Elie Richa Date: Tue, 19 Nov 2024 17:55:26 +0000 Subject: [PATCH] Create a pre-commit configuration and run it in CI --- .flake8 | 6 ++++++ .gitlab-ci.yml | 6 ++++++ .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .flake8 create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..5218dc07c --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +# This is intented for compatibility with Black. See +# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8 +max-line-length = 80 +extend-select = B950 +extend-ignore = E203,E501,E701 \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5beda208a..0c2ff79a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,12 @@ include: # Issue check - component: $CI_SERVER_FQDN/eng/gitlab-templates/check-issue@~latest + # pre-commit + - component: $CI_SERVER_FQDN/eng/gitlab-templates/pre-commit@~latest + inputs: + on-diff: true + stage: check + # Build - component: $CI_SERVER_FQDN/eng/gitlab-templates/build@~latest inputs: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..71f0df8d9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +repos: + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + types: [file] + files: \.(py|anod|plan)$ + additional_dependencies: + - flake8-bugbear + - flake8-builtins + - flake8-comprehensions + # - flake8-docstrings + # - flake8-rst-docstrings + - repo: https://github.com/ambv/black + rev: 24.2.0 + hooks: + - id: black + types_or: [file] + files: \.(py|plan)$ + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + files: '\.py$' + # exclude: "^tests/.+$" + additional_dependencies: + - --extra-index-url + - https://gitlab.adacore-it.com/api/v4/projects/it%2Fpackage-registry/packages/pypi/simple + - pytest-lsp