From 5e9068b5f8257a5403f6e5e637a8d90b88f4c2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Tue, 7 May 2024 12:59:23 +0200 Subject: [PATCH] Add type checks to Github Actions --- .github/workflows/mypy.yml | 35 +++++++++++++++++++++++++++++++++++ setup.py | 1 + tox.ini | 6 +++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mypy.yml diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 000000000..c30ed0faf --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,35 @@ +name: Type checking + +on: + push: + branches: + - master + tags: + - "[0-9]+.[0-9]+.[0-9]+*" + pull_request: + branches: + - master + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +jobs: + test: + runs-on: arc-runner + + env: + TOX_COMMAND: "tox --skip-missing-interpreters false" + + strategy: + matrix: + toxenv: ["py310", "py311", "py312"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Mypy + run: | + ${{ env.TOX_COMMAND }} -e mypy diff --git a/setup.py b/setup.py index 6a7e97e40..7338c3ddc 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ "package": ["twine", "wheel"], "test": [ "black==24.1.0", + "mypy>=1.10.0", "django-stubs>=4.2.4", "django-filter-stubs>=0.1.3", "djangorestframework-stubs[compatible-mypy]>=3.14.0", diff --git a/tox.ini b/tox.ini index 31cb23334..cebe9ef5c 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,8 @@ envlist = linters, packaging, extra, - migrations + migrations, + mypy skip_missing_interpreters = True # This is the highest version of tox available on our test server. minversion = 3.5.0 @@ -72,6 +73,9 @@ commands = py3{10,11,12}-partial: --changes-file-types .resolwebio-filetypes.yml \ py3{10,11,12}: --verbosity 2 --parallel + # Check types. + mypy: python -m mypy resolwe_bio + # Docs commands: # Build documentation. docs: python setup.py build_sphinx --fresh-env --warning-is-error