Add, configure and run pre-commit locally and in test workflow

This commit is contained in:
Debanjum Singh Solanky 2023-02-17 12:07:59 -06:00
parent 5e83baab21
commit 051f0e3fb5
22 changed files with 183 additions and 162 deletions

View file

@ -9,6 +9,7 @@ on:
- tests/** - tests/**
- config/** - config/**
- pyproject.toml - pyproject.toml
- .pre-commit-config.yml
- .github/workflows/test.yml - .github/workflows/test.yml
push: push:
branches: branches:
@ -18,6 +19,7 @@ on:
- tests/** - tests/**
- config/** - config/**
- pyproject.toml - pyproject.toml
- .pre-commit-config.yml
- .github/workflows/test.yml - .github/workflows/test.yml
jobs: jobs:
@ -45,9 +47,10 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
- name: Install Application - name: Install Application
run: | run: pip install --upgrade .[dev]
pip install --upgrade .[dev]
- name: Validate Application
run: pre-commit
- name: Test Application - name: Test Application
run: | run: pytest
pytest

16
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
# Exclude elisp files to not clear page breaks
exclude: \.el$
- id: check-json
- id: check-toml
- id: check-yaml

View file

@ -619,4 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee. copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS

View file

@ -65,9 +65,13 @@ khoj = "khoj.main:run"
[project.optional-dependencies] [project.optional-dependencies]
test = [ test = [
"pytest >= 7.1.2", "pytest >= 7.1.2",
"black >= 23.1.0",
] ]
dev = ["khoj-assistant[test]"] dev = [
"khoj-assistant[test]",
"mypy >= 1.0.1",
"black >= 23.1.0",
"pre-commit >= 3.0.4",
]
[tool.hatch.build.targets.sdist] [tool.hatch.build.targets.sdist]
include = ["src/khoj"] include = ["src/khoj"]
@ -79,8 +83,8 @@ packages = ["src/khoj"]
files = "src/khoj" files = "src/khoj"
pretty = true pretty = true
strict_optional = false strict_optional = false
ignore_missing_imports = true
install_types = true install_types = true
ignore_missing_imports = true
non_interactive = true non_interactive = true
show_error_codes = true show_error_codes = true
warn_unused_ignores = true warn_unused_ignores = true

View file

@ -619,4 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee. copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS