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
44 changes: 32 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
CD: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTHON_DEFAULT_VERSION: "3.12"
UV_VERSION: "0.8.24"

jobs:
deploy:
Expand Down Expand Up @@ -35,11 +36,16 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Build the distribution
id: build
run: nox -vs build
run: uv run nox -vs build
- name: Read the Changelog
id: read-changelog
uses: mindsers/changelog-reader-action@v2
Expand Down Expand Up @@ -75,21 +81,25 @@ jobs:
uses: deadsnakes/action@v3.2.0 # staticx doesn't work with python installed by setup-python action
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install patchelf scons
python -m pip install --upgrade nox pdm==2.26.4
uv sync --python ${{ env.PYTHON_DEFAULT_VERSION }} --locked --group nox
git config --global --add safe.directory '*'
- name: Bundle the distribution
id: bundle
run: nox -vs bundle
run: uv run nox -vs bundle
- name: Sign the bundle
id: sign
run: nox -vs sign
run: uv run nox -vs sign
- name: Generate hashes
id: hashes
run: nox -vs make_dist_digest
run: uv run nox -vs make_dist_digest
- name: Upload the bundle to the GitHub release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -113,12 +123,17 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Bundle the distribution
id: bundle
shell: bash
run: nox -vs bundle
run: uv run nox -vs bundle
- name: Install client for code signing with Software Trust Manager
uses: digicert/ssm-code-signing@v1.1.0
env:
Expand All @@ -131,10 +146,10 @@ jobs:
shell: bash
- name: Sign the bundle using a keypair alias
id: sign
run: nox -vs sign -- '${{ secrets.SM_KEYPAIR_ALIAS }}' '${{ secrets.SM_CERT_FINGERPRINT }}'
run: uv run nox -vs sign -- '${{ secrets.SM_KEYPAIR_ALIAS }}' '${{ secrets.SM_CERT_FINGERPRINT }}'
- name: Generate hashes
id: hashes
run: nox -vs make_dist_digest
run: uv run nox -vs make_dist_digest
- name: Create GitHub release and upload the distribution
id: create-release
uses: softprops/action-gh-release@v2
Expand All @@ -158,10 +173,15 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Build Dockerfile
run: nox -vs generate_dockerfile
run: uv run nox -vs generate_dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
92 changes: 66 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
PYTHON_DEFAULT_VERSION: "3.12"
UV_VERSION: "0.8.24"

jobs:
lint:
Expand All @@ -24,16 +25,21 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Run linters
run: nox -vs lint
run: uv run nox -vs lint
- name: Validate new changelog entries
if: (contains(github.event.pull_request.labels.*.name, '-changelog') == false) && (github.event.pull_request.base.ref != '')
run: if [ -z "$(git diff --diff-filter=A --name-only origin/${{ github.event.pull_request.base.ref }} changelog.d)" ];
then echo no changelog item added; exit 1; fi
- name: Changelog validation
run: nox -vs towncrier_check
run: uv run nox -vs towncrier_check
build:
timeout-minutes: 30
needs: lint
Expand All @@ -46,10 +52,15 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Build the distribution
run: nox -vs build
run: uv run nox -vs build
cleanup_buckets:
timeout-minutes: 30
needs: lint
Expand All @@ -68,12 +79,18 @@ jobs:
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
- uses: astral-sh/setup-uv@v7
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Find and remove old buckets
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
run: nox -vs cleanup_buckets
run: uv run nox -vs cleanup_buckets
test:
timeout-minutes: 90
needs: cleanup_buckets
Expand All @@ -100,6 +117,10 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install test binary dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
Expand All @@ -111,15 +132,16 @@ jobs:
run: |
brew install fish
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Run unit tests
run: nox -vs unit -p ${{ matrix.python-version }}
run: uv run nox -vs unit -p ${{ matrix.python-version }}
- name: Run integration tests (without secrets)
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "not require_secrets"
run: uv run nox -vs integration -p ${{ matrix.python-version }} -- -m "not require_secrets"
- name: Run integration tests (with secrets)
# Limit CI workload by running integration tests with secrets only on edge Python versions.
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' && contains(fromJSON('["3.9", "pypy3.10", "3.14"]'), matrix.python-version) }}
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "require_secrets" --cleanup
run: uv run nox -vs integration -p ${{ matrix.python-version }} -- -m "require_secrets" --cleanup
test-docker:
timeout-minutes: 90
needs: cleanup_buckets
Expand All @@ -136,10 +158,15 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Generate Dockerfile
run: nox -vs generate_dockerfile
run: uv run nox -vs generate_dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -153,7 +180,7 @@ jobs:
platforms: linux/amd64
- name: Run tests with docker
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
run: nox -vs docker_test -- backblazeit/b2:test
run: uv run nox -vs docker_test -- backblazeit/b2:test
test-linux-bundle:
timeout-minutes: 90
needs: cleanup_buckets
Expand All @@ -174,24 +201,28 @@ jobs:
uses: deadsnakes/action@v3.2.0 # staticx doesn't work with python installed by setup-python action
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install patchelf scons
python -m pip install --upgrade nox pdm==2.26.4
uv sync --python ${{ env.PYTHON_DEFAULT_VERSION }} --locked --group nox
git config --global --add safe.directory '*'
- name: Bundle the distribution
id: bundle
shell: bash
run: nox -vs bundle
run: uv run nox -vs bundle
- name: Generate hashes
id: hashes
run: nox -vs make_dist_digest
run: uv run nox -vs make_dist_digest
- name: Run integration tests (without secrets)
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
- name: Run integration tests (with secrets)
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
- name: Upload assets
if: failure()
uses: actions/upload-artifact@v4
Expand All @@ -216,20 +247,25 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: python -m pip install --upgrade nox pdm==2.26.4
run: |
uv sync --locked --group nox
- name: Bundle the distribution
id: bundle
shell: bash
run: nox -vs bundle
run: uv run nox -vs bundle
- name: Generate hashes
id: hashes
run: nox -vs make_dist_digest
run: uv run nox -vs make_dist_digest
- name: Run integration tests (without secrets)
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "not require_secrets"
- name: Run integration tests (with secrets)
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
run: nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
run: uv run nox -vs integration -p ${{ env.PYTHON_DEFAULT_VERSION }} -- --sut=${{ steps.bundle.outputs.sut_path }} -m "require_secrets" --cleanup
- name: Upload assets
if: failure()
uses: actions/upload-artifact@v4
Expand All @@ -250,12 +286,16 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update -y
sudo apt-get install -y graphviz plantuml
python -m pip install --upgrade nox pdm==2.26.4
uv sync --locked --group nox
- name: Build the docs
run: nox --non-interactive -vs doc
run: uv run nox --non-interactive -vs doc
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ for a given github issue).

## Developer Info

You'll need to have [nox](https://github.com/theacodes/nox) and [pdm](https://pdm-project.org/) installed:
You'll need to have [nox](https://github.com/theacodes/nox) and [uv](https://docs.astral.sh/uv/) installed:

* `pip install nox pdm`
* `pip install nox uv`

With `nox`, you can run different sessions (default are `lint` and `test`):

Expand Down Expand Up @@ -106,10 +106,10 @@ Given Python interpreters should be installed in the operating system or via [py

## Managing dependencies

We use [pdm](https://pdm-project.org/) for managing dependencies and developing locally.
We use [uv](https://docs.astral.sh/uv/) for managing dependencies and developing locally.
If you want to change any of the project requirements (or requirement bounds) in `pyproject.toml`,
make sure that `pdm.lock` file reflects those changes by using `pdm add`, `pdm update` or other
commands - see [documentation](https://pdm-project.org/latest/). You can verify that lock file
make sure that `uv.lock` file reflects those changes by using `uv add`, `uv lock` or other
commands - see [documentation](https://docs.astral.sh/uv/). You can verify that lock file
is up to date by running the linter.

## Linting
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+pdm-to-uv.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrate from pdm to uv.
19 changes: 10 additions & 9 deletions docker/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
FROM python:${python_version}-slim as builder

RUN apt-get update -y && apt-get install git patchelf -y && pip install -U pdm
RUN apt-get update -y && apt-get install git patchelf -y && pip install -U uv==0.8.24

WORKDIR /b2
COPY ./b2 /b2/b2
COPY pyproject.toml pdm.lock LICENSE README.md /b2/
COPY pyproject.toml uv.lock LICENSE README.md /b2/

ENV PDM_BUILD_SCM_VERSION=${version}
RUN pdm install --prod --group license
RUN pdm run b2 license --dump --with-packages
# Run pdm in PEP 582 mode, install packaged to __pypackages__, not virtualenv
RUN rm -r .venv && mkdir __pypackages__ && pdm install --prod --group full --no-editable
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${version}
RUN uv sync --locked --no-dev --extra license
RUN uv run b2 license --dump --with-packages
RUN rm -r .venv && mkdir __pypackages__
RUN uv export --locked --no-dev --extra full --no-hashes --no-editable -o requirements.txt
RUN uv pip install --compile-bytecode --python /usr/local/bin/python --prefix __pypackages__ -r requirements.txt

FROM python:${python_version}-slim

Expand All @@ -26,8 +27,8 @@ LABEL build-date-iso8601="${build_date}"
ENV B2_CLI_DOCKER=1
ENV PYTHONPATH=/opt/b2
COPY ./docker/entrypoint.sh /entrypoint.sh
COPY --from=builder /b2/__pypackages__/${python_version}/lib /opt/b2
COPY --from=builder /b2/__pypackages__/${python_version}/bin/* /bin/
COPY --from=builder /b2/__pypackages__/lib/python${python_version}/site-packages /opt/b2
COPY --from=builder /b2/__pypackages__/bin/* /bin/

WORKDIR /root
ENTRYPOINT ["/entrypoint.sh"]
Expand Down
Loading