Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use rye as project manager #2359

Merged
merged 6 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 24 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v4
- name: "Install rye"
id: setup-rye
uses: eifinger/setup-rye@v4
with:
python-version: '3.10'
cache: 'poetry'
version: '0.43.0'
checksum: 'ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80'
enable-cache: true

- name: Install OS dependencies
if: ${{ matrix.python-version }} == '3.10'
run: |
sudo apt update
sudo apt install -y libre2-dev libpq-dev

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye sync --no-lock

- name: Check formatting & linting
run: |
poetry run pre-commit run --all-files
rye run pre-commit run --all-files


test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.10"]
fail-fast: true

# service containers to run with `postgres-job`
services:
Expand Down Expand Up @@ -69,13 +69,14 @@ jobs:
- name: Check out repo
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v4
- name: Install rye
id: setup-rye
uses: eifinger/setup-rye@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
version: '0.43.0'
checksum: 'ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80'
enable-cache: true
cache-prefix: 'rye-cache'

- name: Install OS dependencies
if: ${{ matrix.python-version }} == '3.10'
Expand All @@ -84,9 +85,8 @@ jobs:
sudo apt install -y libre2-dev libpq-dev

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

if: steps.setup-rye.outputs.cache-hit != 'true'
run: rye sync --no-lock

- name: Start Redis v6
uses: superchargejs/[email protected]
Expand All @@ -95,7 +95,8 @@ jobs:

- name: Run db migration
run: |
CONFIG=tests/test.env poetry run alembic upgrade head
rye install alembic
CONFIG=tests/test.env rye run alembic upgrade head

- name: Prepare version file
run: |
Expand All @@ -104,7 +105,7 @@ jobs:

- name: Test with pytest
run: |
poetry run pytest
rye run pytest
env:
GITHUB_ACTIONS_TEST: true

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.16
50 changes: 26 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,45 @@ WORKDIR /code
COPY ./static/package*.json /code/static/
RUN cd /code/static && npm ci

# Main image
FROM python:3.10
FROM --platform=linux/amd64 ubuntu:22.04

ARG RYE_VERSION="0.43.0"
ARG RYE_HASH="ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80"

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
ENV PYTHONUNBUFFERED=1

# Add poetry to PATH
ENV PATH="${PATH}:/root/.local/bin"

WORKDIR /code

# Copy poetry files
COPY poetry.lock pyproject.toml ./

# Install and setup poetry
RUN pip install -U pip \
&& apt-get update \
&& apt install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev cmake ninja-build\
&& curl -sSL https://install.python-poetry.org | python3 - \
# Remove curl and netcat from the image
&& apt-get purge -y curl netcat-traditional \
# Run poetry
&& poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-root \
# Clear apt cache \
&& apt-get purge -y libre2-dev cmake ninja-build\
# Copy dependency files
COPY pyproject.toml requirements.lock requirements-dev.lock .python-version ./

# Install deps
RUN apt-get update \
&& apt-get install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev build-essential pkg-config cmake ninja-build bash clang \
&& curl -sSL "https://github.com/astral-sh/rye/releases/download/${RYE_VERSION}/rye-x86_64-linux.gz" > rye.gz \
&& echo "${RYE_HASH} rye.gz" | sha256sum -c - \
&& gunzip rye.gz \
&& chmod +x rye \
&& mv rye /usr/bin/rye \
&& rye toolchain fetch `cat .python-version` \
&& rye sync --no-lock --no-dev \
&& apt-get autoremove -y \
&& apt-get purge -y curl netcat-traditional build-essential pkg-config cmake ninja-build python3-dev clang\
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy code
COPY . .

# copy npm packages
COPY --from=npm /code /code

# copy everything else into /code
COPY . .

ENV PATH="/code/.venv/bin:$PATH"
EXPOSE 7777

#gunicorn wsgi:app -b 0.0.0.0:7777 -w 2 --timeout 15 --log-level DEBUG
Expand Down
Loading
Loading