Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
99 changes: 27 additions & 72 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,16 @@ jobs:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/checkout@v4

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: cached-poetry-dependencies
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: poetry install -E full
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run black
run: make black
Expand All @@ -52,33 +39,19 @@ jobs:
platform: [ubuntu-latest, macos-13, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/checkout@v4

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: cached-poetry-dependencies
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: poetry install -E full
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run pytest
run: poetry run pytest -vs
run: uv run pytest -vs

pytest_extras:
name: Testing ${{ matrix.extra }} on Python ${{ matrix.python-version }} (${{ matrix.platform}})
Expand All @@ -94,32 +67,18 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: cached-poetry-dependencies
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ matrix.extra }}-${{ hashFiles('**/poetry.lock') }}
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: poetry install -E ${{ matrix.extra }}
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Install the project
run: uv sync --locked --extra ${{ matrix.extra }}

- name: Run pytest
run: poetry run pytest -v -m ${{ matrix.extra }}
run: uv run pytest -v -m ${{ matrix.extra }}

release:
name: Releasing to pypi
Expand All @@ -128,22 +87,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: "3.9"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: prepare release
run: make fiximageurls

- name: prepare release
run: make fiximageurls

- name: build release
run: poetry build
run: uv build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributions are highly welcomed and appreciated!

## Development Environment

NetTowel uses [poetry](https://python-poetry.org/docs/) for packaging and
NetTowel uses [uv](https://docs.astral.sh/uv/) for packaging and
dependency management.

### Tests
Expand Down
14 changes: 4 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ FROM python:3.9

WORKDIR /workspace

ENV PATH="/root/.poetry/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1


RUN apt-get update && apt-get install curl -y \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python \
&& poetry config virtualenvs.create false
# Install uv.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

COPY . .

RUN poetry install --no-dev --extras full --no-interaction --no-ansi
ENV UV_PROJECT_ENVIRONMENT=/usr/local
RUN uv sync --frozen --no-cache --all-extras

CMD ["nettowel", "help"]
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PROJECT=nettowel
CODE_DIRS=${PROJECT} tests
CODE_DIRS=src/${PROJECT} tests
IMG_URL=https://raw.githubusercontent.com/InfrastructureAsCode-ch/nettowel/main/imgs/

# Run pytest
.PHONY: pytest
pytest:
poetry run pytest -vs ${ARGS}
uv run pytest -vs ${ARGS}

# Check if the python code needs to be reformatted
.PHONY: black
black:
poetry run black --check ${CODE_DIRS}
uv run black --check ${CODE_DIRS}

# Python type check
.PHONY: mypy
mypy:
poetry run mypy ${CODE_DIRS}
uv run mypy ${CODE_DIRS}

# Runn pytest, black and mypy
.PHONY: tests
Expand All @@ -24,9 +24,9 @@ tests: pytest black mypy
# use "make bump ARGS=patch" to bump the version. ARGS can be patch, minor or major.
.PHONY: bump
bump:
poetry version ${ARGS}
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" ${PROJECT}/__init__.py
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" tests/test_${PROJECT}.py
uv version --bump ${ARGS}
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" src/${PROJECT}/__init__.py
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" tests/test_${PROJECT}.py

# Used in the pipeline to change the image urls befor publishing it on pypi.org
.PHONY: fiximageurls
Expand All @@ -38,6 +38,6 @@ fiximageurls:
tag:
git checkout main
git pull
git tag -a "v`poetry version -s`" -m "Version v`poetry version -s`"
git tag -a "v`uv version --short`" -m "Version v`uv version --short`"
git push --tags
git checkout -
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pip install nettowel[full]
```
git clone ....
cd nettowel
poetry install
poetry run nettowel --help
uv sync --extra full
uv run nettowel --help
```


Expand Down
Loading
Loading