Skip to content

Commit ea2a144

Browse files
author
Daniel Sanz
committed
chore: replace poetry with uv
1 parent 403f259 commit ea2a144

File tree

12 files changed

+1261
-1467
lines changed

12 files changed

+1261
-1467
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,23 @@ jobs:
1212
lint:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
16-
- name: Set up Python 3.13
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: "3.13"
15+
- uses: actions/checkout@v4
2016
- name: Install just
2117
run: |
2218
sudo apt update
2319
sudo snap install --edge --classic just
24-
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry
28-
poetry install
29-
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v5
3022
- name: Lint
3123
run: |
32-
just lint
24+
just python_version="3.13" lint
3325
3426
lint-commit:
3527
runs-on: ubuntu-latest
3628
name: "Lint commit message"
3729
steps:
3830
- name: Check out
39-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
4032
- name: Install commitizen
4133
run: |
4234
python -m pip install --upgrade pip

.github/workflows/publish.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will publish our package on pypi
1+
# This workflow will publish our package on pypi, dockerhub, and create the release notes
22

33
name: Publish
44

@@ -11,23 +11,28 @@ permissions:
1111
contents: write
1212

1313
jobs:
14-
push_to_pypi:
14+
publish_to_pypi:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
18-
- name: Publish python package
19-
uses: JRubics/[email protected]
17+
- uses: actions/checkout@v4
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
2020
with:
21-
pypi_token: ${{ secrets.PYPI_TOKEN }}
22-
poetry_install_options: "--without dev"
21+
version: "0.6.3"
22+
- name: Publish to PyPi
23+
run: |
24+
uv build
25+
uv publish
26+
env:
27+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
2328

2429
push_to_docker_hub:
25-
needs: push_to_pypi
30+
needs: publish_to_pypi
2631
name: Push Docker image to Docker Hub
2732
runs-on: ubuntu-latest
2833
steps:
2934
- name: Check out the repo
30-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3136

3237
- name: Log in to Docker Hub
3338
uses: docker/login-action@v2

.github/workflows/security.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,31 @@ on:
99
branches: ["main"]
1010

1111
jobs:
12+
generate-dependencies-file:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v5
18+
- name: Create dependencies file
19+
run: |
20+
UV_PROJECT_ENVIRONMENT=.venv uv sync
21+
UV_PROJECT_ENVIRONMENT=.venv uv pip freeze > requirements.txt
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: requirements
25+
path: requirements.txt
26+
overwrite: true
27+
1228
osv-scanner:
29+
needs: generate-dependencies-file
1330
runs-on: ubuntu-latest
1431
container:
1532
image: ghcr.io/google/osv-scanner:v1.9.2
1633
steps:
17-
- uses: actions/checkout@v3
34+
- uses: actions/download-artifact@v4
35+
with:
36+
name: requirements
1837
- name: Run OSV Scanner
1938
run: |
2039
/osv-scanner --skip-git --format table -r .
@@ -23,24 +42,21 @@ jobs:
2342
container:
2443
image: returntocorp/semgrep:latest
2544
steps:
26-
- uses: actions/checkout@v3
45+
- uses: actions/checkout@v4
2746
- name: Run Semgrep
2847
run: |
2948
semgrep scan --config auto
3049
twyn:
50+
needs: generate-dependencies-file
3151
runs-on: ubuntu-latest
3252
steps:
33-
- uses: actions/checkout@v3
34-
- name: Set up Python
35-
uses: actions/setup-python@v4
53+
- uses: actions/checkout@v4
54+
- uses: actions/download-artifact@v4
3655
with:
37-
python-version: "3.13"
38-
- name: Install dependencies
39-
run: |
40-
python -m pip install --upgrade pip
41-
python -m pip install poetry
42-
poetry install --only main
56+
name: requirements
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v5
4359
- name: Run Twyn against our dependencies
4460
run: |
45-
poetry run twyn --version
46-
poetry run twyn run -vv
61+
uv run twyn --version
62+
uv run twyn run -vv

.github/workflows/test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,13 @@ jobs:
1818
runs-on: [ubuntu-latest]
1919

2020
steps:
21-
- uses: actions/checkout@v3
22-
- name: Set up Python
23-
uses: actions/setup-python@v4
24-
with:
25-
python-version: ${{ matrix.python-version }}
21+
- uses: actions/checkout@v4
2622
- name: Install just
2723
run: |
2824
sudo apt update
2925
sudo snap install --edge --classic just
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
python -m pip install poetry
34-
poetry install
35-
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
3628
- name: Test with pytest
3729
run: |
38-
just test
30+
just python_version=${{ matrix.python-version }} test

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For new feature proposals, please create first an issue to start a discussion ab
1010

1111
git clone [email protected]:<username>/twyn.git
1212
cd twyn/
13-
3. Make sure to have [poetry](https://python-poetry.org/) installed in your system, as well as [just](https://github.com/casey/just).
13+
3. Make sure to have [uv](https://docs.astral.sh/uv/getting-started/installation/) installed in your system, as well as [just](https://github.com/casey/just).
1414
4. Set up your working environment: create a virtual environment and install the project dependencies.
1515
The following command will do both:
1616

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
FROM python:3.13-slim
22

3+
ARG USER=twyn
4+
ARG GROUP=twyn
5+
36
WORKDIR /app
47

58
RUN pip install twyn
69

10+
RUN groupadd -g 1001 ${GROUP} && \
11+
useradd -m -u 1001 -g ${GROUP} -s /bin/bash ${USER}
12+
13+
USER ${USER}
14+
715
ENTRYPOINT ["twyn"]

justfile

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
# VARIABLE DEFINITIONS
22
venv := ".venv"
3-
bin := venv + "/bin"
4-
python := bin + "/python"
5-
python_version := "python3.13"
3+
python_version :="3.13"
64
target_dirs := "src tests"
75

8-
9-
# SENTINELS
10-
venv-exists := path_exists(venv)
11-
126
# ALIASES
137
alias t := test
148

@@ -19,32 +13,35 @@ alias t := test
1913
help:
2014
just --list --unsorted
2115

22-
# Generate the virtual environment.
23-
venv:
24-
@if ! {{ venv-exists }}; \
25-
then \
26-
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry env use {{ python_version }}; \
27-
poetry install; \
28-
fi
16+
# Cleans all artifacts generated while running this project, including the virtualenv.
17+
venv:
18+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv sync
2919

3020
# Cleans all artifacts generated while running this project, including the virtualenv.
3121
clean:
3222
@rm -f .coverage*
3323
@rm -rf {{ venv }}
3424

3525
# Runs the tests with the specified arguments (any path or pytest argument).
36-
test *test-args='': venv
37-
poetry run pytest {{ test-args }} --no-cov
26+
test *test-args='':
27+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run pytest {{ test-args }} --no-cov
3828

3929
# Runs all tests including coverage report.
40-
test-all: venv
41-
poetry run pytest
30+
test-all:
31+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run pytest
4232

4333
# Format all code in the project.
44-
format: venv
45-
poetry run ruff check {{ target_dirs }} --fix
34+
format:
35+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run ruff check {{ target_dirs }} --fix
4636

4737
# Lint all code in the project.
48-
lint: venv
49-
poetry run ruff check {{ target_dirs }}
50-
poetry run mypy {{ target_dirs }}
38+
lint:
39+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run ruff check {{ target_dirs }}
40+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv run mypy {{ target_dirs }}
41+
42+
43+
# Generate requirements.txt file
44+
dependencies:
45+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv sync
46+
@UV_PROJECT_ENVIRONMENT={{ venv }} UV_PYTHON={{ python_version }} uv pip freeze > requirements.txt
47+

0 commit comments

Comments
 (0)