Skip to content

Commit

Permalink
Use uv in github actions and recommend uv for dev (#650)
Browse files Browse the repository at this point in the history
This will become the main way we use the project for contributors. Any contributor can use other tools, 
but they'll have to find out how to use the project themselves. It doesn't change anything for end users.
  • Loading branch information
gabrieldemarmiesse authored Nov 20, 2024
1 parent 9a9f090 commit 140865d
Show file tree
Hide file tree
Showing 13 changed files with 1,132 additions and 75 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uv.lock linguist-generated=true

10 changes: 4 additions & 6 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Setup uv
run: ./scripts/install-uv.sh
- name: prepare
run: |
pip install -r ./requirements.txt -r docs/requirements.txt -e .
python docs/autogen.py
uv run docs/autogen.py
cp -r docs/generated_sources ./generated_sources
cp docs/mkdocs.yml ./
- name: Deploy docs
uses: mhausenblas/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUIREMENTS: docs/requirements.txt
REQUIREMENTS: docs/requirements.txt # TODO: use pyproject.toml
52 changes: 19 additions & 33 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,27 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup uv
run: ./scripts/install-uv.sh
- name: prepare
run: |
./scripts/ci-podman-update.sh
pip install -U pip wheel
pip install -r ./requirements.txt -r docs/requirements.txt -e .
./docs/autogen.py
uv run ./docs/autogen.py
cp -r docs/generated_sources ./generated_sources
cp docs/mkdocs.yml ./
- name: Render
run: mkdocs build
run: uv run mkdocs build

build-linux-lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Setup
run: |
pip install -U pip wheel
pip install -e ./[dev]
- name: Setup uv
run: ./scripts/install-uv.sh
- name: Run all checks
run: |
ruff check ./
ruff format --check ./
uv run ruff check ./
uv run ruff format --check ./
build-linux-test-component:
strategy:
Expand All @@ -67,47 +59,41 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Setup
- name: Setup uv
run: ./scripts/install-uv.sh
- name: Setup Podman and Docker
run: |
./scripts/ci-setup.sh
- name: Run tests
run: |
python -m pytest -vv --no-runtime-skip --durations=10 tests/python_on_whales/components/${{ matrix.component }}
uv run pytest -vv --no-runtime-skip --durations=10 tests/python_on_whales/components/${{ matrix.component }}
build-linux-test-other:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Setup
- name: Setup uv
run: ./scripts/install-uv.sh
- name: Setup Podman and Docker
run: |
./scripts/ci-setup.sh
- name: Run tests
run: |
python -m pytest -vv --no-runtime-skip --durations=10 --ignore=tests/python_on_whales/components/
uv run pytest -vv --no-runtime-skip --durations=10 --ignore=tests/python_on_whales/components/
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Setup uv
run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
- name: Setup
run: |
docker info
docker run hello-world
pip install -U pip wheel
pip install -e ./
pip install -r tests/test-requirements.txt
- name: Run single test
run: |
python -m pytest -vv --no-runtime-skip -m "not podman" tests/python_on_whales/components/test_volume.py::test_simple_volume
uv run pytest -vv --no-runtime-skip -m "not podman" tests/python_on_whales/components/test_volume.py::test_simple_volume
# cost too much at the moment.
# build-macos:
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build==1.0.0
- name: Setup uv
run: ./scripts/install-uv.sh
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USERNAME }}
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
uv build
uv publish
- name: Testing the uploaded wheel
run: |
python -m build
twine upload dist/*
uv run --with python-on-whales --no-project -- python -c "import python_on_whales"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ target/
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down Expand Up @@ -131,3 +129,5 @@ docs/generated_sources
docs/site
generated_sources/
mkdocs.yml

docs/README.md
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ repos:
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.3
hooks:
# Update the uv lockfile
- id: uv-lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
41 changes: 29 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,60 @@ First things first, if it's your first pull request to an open-source project, h
https://github.com/firstcontributions/first-contributions. This guide will explain
how to open a pull request in a github repository that you don't own.

This guide will assume that you are using [uv](https://docs.astral.sh/uv/) as your Package
manager, because this is the simplest way to get started. If you are using any other tool,
like pip, conda, rye, or poetry, refer to the documentation of your package manager, and take
a look at uv nonetheless, you might like it :)

Instructions to install uv can be found on [this page](https://docs.astral.sh/uv/getting-started/installation/).

## Building the docs

All docstring are fetched and put in templates. Everything is done in markdown,
with the help of [mkdocstrings](https://mkdocstrings.github.io/) and
[mkdocs](https://www.mkdocs.org/).

#### First install the dependencies:
#### Generate the documentation files and serve them

```
pip install -r docs/requirements.txt
```
With `uv`, you don't need to manually install the dependencies.

#### Generate the documentation files and serve them
```
cd ./docs/
python autogen.py && mkdocs serve
uv run autogen.py && cp ../README.md ./ && uv run mkdocs serve
```

Note that if you don't have podman installed, you will end up with an error when
generating the docs for `podman pods`. To bypass this, you can comment the last line
of the file `docs/docs_utils.py` which is responsible for generating the part of the documentation.

#### Open your browser

http://localhost:8000


## Running the tests

Install all dependencies and install python-on-whales in editable mode:
```
pip install -r requirements.txt -r tests/test-requirements.txt
pip install -e ./
Same as before, using `uv` means that you don't need to install anything. Just run
Then:

```bash
uv run pytest -v ./tests/
```

Then:
Feel free to explore the [pytes documentation](https://docs.pytest.org/en/6.2.x/usage.html) to
learn how to run a subset of the test suite.


## Pre-commit

We use a pre-commit to make sure the formatting and linting are correct before pushing changes.

Install the pre-commit by running:
```bash
pytest -v ./tests/
uvx --with=pre-commit pre-commit install
```

It will run automatically every time you call `git commit`.

## Exploring the codebase

Expand Down
22 changes: 19 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,24 @@ dynamic = ["dependencies"]
[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[project.optional-dependencies]
test = ["pytest"]
dev = ["ruff==0.5.6"]
[dependency-groups]
dev = [
"ruff>=0.5.6",
"pytest==7.*",
"pytest-mock>=3.14.0",
"pytz>=2024.2",
"astunparse==1.6.3",
"griffe==1.2.0",
"markdown==3.7",
"markupsafe==2.1.5",
"mkdocs==1.6.1",
"mkdocs-autorefs==1.1.0",
"mkdocs-get-deps==0.2.0",
"mkdocs-material==9.5.34",
"mkdocstrings==0.25.2",
"mkdocstrings-python==1.10.9",
"pymdown-extensions==10.9",
]

[project.urls]
"Source" = "https://github.com/gabrieldemarmiesse/python-on-whales"
Expand Down Expand Up @@ -51,3 +66,4 @@ markers = [
]
xfail_strict = true
pythonpath = ["./"]

4 changes: 0 additions & 4 deletions scripts/ci-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ THIS_DIR=$(dirname "${BASH_SOURCE[0]}")

docker info
podman info

pip install -U pip wheel
pip install -e ./
pip install -r tests/test-requirements.txt
2 changes: 2 additions & 0 deletions scripts/install-uv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
3 changes: 0 additions & 3 deletions tests/test-requirements.txt

This file was deleted.

Loading

0 comments on commit 140865d

Please sign in to comment.