Skip to content

Commit 57a7e2a

Browse files
authored
Switch to using uv instead of poetry, add test coverage (#145)
1 parent c0cd32f commit 57a7e2a

File tree

15 files changed

+691
-947
lines changed

15 files changed

+691
-947
lines changed

.github/workflows/coverage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Coverage
2+
3+
on:
4+
workflow_run:
5+
workflows: [Tests]
6+
types:
7+
- completed
8+
9+
jobs:
10+
report:
11+
name: report coverage
12+
runs-on: ubuntu-latest
13+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
14+
permissions:
15+
# Gives the action the necessary permissions for publishing new
16+
# comments in pull requests.
17+
pull-requests: write
18+
# Gives the action the necessary permissions for editing existing
19+
# comments (to avoid publishing multiple comments in the same PR)
20+
contents: write
21+
# Gives the action the necessary permissions for looking up the
22+
# workflow that launched this workflow, and download the related
23+
# artifact that contains the comment to be published
24+
actions: read
25+
26+
steps:
27+
# DO NOT run actions/checkout here, for security reasons
28+
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
29+
- name: Post comment
30+
uses: py-cov-action/[email protected]
31+
with:
32+
GITHUB_TOKEN: ${{ github.token }}
33+
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}

.github/workflows/main.yml

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- "**"
10+
- master
11+
- develop
1112

1213
concurrency:
1314
group: tests-${{ github.head_ref || github.ref }}
@@ -56,73 +57,75 @@ jobs:
5657
- name: Checkout
5758
uses: actions/checkout@v4
5859

59-
- name: Set up Python ${{ matrix.python-version }}
60+
- name: Install libxcb dependencies
61+
if: ${{ matrix.os == 'ubuntu' }}
62+
env:
63+
DEBIAN_FRONTEND: noninteractive
64+
run: |
65+
sudo apt-get -qq update
66+
sudo apt-get -qq install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl-dev
67+
68+
- name: Setup python ${{ matrix.python-version }}
6069
uses: actions/setup-python@v5
6170
with:
6271
python-version: ${{ matrix.python-version }}
6372

64-
- name: Get full Python version
65-
id: full-python-version
66-
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
67-
68-
- name: Bootstrap poetry
69-
run: |
70-
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.4 python - -y
71-
72-
- name: Update Path
73-
if: ${{ matrix.os != 'windows' }}
74-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
75-
76-
- name: Update Path for Windows
77-
if: ${{ matrix.os == 'windows' }}
78-
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
79-
80-
- name: Enable long paths on Windows
81-
if: ${{ matrix.os == 'windows' }}
82-
run: git config --system core.longpaths true
83-
84-
- name: Configure poetry
85-
run: poetry config virtualenvs.in-project true
86-
87-
- name: Setup cache
88-
uses: actions/cache@v4
89-
id: cache
73+
- name: Install uv
74+
uses: astral-sh/setup-uv@v6
9075
with:
91-
path: .venv
92-
key: venv-${{ runner.os }}-${{ matrix.qt-version }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
76+
version: "0.8.3"
77+
enable-cache: true
9378

94-
- name: Valdate cache
95-
if: steps.cache.outputs.cache-hit == 'true'
96-
run: |
97-
# `timeout` is not available on macos, so we define a custom function.
98-
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
79+
- name: Install qasync
80+
run: uv sync --locked --group dev
9981

100-
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
101-
timeout 10s poetry run pip --version || rm -rf .venv
82+
- name: Install qt ${{ matrix.qt-version }}
83+
run: uv pip install ${{ matrix.qt-version }}
10284

103-
- name: Check lock file
104-
run: poetry check --lock
85+
- name: Run tests
86+
uses: coactions/setup-xvfb@v1
87+
env:
88+
QT_API: "${{ matrix.qt_version }}"
89+
COVERAGE_FILE: ".coverage.${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}"
90+
with:
91+
run: uv run coverage run --context=${{matrix.qt-version}}
10592

106-
- name: Install dependencies
107-
run: poetry install --with github-actions
93+
- name: Upload coverage artifacts
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}
97+
path: .coverage.${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}
98+
include-hidden-files: true
99+
100+
coverage:
101+
name: collect coverage
102+
runs-on: ubuntu-latest
103+
needs: tests
104+
permissions:
105+
pull-requests: write
106+
contents: write
108107

109-
# - name: Run mypy
110-
# run: poetry run mypy
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v4
111111

112-
- name: Install Qt
113-
run: poetry run pip install --ignore-installed ${{ matrix.qt-version }}
112+
- name: Download coverage artifacts
113+
uses: actions/download-artifact@v4
114+
with:
115+
pattern: coverage-*
116+
merge-multiple: true
114117

115-
- name: Install libxcb dependencies
116-
if: ${{ matrix.os == 'ubuntu' }}
117-
env:
118-
DEBIAN_FRONTEND: noninteractive
119-
run: |
120-
sudo apt-get -qq update
121-
sudo apt-get -qq install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl-dev
118+
- name: Coverage comment
119+
id: coverage_comment
120+
uses: py-cov-action/[email protected]
121+
with:
122+
GITHUB_TOKEN: ${{ github.token }}
123+
MERGE_COVERAGE_FILES: true
124+
ANNOTATE_MISSING_LINES: true
122125

123-
- name: Run pytest
124-
uses: coactions/setup-xvfb@v1
125-
env:
126-
QT_API: ${{ matrix.qt-version }}
126+
- name: Store coverage comment to be posted
127+
uses: actions/upload-artifact@v4
128+
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
127129
with:
128-
run: poetry run pytest --cov qasync -v
130+
name: python-coverage-comment-action
131+
path: python-coverage-comment-action.txt

.github/workflows/release.yml

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,29 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v4
1515

16-
- name: Set up Python 3.10
16+
- name: Set up python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: "3.10"
19+
python-version-file: pyproject.toml
2020

21-
- name: Install Poetry
22-
run: |
23-
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.4 python - -y
24-
25-
- name: Update PATH
26-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
27-
28-
- name: Build project for distribution
29-
run: poetry build
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
version: "0.8.3"
25+
enable-cache: true
3026

31-
- name: Check Version
32-
id: check-version
33-
run: |
34-
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
27+
- name: Build qasync
28+
run: uv build
3529

36-
- name: Create Release
30+
- name: Create release
3731
uses: ncipollo/release-action@v1
3832
with:
3933
artifacts: "dist/*"
40-
token: ${{ secrets.GITHUB_TOKEN }}
41-
draft: false
42-
prerelease: steps.check-version.outputs.prerelease == 'true'
34+
allowUpdates: true
35+
generateReleaseNotes: true
36+
token: ${{ github.token }}
4337

4438
- name: Publish to PyPI
4539
env:
46-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
47-
run: poetry publish
40+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
41+
run: uv publish

.gitignore

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.idea/*
33
.vscode/*
44
.python-version
5+
.mise.toml
56
.DS_Store
67

78
# python
@@ -21,17 +22,7 @@ _build
2122
.cache
2223
*.so
2324

24-
# logs
25-
pip-log.txt
26-
2725
# testing / coverage
28-
.coverage
26+
.coverage*
2927
.pytest_cache
30-
31-
# release
32-
/setup.cfg
33-
MANIFEST.in
34-
# /setup.py
35-
/releases/*
36-
pip-wheel-metadata
37-
poetry.toml
28+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1+
default_stages:
2+
- pre-commit
3+
- pre-push
14
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
5+
- repo: https://github.com/astral-sh/uv-pre-commit
6+
# uv version.
7+
rev: 0.8.3
48
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
7-
exclude: ^.*\.egg-info/
8-
- id: check-merge-conflict
9-
- id: check-case-conflict
10-
- id: check-toml
11-
- id: check-yaml
12-
- id: check-ast
13-
- id: check-docstring-first
14-
15-
- repo: https://github.com/psf/black-pre-commit-mirror
16-
rev: 23.9.1
9+
- id: uv-lock
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
# Ruff version.
12+
rev: v0.12.5
1713
hooks:
18-
- id: black
19-
20-
- repo: https://github.com/pre-commit/pre-commit
21-
rev: v3.4.0
14+
# Run the linter.
15+
- id: ruff
16+
args: [--fix]
17+
# Run the formatter.
18+
- id: ruff-format
19+
- repo: https://github.com/pre-commit/pre-commit-hooks
20+
rev: v5.0.0
2221
hooks:
23-
- id: validate_manifest
22+
- id: check-yaml
23+
- id: check-toml
24+
- id: end-of-file-fixer
25+
exclude_types: [json]
26+
- id: trailing-whitespace
27+
exclude_types: [json]

.pre-commit-hooks.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Pipfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)