Skip to content

Use uv with flit-core backend #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
- package-ecosystem: "uv" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
29 changes: 24 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,34 @@ on:
push:
branches:
- main

env:
UV_LOCKED: true # Assert that the `uv.lock` will remain unchanged

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: 3.x
# It is considered best practice to pin to a specific uv version.
version: "0.7.13"
python-version: ${{ matrix.python-version }}

- name: Install the project
# --no-dev: exclude group 'dev' from [dependency-groups]
# --group docs: include group 'dev' from [dependency-groups]
run: uv sync --no-dev --group docs

- name: Build and publish docs
run: uv run mkdocs gh-deploy --force

- run: pip install flit
- run: flit install --only-deps --deps develop
- run: mkdocs gh-deploy --force
# - uses: actions/setup-python@v2
# with:
# python-version: 3.x
# - run: pip install flit
# - run: flit install --only-deps --deps develop
# - run: mkdocs gh-deploy --force
49 changes: 37 additions & 12 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,47 @@ on:
release:
types: [created]

env:
UV_LOCKED: true # Assert that the `uv.lock` will remain unchanged

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
- name: Build and publish
# It is considered best practice to pin to a specific uv version.
version: "0.7.13"
python-version: ${{ matrix.python-version }}

- name: Build package
run: uv build

- name: Publish package
run: uv publish
env:
FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
run: |
flit publish
UV_PUBLISH_USERNAME: ${{ secrets.FLIT_USERNAME }}
UV_PUBLISH_PASSWORD: ${{ secrets.FLIT_PASSWORD }}

# TODO Migrate to trusted publishing with OIDC https://docs.pypi.org/trusted-publishers/
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1


# - 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 flit
# - name: Build and publish
# env:
# FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
# FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
# run: |
# flit publish
4 changes: 4 additions & 0 deletions .github/workflows/run-codspeed-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches: [ "main" ]

env:
UV_LOCKED: true # Assert that the `uv.lock` will remain unchanged

jobs:
codspeed:
name: Run benchmarks
Expand Down Expand Up @@ -40,6 +43,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v3

# TODO uv
- name: Install dependencies
run: |
apt update
Expand Down
46 changes: 36 additions & 10 deletions .github/workflows/run-linting-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
workflow_call:
pull_request:

env:
UV_LOCKED: true # Assert that the `uv.lock` will remain unchanged

jobs:
build:
name: Linting Tests
Expand All @@ -20,17 +23,40 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
# It is considered best practice to pin to a specific uv version.
version: "0.7.13"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
flit install --deps develop --symlink

- name: Install the project
# --all-extras: [project.optional-dependencies]
# --dev: group 'dev' from [dependency-groups]
run: uv sync --all-extras --dev

- name: Check with mypy
run: |
mypy .
run: uv run mypy .

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install flit
# flit install --deps develop --symlink
#
# - name: Check with mypy
# run: |
# mypy .

- name: Run remaining pre-commit hooks
uses: pre-commit/[email protected]
run: uv run pre-commit run --all-files

# TODO consider keeping the pre-commit action below, would need to add a step `uv pip install pip` before it
# - name: Run remaining pre-commit hooks
# uses: pre-commit/[email protected]
54 changes: 40 additions & 14 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
workflow_call:
pull_request:

env:
UV_LOCKED: true # Assert that the `uv.lock` will remain unchanged

jobs:
container_job:
name: Unit tests Python (${{ matrix.python-version }}) Postgres (${{ matrix.postgres-version }})
Expand All @@ -14,7 +17,8 @@ jobs:
python-version: ['3.11', '3.12', '3.13']
postgres-version: ['15', '16', '17']
fail-fast: false
container: python:${{ matrix.python-version }}-slim
# container: python:${{ matrix.python-version }}-slim
container: ubuntu:latest
services:
postgres:
image: postgres:${{ matrix.postgres-version }}-alpine
Expand All @@ -38,28 +42,50 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v3

- name: Install dependencies
run: |
apt update
apt install curl git build-essential libpq-dev libffi-dev -y
python -m pip install --upgrade pip
pip install flit
flit install --deps develop --symlink
echo "GIT_COMMIT_HASH=\"test\"" > orchestrator/version.py
env:
FLIT_ROOT_INSTALL: 1
- name: Run Unit tests
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest --cov-branch --cov=orchestrator --cov-report=xml --ignore=test --ignore=orchestrator/devtools --ignore=examples --ignore=docs --ignore=orchestrator/vendor
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
# It is considered best practice to pin to a specific uv version.
version: "0.7.13"
python-version: ${{ matrix.python-version }}

- name: Install the project
# --all-extras: [project.optional-dependencies]
# --dev: group 'dev' from [dependency-groups]
run: uv sync --all-extras --dev

# TODO this fails because the code cannot reach postgres and I have no idea why
- name: Run tests
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB uv run pytest --cov-branch --cov=orchestrator --cov-report=xml --ignore=test --ignore=orchestrator/devtools --ignore=examples --ignore=docs
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
POSTGRES_PASSWORD: nwa
POSTGRES_HOST: postgres
ENVIRONMENT: TESTING

# - name: Install dependencies
# run: |
# apt update
# apt install curl git build-essential libpq-dev libffi-dev -y
# python -m pip install --upgrade pip
# pip install flit
# flit install --deps develop --symlink
# echo "GIT_COMMIT_HASH=\"test\"" > orchestrator/version.py
# env:
# FLIT_ROOT_INSTALL: 1

# - name: Run Unit tests
# run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest --cov-branch --cov=orchestrator --cov-report=xml --ignore=test --ignore=orchestrator/devtools --ignore=examples --ignore=docs --ignore=orchestrator/vendor
# env:
# POSTGRES_DB: orchestrator-core-test
# POSTGRES_USER: nwa
# POSTGRES_PASSWORD: nwa
# POSTGRES_HOST: postgres
# ENVIRONMENT: TESTING
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends git build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY . .
# TODO uv
RUN pip install --upgrade pip --no-cache-dir
RUN pip install build --no-cache-dir
RUN python -m build --wheel --outdir dist
Expand Down
Loading
Loading