From fe0897c8727158c3442a815a440b1fdc254a86f7 Mon Sep 17 00:00:00 2001 From: Renu Singh Date: Fri, 17 Jan 2025 15:39:50 +0100 Subject: [PATCH] Add format and lint checks to cicd --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ pyproject.toml | 6 +++--- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..79a89ad --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: 'Lint codebase' + +on: + pull_request: + branches: [ "main" ] + push: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: pre-commit/actions@v3.0.1 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2d6d5df --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# Config to automatically run checks and fixes of code format on git commit. +# +# To use, run `pre-commit install` in the root of the repository. +# See https://pre-commit.com for more information. + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.9.2 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] # enable lint fixes + # Run the formatter. + - id: ruff-format +- repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + args: ["--skip=*.ipynb", "--ignore-words-list=hist"] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index cea4125..ee9770c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,9 +56,9 @@ ignore = [ "geoarches/backbones/weatherlearn_utils/*" = ["N"] "geoarches/lightning_modules/__init__.py" = ["F401"] - -[tool.poetry.group.test.dependencies] - +[tool.codespell] +skip = "*.ipynb" +ignore-words-list = "hist" [tool.poetry.group.dev.dependencies] pytest = "*"