Skip to content

Commit

Permalink
Update the github actions to support uv instead of poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Jan 6, 2025
1 parent ce25d51 commit f3bc880
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 44 deletions.
Empty file added .github/workflows/build-deb.yml
Empty file.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,17 @@ jobs:
id: cache-container-image
uses: actions/cache@v4
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: |
share/container.tar.gz
share/image-id.txt
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Build and push Dangerzone image
if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }}
run: |
sudo apt-get install -y python3-poetry
python3 ./install/common/build-image.py
uv run ./install/common/build-image.py
echo ${{ github.token }} | podman login ghcr.io -u USERNAME --password-stdin
gunzip -c share/container.tar.gz | podman load
tag=$(cat share/image-id.txt)
Expand Down
39 changes: 22 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
run: |-
apt-get update
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
run: poetry run make lint
run: uv run make lint
- name: Check that the QA script is up to date with the docs
run: "./dev_scripts/qa.py --check-refs"

Expand All @@ -59,16 +59,18 @@ jobs:
id: cache-container-image
uses: actions/cache@v4
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: |-
share/container.tar.gz
share/image-id.txt
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build Dangerzone container image
if: ${{ steps.cache-container-image.outputs.cache-hit != 'true' }}
run: |
sudo apt-get install -y python3-poetry
python3 ./install/common/build-image.py
uv run ./install/common/build-image.py
- name: Upload container image
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -110,8 +112,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install poetry
- run: poetry install
- name: Install uv
uses: astral-sh/setup-uv@v5
- run: uv sync
- name: Restore cached tessdata
uses: actions/cache/restore@v4
with:
Expand All @@ -120,7 +123,7 @@ jobs:
fail-on-cache-miss: true
key: v1-tessdata-${{ hashFiles('./install/common/download-tessdata.py') }}
- name: Run CLI tests
run: poetry run make test
run: uv run make test
- name: Set up .NET CLI environment
uses: actions/setup-dotnet@v4
with:
Expand All @@ -131,7 +134,7 @@ jobs:
run: wix extension add --global WixToolset.UI.wixext
- name: Build the MSI installer
# 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
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -166,12 +169,14 @@ jobs:
enableCrossOsArchive: true
fail-on-cache-miss: true
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
run: poetry run make test
run: uv run make test
- 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
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -227,7 +232,7 @@ jobs:
- name: Restore container cache
uses: actions/cache/restore@v4
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: |-
share/container.tar.gz
share/image-id.txt
Expand Down Expand Up @@ -334,7 +339,7 @@ jobs:
- name: Restore container image
uses: actions/cache/restore@v4
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: |-
share/container.tar.gz
share/image-id.txt
Expand Down Expand Up @@ -429,7 +434,7 @@ jobs:
- name: Restore container image
uses: actions/cache/restore@v4
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: |-
share/container.tar.gz
share/image-id.txt
Expand Down Expand Up @@ -470,4 +475,4 @@ jobs:
# that the command in the Podman container can read the Xauthority
# file successfully.
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'
2 changes: 1 addition & 1 deletion dev_scripts/dangerzone-cli.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set DANGERZONE_MODE=cli
uv run python .\dev_scripts\dangerzone %*
uv run .\dev_scripts\dangerzone %*
2 changes: 1 addition & 1 deletion dev_scripts/dangerzone.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set DANGERZONE_MODE=gui
uv run python .\dev_scripts\dangerzone %*
uv run .\dev_scripts\dangerzone %*
16 changes: 6 additions & 10 deletions dev_scripts/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
&& 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 \
&& 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.
RUN bash -c 'if [[ "$(pipx --version)" < "1" ]]; then \
apt-get update \
Expand All @@ -138,9 +137,8 @@
RUN dnf install -y python3.12
"""

# FIXME: Install Poetry on Fedora via package manager.
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 \
&& dnf clean all
Expand Down Expand Up @@ -179,14 +177,12 @@
RUN mkdir -p /home/user/.config/containers
COPY storage.conf /home/user/.config/containers
# Install Poetry under ~/.local/bin.
# See https://github.com/freedomofpress/dangerzone/issues/351
# FIXME: pipx install poetry does not work for Ubuntu Focal.
# Install uv under ~/.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/
RUN cd /home/user/dangerzone && poetry --no-ansi install
COPY pyproject.toml uv.lock /home/user/dangerzone/
RUN cd /home/user/dangerzone && uv sync
"""

DOCKERFILE_BUILD_DEBIAN_DEPS = r"""
Expand Down Expand Up @@ -291,7 +287,7 @@ def get_build_dir_sources(distro, version):
"""Return the files needed to build an image."""
sources = [
git_root() / "pyproject.toml",
git_root() / "poetry.lock",
git_root() / "uv.lock",
git_root() / "dev_scripts" / "storage.conf",
git_root() / "dev_scripts" / "containers.conf",
]
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ The following assumes that you have already setup the development environment.
Unit / integration tests are run with:

```bash
poetry run make test
uv run make test
```

## Run large tests

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
poetry run make test-large
uv run make test-large
```

### Test report generation
Expand Down
14 changes: 7 additions & 7 deletions docs/developer/doit.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ We picked Doit out of the various tools out there for the following reasons:

## How to Doit?

First, enter your Poetry shell. Then, make sure that your environment is clean,
and you have ample disk space. You can run:
Make sure that your environment is clean, and you have ample disk space. You
can run:

```bash
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 --dry-run # if you want to see what would happen
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
with:

```
doit <task>
uv run doit <task>
```

## 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.
* 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
Docker/Podman build cache:

Expand Down
6 changes: 3 additions & 3 deletions docs/developer/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ It supports two types of environments:
1. Dev environment. This environment has developer tools, necessary for
Dangerzone, baked in. Also, it mounts the Dangerzone source under
`/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,
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
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,
and should be closer to the end user's environment, than the development
environment.
Expand Down Expand Up @@ -92,7 +92,7 @@ In order to build Dangerzone environments, the script uses the following inputs:

* Dev environment:
- 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.
* End-user environment:
- Distro name and version. Together, these comprise the base container image.
Expand Down

0 comments on commit f3bc880

Please sign in to comment.