Skip to content

Commit 00432bc

Browse files
committed
build(agent): migrate from Poetry to Rye
1 parent ba90f6b commit 00432bc

File tree

9 files changed

+80
-438
lines changed

9 files changed

+80
-438
lines changed

.github/workflows/ci_agent.yml

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: CI (Agent)
22

3-
env:
4-
VENV_PATH: "~/.venv-agent"
5-
63
on:
74
push:
85
paths:
@@ -28,44 +25,21 @@ jobs:
2825
- name: Checkout repository
2926
uses: actions/checkout@v4
3027

31-
- name: Set up Python
32-
uses: actions/setup-python@v5
33-
with:
34-
python-version: '3.11.3'
35-
36-
- name: Cache poetry install
37-
uses: actions/cache@v4
38-
with:
39-
path: ~/.local
40-
key: poetry
41-
42-
- name: Install Poetry
43-
uses: snok/install-poetry@v1
28+
- name: Install the latest version of rye
29+
uses: eifinger/setup-rye@v4
4430
with:
45-
virtualenvs-create: true
46-
virtualenvs-in-project: false
47-
virtualenvs-path: ${{ env.VENV_PATH }}
48-
49-
- name: Cache deps
50-
id: cache-deps
51-
uses: actions/cache@v4
52-
with:
53-
path: ${{ env.VENV_PATH }}
54-
key: venv-agent-${{ hashFiles('**/poetry.lock') }}
31+
enable-cache: true
5532

5633
- name: Install confluent-kafka prerequisites
5734
run: |
5835
sudo apt-get install --yes gcc librdkafka-dev python3-dev
5936
60-
- name: Install dependencies
61-
run: |
62-
poetry install --no-interaction --no-root
37+
- name: Sync dependencies
38+
run: rye sync
6339

6440
- uses: taiki-e/install-action@just
6541
- uses: taiki-e/install-action@dprint
6642

6743
- name: Lint
6844
# currently cli is not-maintained
69-
run: |
70-
just fmt-check
71-
just lint
45+
run: just check

agent/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ __pycache__/
1515
# other
1616
.flake8
1717
.env
18-
docker-compose.yml
18+
compose.yml

agent/Dockerfile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
11
# didn't work with apline
22
FROM python:3.11.3-slim-buster
33

4-
ENV PIP_DEFAULT_TIMEOUT=100 \
5-
POETRY_VERSION=1.4
4+
ENV PIP_DEFAULT_TIMEOUT=100
65

76
RUN apt-get update
87
# working with timezones
98
RUN apt-get install --no-install-recommends --yes tzdata
109
# confluent-kafka-python needs these
1110
RUN apt-get install --no-install-recommends --yes gcc librdkafka-dev python3-dev
1211

13-
# activate virtualenv
14-
ENV VIRTUAL_ENV=/opt/venv
15-
RUN python3 -m venv $VIRTUAL_ENV
16-
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
17-
1812
# upgrading pip solves many installation problems
1913
RUN pip3 install --upgrade pip
20-
RUN pip3 install "poetry==$POETRY_VERSION"
2114

2215
WORKDIR /dnsagent
2316

2417
# leverage Docker cache
25-
COPY poetry.lock pyproject.toml /dnsagent/
26-
27-
RUN poetry install --only main --no-interaction --no-ansi
18+
COPY requirements.lock /dnsagent/
19+
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.lock
2820

2921
ARG VCS_REVISION
3022
RUN echo "$VCS_REVISION" > version
3123

3224
COPY . /dnsagent
3325

34-
# check build version
35-
RUN cat /dnsagent/version
36-
37-
ENV PYTHONPATH="${PYTHONPATH}:/dnsagent"
3826
CMD ["python3", "dnsagent/start.py"]

agent/justfile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _default:
99

1010
# Setup the repository.
1111
setup:
12-
poetry install && poetry shell
12+
rye sync
1313

1414
# Tasks to make the code-base comply with the rules. Mostly used in git hooks.
1515
comply: fmt lint
@@ -19,31 +19,28 @@ check: fmt-check lint
1919

2020
# Build the container image.
2121
image-build:
22-
podman build --tag restknot-agent:latest --build-arg VCS_REVISION=$(git rev-parse --short HEAD) .
22+
docker build --tag restknot-agent:latest --build-arg VCS_REVISION=$(git rev-parse --short HEAD) .
2323

2424
# Run the container image.
2525
image-start:
26-
podman-compose up -d
26+
docker compose up -d
2727

2828
# Stop the container image.
2929
image-stop:
30-
podman-compose down
30+
docker compose down
3131

3232
# Format the codebase.
3333
fmt:
34-
poetry run black .
35-
poetry run isort .
34+
rye fmt
3635

3736
# Check is the codebase properly formatted.
3837
fmt-check:
39-
poetry run black --check .
38+
rye fmt --check
4039

4140
# Lint the codebase.
4241
lint:
43-
poetry run ruff .
42+
rye lint
4443

4544
# Check dependencies health.
4645
up:
47-
#!/usr/bin/env bash
48-
poetry lock
49-
poetry show --outdated | grep --file=<(poetry show --tree | grep '^\w' | cut -d' ' -f1) || echo "All dependencies are up to date, yay!"
46+
rye sync --update-all

0 commit comments

Comments
 (0)