Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
feat: migrate from poetry to uv (#98)
Browse files Browse the repository at this point in the history
* feat: migrate from poetry to uv

---------

Signed-off-by: Ludovic Ortega <[email protected]>
  • Loading branch information
M0NsTeRRR authored Oct 18, 2024
1 parent 940a720 commit 9f17e21
Show file tree
Hide file tree
Showing 34 changed files with 1,918 additions and 2,089 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "napalm-fsos-ssh",
"image": "mcr.microsoft.com/devcontainers/python:3.11",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-contrib/features/poetry:2": {
"ghcr.io/va-h/devcontainers-features/uv:1": {
"version": "latest"
}
},
Expand Down
5 changes: 2 additions & 3 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

# Setup poetry
poetry install --with=dev
poetry shell
# Setup uv
uv sync
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python release
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
permissions:
# this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install the project
run: uv sync --all-extras
- name: Publish package
run: |
sed -i -e "s/0.0.0/${GITHUB_REF#refs/*/}/" pyproject.toml
uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
25 changes: 0 additions & 25 deletions .github/workflows/releases.yml

This file was deleted.

41 changes: 12 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,22 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Install poetry dependencies
run: |
export PATH="$PATH:$HOME/.local/bin"
poetry install --with=dev
- name: Run ruff
run: |
export PATH="$PATH:$HOME/.local/bin"
source `poetry env info --path`/bin/activate
poetry run ruff format --check .
poetry run ruff check .
- name: Run test
run: |
export PATH="$PATH:$HOME/.local/bin"
source `poetry env info --path`/bin/activate
poetry run pytest
run: uv python install ${{ matrix.python-version }}
- name: Install the project
run: uv sync --all-extras
- name: Run ruff format
run: uv run ruff format --check .
- name: Run ruff check
run: uv run ruff check .
- name: Run tests
run: uv run pytest --cov
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,19 @@ pip install napalm-fsos-ssh
A devcontainer is available

## Standard
Install [Poetry](https://python-poetry.org/docs/master/#installing-with-the-official-installer)
Install [uv](https://docs.astral.sh/uv/getting-started/installation/)

Install and setup dependencies
```
poetry install
poetry shell
pre-commit install
```
Install and setup dependencies with `uv sync`

### Run unit test
```
poetry run pytest
uv run pytest --cov
```

### Run linter & formatter
### Run ruff
```
poetry run ruff format .
poetry run ruff check .
uv run ruff format .
uv run ruff check .
```

# Switch configuration
Expand Down
Loading

0 comments on commit 9f17e21

Please sign in to comment.