Skip to content

Commit

Permalink
Convert from poetry => uv
Browse files Browse the repository at this point in the history
updated
  • Loading branch information
drake-nominal committed Jan 15, 2025
1 parent 1b960fb commit 7744ac7
Show file tree
Hide file tree
Showing 8 changed files with 3,057 additions and 3,660 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build-check-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
- uses: extractions/setup-just@v2
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install just
uses: extractions/setup-just@v2
- name: Install dependencies
run: |
just install
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
- uses: extractions/setup-just@v2
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install just
uses: extractions/setup-just@v2
- name: Install dependencies
run: |
just install
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and publish to PyPI
uses: JRubics/[email protected]
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Build and Publish Package to PYPI
run: |
uv build
uv publish --token ${{ secrets.PYPI_TOKEN }}
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Developer workflows are run with [`just`](https://github.com/casey/just). You can use `just -l` to list commands, and view the `justfile` for the commands.

We use `poetry` for packaging and developing. Add a depenency with `poetry add dep`, or `poetry add --group dev dep` for a dev dependency.
We use `uv` for packaging and developing. Add a depenency with `uv add dep`, or `uv add --dev dep` for a dev dependency.

We use `ruff` for formatting and imports, `mypy` for static typing, and `pytest` for testing.

To run all tests and checks: `just verify`. To include e2e tests (for Nominal developers): `just verify-e2e`.

As a rule, all tools should be configured via pyproject.toml, and should prefer configuration over parameters for project information. For example, `poetry run mypy` should work without having to run `poetry run mypy nominal`.
As a rule, all tools should be configured via pyproject.toml, and should prefer configuration over parameters for project information. For example, `uv run mypy` should work without having to run `uv run mypy nominal`.

Tests are written with `pytest`. By default, `pytest` runs all the tests in `tests/` except the end-to-end (e2e) tests in `tests/e2e`. To run e2e tests, `pytest` needs to be passed the e2e test directory with command-line arguments for connecting to the Nominal platform to test against. The e2e tests can be ran manually as:

```sh
poetry run pytest tests/e2e --auth-token AUTH_TOKEN [--base-url BASE_URL]
uv run pytest tests/e2e --auth-token AUTH_TOKEN [--base-url BASE_URL]
```

or simply with `just test-e2e <token>`.
44 changes: 29 additions & 15 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
set positional-arguments

# Default command is no subcommand given to list available commands
default:
@just --list

# development install with dependencies
install:
poetry install
uv sync

# Execute the python CLI
cli *args='--help':
uv run nom "$@"

# Enter into the python interpreter with all dependencies loaded
python *args:
uv run python "$@"

# run unit tests
test:
poetry run pytest
uv run pytest

# run e2e tests | token: auth token for api.nominal.test
test-e2e token:
poetry run pytest tests/e2e --auth-token {{token}}
uv run pytest tests/e2e --auth-token {{token}}

# check static typing
check-types:
poetry run mypy
uv run mypy

# check static typing across all supported python versions
check-types-all:
poetry run mypy --python-version 3.12
poetry run mypy --python-version 3.11
poetry run mypy --python-version 3.10
poetry run mypy --python-version 3.9
uv run mypy --python-version 3.12
uv run mypy --python-version 3.11
uv run mypy --python-version 3.10
uv run mypy --python-version 3.9

# check code formatting | fix with `just fix-format`
check-format:
poetry run ruff format --check
uv run ruff format --check

# check import ordering | fix with `just fix-imports`
check-imports:
poetry run ruff check
uv run ruff check

# run all static analysis checks
check: check-format check-types check-imports

# fixes out-of-order imports (note: mutates the code)
fix-imports:
poetry run ruff check --fix
uv run ruff check --fix

# fixes code formatting (note: mutates the code)
fix-format:
poetry run ruff format
uv run ruff format

# fix imports and formatting
fix: fix-format fix-imports
Expand All @@ -49,10 +63,10 @@ verify: install test check
# run all tests and checks, including e2e tests
verify-e2e token: install check test (test-e2e token)

# clean up poetry environments
# clean up uv environments
clean:
poetry env remove --all
uv cache clean

# build docs
build-docs:
poetry run mkdocs build
uv run mkdocs build
Loading

0 comments on commit 7744ac7

Please sign in to comment.