Skip to content

Commit f5bc395

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

File tree

13 files changed

+1293
-1473
lines changed

13 files changed

+1293
-1473
lines changed

.github/workflows/lint.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,24 @@ 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
40-
- name: Install commitizen
41-
run: |
42-
python -m pip install --upgrade pip
43-
python -m pip install commitizen
44-
- name: Check commit message
45-
run: cz check --rev-range HEAD
31+
uses: actions/checkout@v4
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v5
34+
- name: Install commitizen and check commit message
35+
run: uv run cz check --rev-range HEAD

.github/workflows/publish.yml

Lines changed: 12 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,26 @@ 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/poetry-publish@v2.1
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 --index testpypi
2326
2427
push_to_docker_hub:
25-
needs: push_to_pypi
28+
needs: publish_to_pypi
2629
name: Push Docker image to Docker Hub
2730
runs-on: ubuntu-latest
2831
steps:
2932
- name: Check out the repo
30-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3134

3235
- name: Log in to Docker Hub
3336
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-publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test Publish
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
permissions:
10+
id-token: write
11+
contents: read
12+
13+
jobs:
14+
publish_to_pypi:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
20+
with:
21+
version: "0.6.3"
22+
- name: Publish to PyPi
23+
run: |
24+
uv sync
25+
uv build
26+
uv publish --index testpypi
27+
env:
28+
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}

.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 git@github.com:<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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM python:3.13-slim
22

3+
USER twyn
4+
35
WORKDIR /app
46

57
RUN pip install 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)