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

View file

@ -65,9 +65,13 @@ khoj = "khoj.main:run"
[project.optional-dependencies]
test = [
"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]
include = ["src/khoj"]
@ -79,8 +83,8 @@ packages = ["src/khoj"]
files = "src/khoj"
pretty = true
strict_optional = false
ignore_missing_imports = true
install_types = true
ignore_missing_imports = true
non_interactive = true
show_error_codes = 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.
END OF TERMS AND CONDITIONS