From 90c0d9f5870f2b397284a0f49b7fd6a1da64d706 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 23 Feb 2024 19:05:37 +0530 Subject: [PATCH] use pre-commit instead of gh workflow Signed-off-by: Anupam Kumar --- .github/workflows/lint-n-static-analysis.yml | 49 -------------------- .pre-commit-config.yaml | 28 +++++++++++ 2 files changed, 28 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/lint-n-static-analysis.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint-n-static-analysis.yml b/.github/workflows/lint-n-static-analysis.yml deleted file mode 100644 index aa9c578..0000000 --- a/.github/workflows/lint-n-static-analysis.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Lint and Static Analysis - -on: - pull_request: - paths: - - main.py - - context_chat_backend/** - - reqs.txt - - reqs.dev - push: - branches: - - master - paths: - - main.py - - context_chat_backend/** - - reqs.txt - - reqs.dev - -jobs: - analysis: - runs-on: ubuntu-latest - - name: Lint and Static Analysis - - steps: - - uses: actions/checkout@v4 - - - name: Setup python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - cache-dependency-path: | - reqs.txt - reqs.dev - - - name: Install dependencies - run: | - pip install --no-deps -r reqs.txt - pip install -r reqs.dev - - - name: Lint with Ruff - run: | - ls -la - ruff check --output-format=github --config=pyproject.toml --no-cache - - - name: Static analysis with pyright - run: | - pyright diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3b7bcb4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +ci: + skip: [pyright] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + - id: check-toml + - id: mixed-line-ending + - id: trailing-whitespace + files: context_chat_backend/|main\.py + - id: end-of-file-fixer + exclude: persistent_storage + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.2 + hooks: + - id: ruff + + - repo: local + hooks: + - id: pyright + name: pyright + entry: pyright + language: system + types: [python] + pass_filenames: false