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
17 changes: 8 additions & 9 deletions .github/workflows/python-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ jobs:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install poetry
poetry install --with test --no-root
python-version-file: ".python-version"
- name: Install test dependencies
run: uv sync --group test
- name: Test with pytest - ${{ matrix.python-version }}
run: |
poetry run pytest -s --cov=. --cov-branch --cov-report=xml -v
run: uv run pytest -s --cov=. --cov-branch --cov-report=xml -v
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
27 changes: 14 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio

# Install poetry and any other dependency that your worker needs.
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-poetry \
curl \
# Add your dependencies here
&& rm -rf /var/lib/apt/lists/*

# Configure poetry
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

# Configure debugging
ARG OPENRELIK_PYDEBUG
ENV OPENRELIK_PYDEBUG=${OPENRELIK_PYDEBUG:-0}
Expand All @@ -26,16 +20,23 @@ ENV OPENRELIK_PYDEBUG_PORT=${OPENRELIK_PYDEBUG_PORT:-5678}
# Set working directory
WORKDIR /openrelik

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

# Copy poetry toml and install dependencies
COPY ./pyproject.toml ./poetry.lock ./
RUN poetry install --no-interaction --no-ansi
COPY uv.lock pyproject.toml .

# Copy files needed to build
# Install the project's dependencies using the lockfile and settings
RUN uv sync --locked --no-install-project --no-dev

# Copy project files
COPY . ./

# Installing separately from its dependencies allows optimal layer caching
RUN uv sync --locked --no-dev

# Install the worker and set environment to use the correct python interpreter.
RUN poetry install && rm -rf $POETRY_CACHE_DIR
ENV VIRTUAL_ENV=/app/.venv PATH="/openrelik/.venv/bin:$PATH"
ENV PATH="/openrelik/.venv/bin:$PATH"

# Default command if not run from docker-compose (and command being overidden)
CMD ["celery", "--app=src.tasks", "worker", "--task-events", "--concurrency=1", "--loglevel=INFO"]
CMD ["celery", "--app=src.tasks", "worker", "--task-events", "--concurrency=1", "--loglevel=DEBUG"]
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ openrelik-worker-TEMPLATEWORKERNAME:

## Test
```
pip install poetry
poetry install --with test --no-root
poetry run pytest --cov=. -v
uv sync --group test
uv run pytest -s --cov=.
```
579 changes: 0 additions & 579 deletions poetry.lock

This file was deleted.

32 changes: 17 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
[tool.poetry]
[project]
authors = [
{name = "YOUR NAME", email = "email@example.com"},
]
requires-python = "<4.0,>=3.11"
dependencies = [
"celery[redis]<6.0.0,>=5.4.0",
"openrelik-worker-common<1.0.0,>=0.16.0",
]
name = "openrelik-worker-TEMPLATE-WORKER-NAME"
version = "0.1.0"
description = "Description of the worker"
authors = ["YOUR NAME <email@example.com>"]
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "<4.0,>=3.11"
celery = { extras = ["redis"], version = "^5.4.0" }
openrelik-worker-common = "^0.16.0"
[dependency-groups]
test = [
"pytest",
"pytest-cov<6.0.0,>=5.0.0",
"pytest-mock<4.0.0,>=3.14.0",
]

[tool.poetry.group.test.dependencies]
pytest = "*"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
default-groups = []
Loading