Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
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
24 changes: 12 additions & 12 deletions .github/workflows/python-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ 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
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
run: uv run pytest -s --cov=. --cov-branch --cov-report=xml -v
# Please uncomment this if your organization uses Codecov test coverage!
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v5
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/update-uv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: update-uv

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v3

- run: |
echo "\`\`\`" > uv_output.md
uv lock --upgrade 2>&1 | tee -a uv_output.md
echo "\`\`\`" >> uv_output.md

- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
committer: hacktobeer <ramsesdebeer@gmail.com>
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update uv lockfile
title: Update uv lockfile
body-path: uv_output.md
branch: update-uv
base: main
labels: install
delete-branch: true
add-paths: uv.lock
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

# Copy poetry toml and install dependencies
COPY ./pyproject.toml ./poetry.lock ./
RUN poetry install --no-interaction --no-ansi
# Install the latest uv binaries
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Copy poetry toml and uv.lock
COPY uv.lock pyproject.toml ./

# Install the project's dependencies using the lockfile and settings
RUN uv sync --locked --no-install-project --no-dev

# Copy files needed to build
COPY . ./

# 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"
# Installing separately from its dependencies allows optimal layer caching
RUN uv sync --locked --no-dev

# Set PATH to use the virtual environment
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"]
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ openrelik-worker-cloud-logs:
Run the following command.

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

This file was deleted.

33 changes: 19 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
[tool.poetry]
[project]
name = "openrelik-worker-cloud-logs"
version = "0.1.0"
description = "OpenRelik worker to process Cloud provider logs."
authors = ["roshan maskey <roshanmaskey@gmail.com>"]
authors = [{ name = "roshan maskey", email = "roshanmaskey@gmail.com" }]
requires-python = "<4.0,>=3.11"
readme = "README.md"
package-mode = false
dependencies = [
"celery[redis]>=5.4.0,<6",
"openrelik-worker-common>=0.17.1,<1.0.0",
"orjson>=3.10.16,<4",
]

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

[tool.poetry.group.test.dependencies]
pytest = "*"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"
[tool.uv]
package = false
default-groups = ["test"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["uv_build>=0.9.0,<0.10.0"]
build-backend = "uv_build"
2 changes: 1 addition & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
if os.getenv("OPENRELIK_PYDEBUG") == "1":
start_debugger()

REDIS_URL = os.getenv("REDIS_URL")
REDIS_URL = os.getenv("REDIS_URL") or "redis://localhost:6379/0"
celery = Celery(broker=REDIS_URL, backend=REDIS_URL, include=["src.gcp"])
redis_client = redis.Redis.from_url(REDIS_URL)
Loading