diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eacd1fb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI/CD + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + pip install pytest pytest-cov black isort + + - name: Check formatting with black + run: | + black --check anomaly_detection/ tests/ + + - name: Check import sorting with isort + run: | + isort --check-only anomaly_detection/ tests/ + + - 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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..df7d754 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.PHONY: install test lint format check-format check-imports clean + +install: + pip install -e . + pip install pytest pytest-cov black isort + +test: + pytest tests/ --cov=anomaly_detection --cov-report=term-missing -v + +lint: + black --check anomaly_detection/ tests/ + isort --check-only anomaly_detection/ tests/ + +format: + black anomaly_detection/ tests/ + isort anomaly_detection/ tests/ + +check-format: + black --check anomaly_detection/ tests/ + +check-imports: + isort --check-only anomaly_detection/ tests/ + +clean: + find . -type d -name "__pycache__" -exec rm -r {} + + find . -type f -name "*.pyc" -delete + find . -type f -name "*.pyo" -delete + find . -type f -name "*.pyd" -delete + find . -type f -name ".coverage" -delete + find . -type d -name "*.egg-info" -exec rm -r {} + + find . -type d -name "*.egg" -exec rm -r {} + + 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