From 0561221e1f6d20efdec625c8091a1cd9e629b662 Mon Sep 17 00:00:00 2001 From: Fridolin Glatter Date: Wed, 11 Oct 2023 13:40:43 +0200 Subject: [PATCH] TEMPORARY Introduce pre-commit workflow for consistency --- .github/workflows/pytest.yaml | 14 ++++++++++ .pre-commit-config.yaml | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 9b3500cb..40c9355f 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -74,3 +74,17 @@ jobs: run: | source .venv/bin/activate pytest --cov-report xml:.coverage.xml --cov-report term --cov=ixmp4 -rsx --benchmark-skip + + pre-commit: + name: Code quality + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + + - name: Force recreation of pre-commit virtual environment for mypy + if: github.event_name == 'schedule' # Comment this line to run on a PR + run: gh cache delete $(gh cache list -L 999 | cut -f2 | grep pre-commit) + env: { GH_TOKEN: "${{ github.token }}" } + + - uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1bcc385c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: +# - repo: https://github.com/python-poetry/poetry +# rev: 30da950 #update this to next revision that include poetry-install +# hooks: +# - id: poetry-check +# - id: poetry-lock +# - id: poetry-export +# - id: poetry-install +- repo: local + hooks: + - id: mypy + name: mypy + always_run: true + require_serial: true + pass_filenames: false + + language: python + entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@" + # additional_dependencies: + # - alembic + # - black + # - dask + # - fastapi + # - httpx + # - ipykernel + # - mypy + # - nbclient + # - pandas-stubs + # - pandera + # - psycopg[binary] + # - pydantic + # - pydantic-settings + # - pyjwt + # - pytest + # - python-dotenv + # - sphinx + # - sqlalchemy + # - types-toml + # - typer + # - xarray + args: ["."] +- repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.292 + hooks: + - id: ruff \ No newline at end of file