Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b0b7cb0
fix(api): add is_admin field to UserCreateBaseSchema for email valida…
Adamkadaban Dec 30, 2025
999e42a
chore(api): migrate to uv for dependency management
Adamkadaban Dec 30, 2025
3a1be9a
chore(api): use dynamic versioning from git tags via setuptools-scm
Adamkadaban Dec 30, 2025
005572d
chore(api): set fallback version to dev for non-tagged builds
Adamkadaban Dec 30, 2025
a52418c
chore(ci): update workflows to use uv for dependency management
Adamkadaban Dec 30, 2025
121ddfa
chore(docker): migrate Dockerfile to use uv
Adamkadaban Dec 30, 2025
dedcc80
docs(api): update README to use uv instead of pip
Adamkadaban Dec 30, 2025
ed6a3f8
chore(api): migrate from mypy to ty type checker
Adamkadaban Dec 30, 2025
e554ef7
fix(api): resolve ty type checker errors
Adamkadaban Dec 30, 2025
80b33fb
docs: update references from mypy to ty type checker
Adamkadaban Dec 31, 2025
5c0b1d7
fix(api): update type ignore comment for anyio limiter
Adamkadaban Dec 31, 2025
b7f6f36
style: fix linting issues for staging branch
Adamkadaban Dec 31, 2025
1619840
fix(docker): reorganize apt package installation to prevent cache issues
Adamkadaban Dec 31, 2025
f52b24f
fix(docker): remove missing dep from python slim image
Adamkadaban Dec 31, 2025
366e62c
fix(docker): use 'uv run' for all CMD and HEALTHCHECK commands
Adamkadaban Dec 31, 2025
f172af3
chore(e2e): migrate from pip to uv for dependency management
Adamkadaban Dec 31, 2025
3b0fabf
fix(docker): use 'uv run' for init container command
Adamkadaban Dec 31, 2025
a09ddcc
chore(api): update dependencies to latest versions
Adamkadaban Dec 31, 2025
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
57 changes: 30 additions & 27 deletions .github/workflows/api_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,27 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

# Install dependencies
- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

# Run Black formatter
- name: Run Black
run: |
cd api
black --check --diff .
uv run black --check --diff .

mypy:
ty:
runs-on: ubuntu-latest

steps:
Expand All @@ -65,24 +66,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

# Install dependencies
- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

# Run MyPy checks
- name: Run MyPy
# Run ty checks
- name: Run ty
run: |
cd api
mypy --install-types --non-interactive .
uv run ty check

ruff:
runs-on: ubuntu-latest
Expand All @@ -97,21 +99,22 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

# Install dependencies
- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

# Run Ruff linter and formatter
- name: Run Ruff
run: |
cd api
ruff check .
uv run ruff check .
34 changes: 18 additions & 16 deletions .github/workflows/api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

# Install dependencies
- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

# Run Tests
- name: Run Unit Tests
run: |
cd api
pytest -m unit --cov-report=lcov
uv run pytest -m unit --cov-report=lcov

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
Expand Down Expand Up @@ -90,24 +91,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

# Install uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

# Install dependencies
- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

# Run Tests
- name: Run Integration Tests
run: |
cd api
pytest -m "integration and not deploy" --no-cov
uv run pytest -m "integration and not deploy" --no-cov

- name: Upload test logs on failure
if: failure()
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/reusable_provider_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
api/requirements.txt
api/dev-requirements.txt

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "api/uv.lock"

- name: Install dependencies
run: |
cd api
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
uv sync --all-extras

- name: Run ${{ inputs.provider }} Tests
run: |
cd api
pytest -m ${{ inputs.provider }} --no-cov
uv run pytest -m ${{ inputs.provider }} --no-cov

- name: Upload test logs on failure
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://github.com/OpenLabsHQ/OpenLabs"><img alt="Docs" src="https://img.shields.io/github/actions/workflow/status/OpenLabsHQ/OpenLabs/mdbook.yml?branch=main&label=Docs"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="Linting: ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
<a href="https://mypy-lang.org/"><img alt="Checked with mypy" src="https://www.mypy-lang.org/static/mypy_badge.svg"></a>
<a href="https://docs.astral.sh/ty/"><img alt="Type checked with ty" src="https://img.shields.io/badge/type_checker-ty-blue.svg"></a>
</p>

---
Expand Down
34 changes: 20 additions & 14 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ FROM python:3.12-slim AS builder

WORKDIR /code

RUN apt-get update && apt-get install -y git curl \
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
gnupg \
gnupg2 \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs \
&& apt-get install -y gnupg software-properties-common \
&& apt-get install -y wget \
&& apt-get install -y gnupg2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install python dependencies
COPY api/requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY api/pyproject.toml api/uv.lock /code/
RUN uv sync --frozen --no-dev

COPY api/src /code/src
COPY .env /code/.env
Expand All @@ -31,27 +37,27 @@ FROM builder AS test_builder

COPY api/tests /code/tests

COPY api/dev-requirements.txt /code/dev-requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/dev-requirements.txt
# Install dev dependencies
RUN uv sync --frozen --all-extras

COPY api/pyproject.toml /code/pyproject.toml

# ========= API Debug Image =========
# Adds debug capabilities
FROM builder AS api_debug

RUN pip install --no-cache-dir debugpy
RUN uv pip install --no-cache debugpy

HEALTHCHECK --interval=15s --timeout=5s --start-period=60s --retries=3 \
CMD ["python", "-m", "src.scripts.health_check"]
CMD ["uv", "run", "python", "-m", "src.scripts.health_check"]


# ========= API Test Image =========
# Adds test dependencies
FROM test_builder AS api_test

HEALTHCHECK --interval=5s --timeout=5s --start-period=300s --retries=3 \
CMD ["python", "-m", "src.scripts.health_check"]
CMD ["uv", "run", "python", "-m", "src.scripts.health_check"]


# ========= Worker Image =========
Expand All @@ -76,14 +82,14 @@ RUN terraform init
RUN rm -rf .terraform*
WORKDIR /code

CMD ["arq", "src.app.worker.settings.WorkerSettings"]
CMD ["uv", "run", "arq", "src.app.worker.settings.WorkerSettings"]


# ========= Prod Image =========
# Extra prod goodies
FROM builder AS prod

HEALTHCHECK --interval=60s --timeout=5s --start-period=60s --retries=3 \
CMD ["python", "-m", "src.scripts.health_check"]
CMD ["uv", "run", "python", "-m", "src.scripts.health_check"]

CMD ["uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "80", "--workers", "4"]
CMD ["uv", "run", "uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "80", "--workers", "4"]
24 changes: 11 additions & 13 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="https://github.com/OpenLabsHQ/OpenLabs"><img alt="Latest version" src="https://img.shields.io/github/v/release/OpenLabsHQ/OpenLabs"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="Linting: ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
<a href="https://mypy-lang.org/"><img alt="Checked with mypy" src="https://www.mypy-lang.org/static/mypy_badge.svg"></a>
<a href="https://docs.astral.sh/ty/"><img alt="Type checked with ty" src="https://img.shields.io/badge/type_checker-ty-blue.svg"></a>
</p>


Expand Down Expand Up @@ -77,24 +77,22 @@ src/

## Environment Setup

Create environment:
Install uv (if not already installed):

```bash
python3.12 -m venv venv
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Activate environment:
Install dependencies:

```bash
source venv/bin/activate
uv sync --all-extras
```

Install dependencies:
Activate environment:

```bash
pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
source .venv/bin/activate
```

## Tests
Expand All @@ -103,16 +101,16 @@ Run tests:

```bash
# Unit tests
pytest -m unit
uv run pytest -m unit

# Integration tests (no deployments)
pytest -m "integration and not deploy"
uv run pytest -m "integration and not deploy"

# Configure provider credentials
cp .env.tests.example .env.tests

# Provider specific tests
pytest -m aws
uv run pytest -m aws
```

> See `marks` defined in `pyproject.toml` for more options.
Expand Down Expand Up @@ -161,7 +159,7 @@ The app will only be started once you run the debugger in VScode using the `Pyth

* `api-black.yml` - Runs the Black code formatter in check mode to verify code formatting.
* `api-ruff.yml` - Runs the Ruff linter to check for code quality issues.
* `api-mypy.yml` - Performs static type checking with MyPy.
* `api-ty.yml` - Performs static type checking with ty.
* `api-unit_tests.yml` - Runs all unit tests.
* `api-integration_tests.yml` Runs integration tests that do **not** deploy live infrastructure.
* `api-aws_tests.yml` - Run all AWS specific tests including live deploy tests.
27 changes: 0 additions & 27 deletions api/dev-requirements.txt

This file was deleted.

Loading
Loading