From 5b60d02f859e9b7ff383a7963f77bd080717b66e Mon Sep 17 00:00:00 2001 From: Benjamin Gutzmann Date: Fri, 22 Dec 2023 18:18:00 +0100 Subject: [PATCH] Split pre commit config into single executable tasks --- .github/workflows/lint.yml | 4 ++-- .github/workflows/tests.yml | 2 +- .github/workflows/typing.yml | 38 ++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 18 ----------------- pyproject.toml | 22 ++++++++++++++++++++- 5 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/typing.yml delete mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1dd7208..b004e2d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,7 @@ jobs: - name: Install project run: | python -m pip install --upgrade pip - pip install '.[dev,examples]' + pip install '.[dev]' - name: Lint - run: pre-commit run --all-files + run: poe lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 384cb86..d26d144 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: pip install '.[dev,examples]' - name: Test - run: pytest + run: poe test - name: Examples run: python examples/check_timesteps.py tests/data diff --git a/.github/workflows/typing.yml b/.github/workflows/typing.yml new file mode 100644 index 0000000..90bf62a --- /dev/null +++ b/.github/workflows/typing.yml @@ -0,0 +1,38 @@ +name: Typing + +on: + push: + branches: [ main ] + + pull_request: + branches: [ main ] + + # Allow job to be triggered manually. + workflow_dispatch: + +# Cancel in-progress jobs when pushing to the same branch. +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + typing: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + architecture: x64 + cache: pip + + - name: Install project + run: | + python -m pip install --upgrade pip + pip install '.[dev]' + + - name: Typing + run: poe typing diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index a14449a..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,18 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - args: ["--maxkb=1000"] - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 - hooks: - - id: mypy - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 - hooks: - - id: ruff - - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 9442074..8f8d142 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = ["click~=8.0", "pandas~=1.3"] isd = "isd.cli:main" [project.optional-dependencies] -dev = ["mypy~=1.2", "pre-commit~=3.2", "pytest~=7.4", "ruff~=0.1.9"] +dev = ["mypy~=1.2", "pytest~=7.4", "ruff~=0.1.9", "poethepoet>=0.24.4", "black>=23.12"] examples = ["tqdm~=4.66"] docs = ["sphinx~=7.2"] @@ -27,3 +27,23 @@ build-backend = "setuptools.build_meta" [tool.mypy] strict = true + +[tool.poe.tasks] +format = [ + { cmd = "black ." }, + { cmd = "ruff --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 ." }, +] + +lint = [ + { cmd = "ruff ." }, + { cmd = "black --check ." }, +] + +typing = [ + { cmd = "mypy src --ignore-missing-imports" }, + { cmd = "mypy tests --ignore-missing-imports" }, +] + +test = [ + { cmd = "pytest" }, +] \ No newline at end of file