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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Make exceptions for what's needed
!bot
!pyproject.toml
!poetry.lock
!uv.lock
!LICENSE
15 changes: 11 additions & 4 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ jobs:
name: Run linting & tests
runs-on: ubuntu-latest
steps:
- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.6.0
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python_version: '3.12'
install_args: "--only main --only lint --only test"
enable-cache: true
cache-dependency-glob: "uv.lock"
activate-environment: true

- name: Install dependencies
run: uv sync --frozen --group lint --group test

# Attempt to run the bot. Setting `IN_CI` to true, so bot.run() is never called.
# This is to catch import and cog setup errors that may appear in PRs, to avoid crash loops if merged.
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: ruff
name: ruff
description: Run ruff linting
entry: poetry run ruff check --force-exclude
entry: uv run ruff check --force-exclude
language: system
'types_or': [python, pyi]
require_serial: true
Expand Down
41 changes: 31 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.12-slim
ARG python_version=3.12-slim

# Install dependencies
WORKDIR /bot
COPY pyproject.toml poetry.lock ./
RUN poetry install --without dev
FROM python:$python_version AS builder
COPY --from=ghcr.io/astral-sh/uv:0.7 /uv /bin/

ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

# Install project dependencies with build tools available
WORKDIR /build
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
&& python -m venv .venv

RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-dev

# Set SHA build argument
# -------------------------------------------------------------------------------

FROM python:$python_version

# Define Git SHA build argument for sentry
ARG git_sha="development"
ENV GIT_SHA=$git_sha

# Copy the rest of the project code
# Install dependencies from build cache
# .venv not put in /app so that it doesn't conflict with the dev
# volume we use to avoid rebuilding image every code change locally
COPY --from=builder /build /build
ENV PATH="/build/.venv/bin:$PATH"

# Copy the source code in last to optimize rebuilding the image
WORKDIR /bot
COPY . .

# Start the bot
ENTRYPOINT ["poetry", "run"]
CMD ["python", "-m", "bot"]
ENTRYPOINT ["python", "-m"]
CMD ["bot"]
1,720 changes: 0 additions & 1,720 deletions poetry.lock

This file was deleted.

50 changes: 26 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
[tool.poetry]
[project]
authors = [
{name = "Python Discord", email = "[email protected]"},
]
requires-python = "==3.12.*"
dependencies = [
"pydis-core[all]==11.5.1",
"arrow==1.3.0",
"sentry-sdk==2.19.0",
"pydantic-settings==2.6.1",
]
name = "sir-robin"
version = "0.1.0"
description = ""
authors = ["Python Discord <[email protected]>"]
package-mode = false

[tool.poetry.dependencies]
python = "3.12.*"

pydis-core = { version = "11.5.1", extras = ["all"]}
arrow = "1.3.0"
sentry-sdk = "2.19.0"
pydantic-settings = "2.6.1"

[tool.poetry.group.dev.dependencies]
taskipy = "1.14.1"
[tool.uv]
prerelease = "allow"

[tool.poetry.group.test.dependencies]
hypothesis = "6.122.0"
pytest = "8.3.3"
pytest-asyncio = "0.24.0"
[dependency-groups]
dev = [
"taskipy==1.14.1",
]
test = [
"hypothesis==6.122.0",
"pytest==8.3.3",
"pytest-asyncio==0.24.0",
]
lint = [
"ruff==0.8.1",
"pre-commit==4.0.1",
]

[tool.poetry.group.lint.dependencies]
ruff = "0.8.1"
pre-commit = "4.0.1"

[tool.taskipy.tasks]
start = "python -m bot"
lint = "pre-commit run --all-files"
precommit = "pre-commit install"
test = "python -m unittest discover"

[build-system]
requires = ["poetry-core>=1.2.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
target-version = "py312"
extend-exclude = [".cache"]
Expand Down
Loading