diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eacd1fb..84e7ab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,23 +25,17 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install -r requirements.txt pip install -e . - pip install pytest pytest-cov black isort - name: Check formatting with black run: | - black --check anomaly_detection/ tests/ + black --check . - name: Check import sorting with isort run: | - isort --check-only anomaly_detection/ tests/ + isort --check-only . - name: Run tests with coverage run: | - pytest tests/ --cov=anomaly_detection --cov-report=xml -v - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./coverage.xml - fail_ci_if_error: true + pytest tests/ --cov=anomaly_detection -v diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0c5eaa0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + language_version: python3.9 + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile", "black"] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: no-commit-to-branch + args: [--branch, main] diff --git a/Makefile b/Makefile index df7d754..7b36b7a 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,28 @@ -.PHONY: install test lint format check-format check-imports clean +.PHONY: install test lint format check-format check-imports clean setup-pre-commit install: pip install -e . - pip install pytest pytest-cov black isort + pip install pytest pytest-cov black isort pre-commit + +setup-pre-commit: + pre-commit install test: pytest tests/ --cov=anomaly_detection --cov-report=term-missing -v lint: - black --check anomaly_detection/ tests/ - isort --check-only anomaly_detection/ tests/ + black --check . + isort --check-only . format: - black anomaly_detection/ tests/ - isort anomaly_detection/ tests/ + black . + isort . check-format: - black --check anomaly_detection/ tests/ + black --check . check-imports: - isort --check-only anomaly_detection/ tests/ + isort --check-only . clean: find . -type d -name "__pycache__" -exec rm -r {} + @@ -32,4 +35,4 @@ clean: find . -type d -name ".pytest_cache" -exec rm -r {} + find . -type d -name ".coverage" -exec rm -r {} + find . -type d -name "htmlcov" -exec rm -r {} + - find . -type f -name "coverage.xml" -delete \ No newline at end of file + find . -type f -name "coverage.xml" -delete diff --git a/requirements.txt b/requirements.txt index 559cc38..4d18005 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,14 @@ -numpy>=1.21.0 -pandas>=1.3.0 -scikit-learn>=0.24.2 +black>=21.7b0 boto3>=1.26.0 fastapi>=0.68.0 -uvicorn>=0.15.0 +flake8>=3.9.2 +httpx>=0.24.0 +isort>=5.9.3 +numpy>=1.21.0 +pandas>=1.3.0 +pre-commit>=3.6.0 python-dotenv>=0.19.0 pytest>=6.2.5 pytest-cov>=2.12.1 -black>=21.7b0 -isort>=5.9.3 -flake8>=3.9.2 -httpx>=0.24.0 \ No newline at end of file +scikit-learn>=0.24.2 +uvicorn>=0.15.0 diff --git a/setup.py b/setup.py index 4e797d4..b35522b 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( name="anomaly_detection", @@ -16,4 +16,4 @@ "pytest-cov>=2.12.0", ], python_requires=">=3.8", -) \ No newline at end of file +)