Update the github actions to support uv instead of poetry

This commit is contained in:
Alexis Métaireau 2025-01-06 15:17:24 +01:00
parent ce25d51634
commit f3bc880b7e
No known key found for this signature in database
GPG key ID: C65C7A89A8FFC56E
9 changed files with 46 additions and 44 deletions

0
.github/workflows/build-deb.yml vendored Normal file
View file

View file

@ -85,16 +85,17 @@ jobs:
id: cache-container-image id: cache-container-image
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'poetry.lock', 'gvisor_wrapper/entrypoint.py') }} key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'uv.lock', 'gvisor_wrapper/entrypoint.py') }}
path: | path: |
share/container.tar.gz share/container.tar.gz
share/image-id.txt share/image-id.txt
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Build and push Dangerzone image - name: Build and push Dangerzone image
if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }} if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }}
run: | run: |
sudo apt-get install -y python3-poetry uv run ./install/common/build-image.py
python3 ./install/common/build-image.py
echo ${{ github.token }} | podman login ghcr.io -u USERNAME --password-stdin echo ${{ github.token }} | podman login ghcr.io -u USERNAME --password-stdin
gunzip -c share/container.tar.gz | podman load gunzip -c share/container.tar.gz | podman load
tag=$(cat share/image-id.txt) tag=$(cat share/image-id.txt)

View file

@ -36,9 +36,9 @@ jobs:
run: |- run: |-
apt-get update apt-get update
apt-get install -y git make python3 --no-install-recommends apt-get install -y git make python3 --no-install-recommends
poetry install --only lint,test uv sync --only-group test --only-group lint
- name: Run linters to enforce code style - name: Run linters to enforce code style
run: poetry run make lint run: uv run make lint
- name: Check that the QA script is up to date with the docs - name: Check that the QA script is up to date with the docs
run: "./dev_scripts/qa.py --check-refs" run: "./dev_scripts/qa.py --check-refs"
@ -59,16 +59,18 @@ jobs:
id: cache-container-image id: cache-container-image
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'poetry.lock', 'gvisor_wrapper/entrypoint.py') }} key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'uv.lock', 'gvisor_wrapper/entrypoint.py') }}
path: |- path: |-
share/container.tar.gz share/container.tar.gz
share/image-id.txt share/image-id.txt
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Build Dangerzone container image - name: Build Dangerzone container image
if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }} if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }}
run: | run: |
sudo apt-get install -y python3-poetry uv run ./install/common/build-image.py
python3 ./install/common/build-image.py
- name: Upload container image - name: Upload container image
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -110,8 +112,9 @@ jobs:
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.12" python-version: "3.12"
- run: pip install poetry - name: Install uv
- run: poetry install uses: astral-sh/setup-uv@v5
- run: uv sync
- name: Restore cached tessdata - name: Restore cached tessdata
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
@ -120,7 +123,7 @@ jobs:
fail-on-cache-miss: true fail-on-cache-miss: true
key: v1-tessdata-${{ hashFiles('./install/common/download-tessdata.py') }} key: v1-tessdata-${{ hashFiles('./install/common/download-tessdata.py') }}
- name: Run CLI tests - name: Run CLI tests
run: poetry run make test run: uv run make test
- name: Set up .NET CLI environment - name: Set up .NET CLI environment
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
@ -131,7 +134,7 @@ jobs:
run: wix extension add --global WixToolset.UI.wixext run: wix extension add --global WixToolset.UI.wixext
- name: Build the MSI installer - name: Build the MSI installer
# NOTE: This also builds the .exe internally. # NOTE: This also builds the .exe internally.
run: poetry run .\install\windows\build-app.bat run: uv run .\install\windows\build-app.bat
- name: Upload MSI installer - name: Upload MSI installer
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@ -166,12 +169,14 @@ jobs:
enableCrossOsArchive: true enableCrossOsArchive: true
fail-on-cache-miss: true fail-on-cache-miss: true
key: v1-tessdata-${{ hashFiles('./install/common/download-tessdata.py') }} key: v1-tessdata-${{ hashFiles('./install/common/download-tessdata.py') }}
- run: pip install poetry
- run: poetry install - name: Install uv
uses: astral-sh/setup-uv@v5
- run: uv sync
- name: Run CLI tests - name: Run CLI tests
run: poetry run make test run: uv run make test
- name: Build macOS app - name: Build macOS app
run: poetry run python ./install/macos/build-app.py run: uv run ./install/macos/build-app.py
- name: Upload macOS app - name: Upload macOS app
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@ -227,7 +232,7 @@ jobs:
- name: Restore container cache - name: Restore container cache
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'poetry.lock', 'gvisor_wrapper/entrypoint.py') }} key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'uv.lock', 'gvisor_wrapper/entrypoint.py') }}
path: |- path: |-
share/container.tar.gz share/container.tar.gz
share/image-id.txt share/image-id.txt
@ -334,7 +339,7 @@ jobs:
- name: Restore container image - name: Restore container image
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'poetry.lock', 'gvisor_wrapper/entrypoint.py') }} key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'uv.lock', 'gvisor_wrapper/entrypoint.py') }}
path: |- path: |-
share/container.tar.gz share/container.tar.gz
share/image-id.txt share/image-id.txt
@ -429,7 +434,7 @@ jobs:
- name: Restore container image - name: Restore container image
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
with: with:
key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'poetry.lock', 'gvisor_wrapper/entrypoint.py') }} key: v3-${{ steps.date.outputs.date }}-${{ hashFiles('Dockerfile', 'dangerzone/conversion/common.py', 'dangerzone/conversion/doc_to_pixels.py', 'dangerzone/conversion/pixels_to_pdf.py', 'uv.lock', 'gvisor_wrapper/entrypoint.py') }}
path: |- path: |-
share/container.tar.gz share/container.tar.gz
share/image-id.txt share/image-id.txt
@ -470,4 +475,4 @@ jobs:
# that the command in the Podman container can read the Xauthority # that the command in the Podman container can read the Xauthority
# file successfully. # file successfully.
xvfb-run -s '-ac' ./dev_scripts/env.py --distro ${{ matrix.distro }} --version ${{ matrix.version }} run --dev \ xvfb-run -s '-ac' ./dev_scripts/env.py --distro ${{ matrix.distro }} --version ${{ matrix.version }} run --dev \
bash -c 'cd dangerzone; poetry run make test' bash -c 'cd dangerzone; uv run make test'

View file

@ -1,2 +1,2 @@
set DANGERZONE_MODE=cli set DANGERZONE_MODE=cli
uv run python .\dev_scripts\dangerzone %* uv run .\dev_scripts\dangerzone %*

View file

@ -1,2 +1,2 @@
set DANGERZONE_MODE=gui set DANGERZONE_MODE=gui
uv run python .\dev_scripts\dangerzone %* uv run .\dev_scripts\dangerzone %*

View file

@ -116,7 +116,6 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends dh-python make build-essential \ && apt-get install -y --no-install-recommends dh-python make build-essential \
git {qt_deps} pipx python3 python3-pip python3-venv dpkg-dev debhelper python3-setuptools \ git {qt_deps} pipx python3 python3-pip python3-venv dpkg-dev debhelper python3-setuptools \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# NOTE: `pipx install poetry` fails on Ubuntu Focal, when installed through APT. By
# installing the latest version, we sidestep this issue. # installing the latest version, we sidestep this issue.
RUN bash -c 'if [[ "$(pipx --version)" < "1" ]]; then \ RUN bash -c 'if [[ "$(pipx --version)" < "1" ]]; then \
apt-get update \ apt-get update \
@ -138,9 +137,8 @@ DOCKERFILE_BUILD_DEV_FEDORA_41_DEPS = r"""
RUN dnf install -y python3.12 RUN dnf install -y python3.12
""" """
# FIXME: Install Poetry on Fedora via package manager.
DOCKERFILE_BUILD_DEV_FEDORA_DEPS = r""" DOCKERFILE_BUILD_DEV_FEDORA_DEPS = r"""
RUN dnf install -y git rpm-build podman python3 python3-devel python3-poetry-core \ RUN dnf install -y git rpm-build podman python3 python3-devel uv \
pipx make qt6-qtbase-gui \ pipx make qt6-qtbase-gui \
&& dnf clean all && dnf clean all
@ -179,14 +177,12 @@ VOLUME /home/user/dangerzone
RUN mkdir -p /home/user/.config/containers RUN mkdir -p /home/user/.config/containers
COPY storage.conf /home/user/.config/containers COPY storage.conf /home/user/.config/containers
# Install Poetry under ~/.local/bin. # Install uv under ~/.local/bin.
# See https://github.com/freedomofpress/dangerzone/issues/351
# FIXME: pipx install poetry does not work for Ubuntu Focal.
ENV PATH="$PATH:/home/user/.local/bin" ENV PATH="$PATH:/home/user/.local/bin"
RUN pipx install poetry RUN pipx install uv
COPY pyproject.toml poetry.lock /home/user/dangerzone/ COPY pyproject.toml uv.lock /home/user/dangerzone/
RUN cd /home/user/dangerzone && poetry --no-ansi install RUN cd /home/user/dangerzone && uv sync
""" """
DOCKERFILE_BUILD_DEBIAN_DEPS = r""" DOCKERFILE_BUILD_DEBIAN_DEPS = r"""
@ -291,7 +287,7 @@ def get_build_dir_sources(distro, version):
"""Return the files needed to build an image.""" """Return the files needed to build an image."""
sources = [ sources = [
git_root() / "pyproject.toml", git_root() / "pyproject.toml",
git_root() / "poetry.lock", git_root() / "uv.lock",
git_root() / "dev_scripts" / "storage.conf", git_root() / "dev_scripts" / "storage.conf",
git_root() / "dev_scripts" / "containers.conf", git_root() / "dev_scripts" / "containers.conf",
] ]

View file

@ -9,7 +9,7 @@ The following assumes that you have already setup the development environment.
Unit / integration tests are run with: Unit / integration tests are run with:
```bash ```bash
poetry run make test uv run make test
``` ```
## Run large tests ## Run large tests
@ -17,7 +17,7 @@ poetry run make test
We also have a larger set of tests that can take a day or more to run, where we evaluate the completeness of Dangerzone conversions. We also have a larger set of tests that can take a day or more to run, where we evaluate the completeness of Dangerzone conversions.
```bash ```bash
poetry run make test-large uv run make test-large
``` ```
### Test report generation ### Test report generation

View file

@ -24,26 +24,26 @@ We picked Doit out of the various tools out there for the following reasons:
## How to Doit? ## How to Doit?
First, enter your Poetry shell. Then, make sure that your environment is clean, Make sure that your environment is clean, and you have ample disk space. You
and you have ample disk space. You can run: can run:
```bash ```bash
doit clean --dry-run # if you want to see what would happen uv run doit clean --dry-run # if you want to see what would happen
doit clean # you'll be asked to cofirm that you want to clean everything uv run doit clean # you'll be asked to cofirm that you want to clean everything
``` ```
Finally, you can build all the release artifacts with `doit`, or a specific task Finally, you can build all the release artifacts with `doit`, or a specific task
with: with:
``` ```
doit <task> uv run doit <task>
``` ```
## Tips and tricks ## Tips and tricks
* You can run `doit list --all -s` to see the full list of tasks, their * You can run `uv run doit list --all -s` to see the full list of tasks, their
dependencies, and whether they are up to date. dependencies, and whether they are up to date.
* You can run `doit info <task>` to see which dependencies are missing. * You can run `uv run doit info <task>` to see which dependencies are missing.
* You can change this line in `pyproject.toml` to `true`, to allow using the * You can change this line in `pyproject.toml` to `true`, to allow using the
Docker/Podman build cache: Docker/Podman build cache:

View file

@ -9,11 +9,11 @@ It supports two types of environments:
1. Dev environment. This environment has developer tools, necessary for 1. Dev environment. This environment has developer tools, necessary for
Dangerzone, baked in. Also, it mounts the Dangerzone source under Dangerzone, baked in. Also, it mounts the Dangerzone source under
`/home/user/dangerzone` in the container. The developer can then run `/home/user/dangerzone` in the container. The developer can then run
Dangerzone from source, with `poetry run ./dev_scripts/dangerzone`. Dangerzone from source, with `uv run ./dev_scripts/dangerzone`.
2. End-user environment. This environment has only Dangerzone installed in it, 2. End-user environment. This environment has only Dangerzone installed in it,
from the .deb/.rpm package that we have created. For convenience, it also has from the .deb/.rpm package that we have created. For convenience, it also has
the Dangerzone source mounted under `/home/user/dangerzone`, but it lacks the Dangerzone source mounted under `/home/user/dangerzone`, but it lacks
Poetry and other build tools. The developer can run Dangerzone there with uv and other build tools. The developer can run Dangerzone there with
`dangerzone`. This environment is the most vanilla Dangerzone environment, `dangerzone`. This environment is the most vanilla Dangerzone environment,
and should be closer to the end user's environment, than the development and should be closer to the end user's environment, than the development
environment. environment.
@ -92,7 +92,7 @@ In order to build Dangerzone environments, the script uses the following inputs:
* Dev environment: * Dev environment:
- Distro name and version. Together, these comprise the base container image. - Distro name and version. Together, these comprise the base container image.
- `poetry.lock` and `pyproject.toml`. Together, these comprise the build - `uv.lock` and `pyproject.toml`. Together, these comprise the build
context. context.
* End-user environment: * End-user environment:
- Distro name and version. Together, these comprise the base container image. - Distro name and version. Together, these comprise the base container image.