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
6 changes: 6 additions & 0 deletions .agent/rules/running-application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
trigger: always_on
---

Use the docker compose when testing the application and functionality.
the local machine does not have the requirements for testing
130 changes: 130 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

env:
DATABASE_URL: postgresql://coalmine:coalmine@localhost:5432/coalmine

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: pip install flake8

- name: Run flake8
run: flake8 src/ --max-line-length=120 --ignore=E501,W503

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio

- name: Run unit tests
run: pytest tests/unit/ -v -m unit --tb=short

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: coalmine
POSTGRES_PASSWORD: coalmine
POSTGRES_DB: coalmine
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio

- name: Wait for services
run: |
until pg_isready -h localhost -p 5432; do sleep 1; done

- name: Run integration tests
env:
DATABASE_URL: postgresql://coalmine:coalmine@localhost:5432/coalmine
CELERY_BROKER_URL: redis://localhost:6379/0
run: pytest tests/integration/ -v -m integration --tb=short

docker-build:
name: Docker Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t coalmine:test .

- name: Verify image
run: docker run --rm coalmine:test python -c "import src; print('OK')"

contract-tests:
name: Contract Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest

- name: Run contract tests
run: pytest tests/unit/test_contracts.py -v --tb=short
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opent

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy and install package (includes dependencies from pyproject.toml)
COPY pyproject.toml README.md ./
COPY src/ ./src/

# Install in editable mode with dev dependencies (includes pytest)
RUN pip install --no-cache-dir -e ".[dev]"

# Copy remaining files
COPY . .

# Set standard entrypoint for DB init
Expand Down
Loading
Loading