Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ jobs:
- name: Display Bandit results
run: poetry run bandit -r pybot -x pybot/_vendor --skip B101 -f txt || true

- name: Check for known vulnerabilities
run: poetry run safety scan --output text || true
continue-on-error: true

# Final status check for branch protection
ci-success:
name: CI Success
Expand Down
82 changes: 82 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.PHONY: help install lint lint-fix format test test-unit test-integration test-cov security ci docker-build docker-up docker-down clean

# Default target
help:
@echo "Available commands:"
@echo " make install - Install dependencies with poetry"
@echo " make lint - Run ruff linter and formatter check"
@echo " make lint-fix - Auto-fix linting and formatting issues"
@echo " make format - Format code with ruff"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-integration - Run integration tests only"
@echo " make test-cov - Run tests with coverage report"
@echo " make security - Run bandit and safety security scanners"
@echo " make ci - Run all CI checks (lint, test-cov, security)"
@echo " make docker-build - Build the Docker image"
@echo " make docker-up - Start services with docker-compose"
@echo " make docker-down - Stop services with docker-compose"
@echo " make clean - Remove Python cache files and test artifacts"

# Install dependencies
install:
poetry install

# Linting and formatting
lint:
poetry run ruff check .
poetry run ruff format --check .

lint-fix:
poetry run ruff check --fix .
poetry run ruff format .

format:
poetry run ruff format .

# Testing
test:
poetry run pytest

test-unit:
poetry run pytest tests/unit/

test-integration:
poetry run pytest tests/integration/

test-cov:
SLACK_TOKEN=xoxb-test-token \
SLACK_ADMIN_TOKEN=xoxb-admin-test-token \
AIRTABLE_API_KEY=test-key \
AIRTABLE_BASE_ID=test-base \
poetry run pytest --cov=pybot --cov-report=xml --cov-report=term-missing -v --tb=short

# Security
security:
poetry run bandit -r pybot -x pybot/_vendor --skip B101 -f txt

# CI - runs all checks that CI will run
ci: lint test-cov security
@echo ""
@echo "✓ All CI checks passed!"

# Docker
docker-build:
docker build -f docker/Dockerfile -t pybot:latest .

docker-up:
docker-compose -f docker/docker-compose.yml up

docker-down:
docker-compose -f docker/docker-compose.yml down

# Cleanup
clean:
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name ".coverage" -delete
find . -type f -name "coverage.xml" -delete
rm -rf .ruff_cache htmlcov
@echo "✓ Cleaned up Python cache files and test artifacts"
16 changes: 13 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM python:3.14-slim AS base

RUN apt-get update && apt-get upgrade -y && apt-get install wget -y && apt clean
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/*

FROM base AS builder

ENV PIP_DISABLE_PIP_VERSION_CHECK=on \
PYTHONUNBUFFERED=1 \
POETRY_VERSION=2.4.0 \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_VIRTUALENVS_CREATE=true \
Expand All @@ -14,12 +16,15 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=on \
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install poetry
RUN pip install --no-cache-dir poetry
# Install Poetry into its own isolated environment
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry

# Copy dependency files
COPY pyproject.toml poetry.lock README.md logging.yml manage.py ./
Expand All @@ -41,4 +46,9 @@ WORKDIR /app
# Copy application and virtual environment from builder
COPY --from=builder /app ./

EXPOSE 5000

HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD wget -q -O /dev/null http://localhost:5000/health || exit 1

CMD ["python", "-m", "pybot"]
30 changes: 0 additions & 30 deletions docker/Dockerfile.test

This file was deleted.

34 changes: 0 additions & 34 deletions docker/Dockerfile.test.py312

This file was deleted.

37 changes: 0 additions & 37 deletions docker/Dockerfile.test.py314

This file was deleted.

Loading
Loading