Skip to content

Commit

Permalink
project: rework env and gh actions with uv and ruff (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
brutasse authored Oct 14, 2024
1 parent 3af22e9 commit 842ed69
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 73 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install and build
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Build docs
run: |
python -VV
python -m site
python -m pip install -U pip wheel setuptools
python -m pip install -e .[dev]
make html
- name: Publish
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
34 changes: 12 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install -U pip wheel setuptools
python -m pip install -U tox tox-gh-actions
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Tests
run: tox
run: |
uv --version
uv run --python ${{ matrix.python-version }} pytest
env:
EXOSCALE_API_KEY: ${{ secrets.EXOSCALE_API_KEY }}
EXOSCALE_API_SECRET: ${{ secrets.EXOSCALE_API_SECRET }}
Expand All @@ -41,16 +38,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install -U pip wheel setuptools
python -m pip install -U black flake8 flake8-import-order flake8-bugbear
- name: Set up ruff
run: curl -LsSf https://astral.sh/ruff/0.6.9/install.sh | sh
- name: Lint
run: |
black --check --diff .
flake8 .
shell: bash
run: |-
ruff check
2 changes: 2 additions & 0 deletions .github/workflows/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Update bundled openapi definition

"on":
push:
branches:
- master
workflow_dispatch:
schedule:
- cron: '0 * * * *' # At :00 every hour
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# If there is an issue in the build process, for example import error in the "reading process" job of sphinx-build
# It will only raise warning which won't make the job in the CI fail, but the HTML page will be empty.
# Therefore, we add the "--fail-on-warning" option.
SPHINXOPTS ?= --fail-on-warning
SPHINXBUILD ?= sphinx-build
SPHINXOPTS ?= -W
SPHINXBUILD ?= uv run -- sphinx-build
SOURCEDIR = docs
BUILDDIR = build

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ at this address: https://exoscale.github.io/python-exoscale

## Development

First create a new virtual environment and run `python -m pip install -e .[dev]`.
Install [uv](https://docs.astral.sh/uv/) and run:

```
uv sync
```

You can then run pytest with the following command:

pytest -x -s -vvv
```
uv run pytest -x -s -vvv
```

[exoscale]: https://www.exoscale.com/
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This provides Python bindings for the `Exoscale`_ cloud platform API.

.. note::
This library maintains compatibility with actively supported Python
versions: Python 3.7+. Older Python versions may be compatible but such
versions: Python 3.9+. Older Python versions may be compatible but such
compatibility is not guaranteed.

.. toctree::
Expand Down
29 changes: 17 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ classifiers = [
"License :: OSI Approved :: ISC License (ISCL)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"requests-exoscale-auth>=1.1.2",
Expand All @@ -31,15 +31,6 @@ dynamic = ["version"]
"Homepage" = "https://github.com/exoscale/python-exoscale"
"Bug Tracker" = "https://github.com/exoscale/python-exoscale/issues"

[project.optional-dependencies]
dev = [
"pytest>=5.0.0",
"recommonmark>=0.5.0",
"sphinx-markdown-parser>=0.1.1",
"sphinx-rtd-theme>=0.4.3",
"sphinx>=2.1.2",
]

[tool.hatch.version]
path = "exoscale/__init__.py"

Expand All @@ -48,6 +39,20 @@ include = [
"exoscale/*",
]

[tool.ruff]
line-length = 79
[tool.ruff.lint]
extend-select = ["B", "Q"]

[tool.black]
line-length = 79
exclude = "exoscale/api/polling.py"

[tool.uv]
dev-dependencies = [
"requests-mock>=1.12.1",
"pytest>=5.0.0",
"recommonmark>=0.5.0",
"sphinx-markdown-parser>=0.1.1",
"sphinx-rtd-theme>=0.4.3",
"sphinx>=2.1.2",
]
29 changes: 0 additions & 29 deletions tox.ini

This file was deleted.

0 comments on commit 842ed69

Please sign in to comment.