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
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage

on:
workflow_run:
workflows: [Tests]
types:
- completed

jobs:
report:
name: report coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
# Gives the action the necessary permissions for looking up the
# workflow that launched this workflow, and download the related
# artifact that contains the comment to be published
actions: read

steps:
# DO NOT run actions/checkout here, for security reasons
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Post comment
uses: py-cov-action/python-coverage-comment-action@v3.35
with:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
117 changes: 60 additions & 57 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
- develop
pull_request:
branches:
- "**"
- master
- develop

concurrency:
group: tests-${{ github.head_ref || github.ref }}
Expand Down Expand Up @@ -56,73 +57,75 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Install libxcb dependencies
if: ${{ matrix.os == 'ubuntu' }}
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get -qq update
sudo apt-get -qq install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl-dev

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT

- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.4 python - -y

- name: Update Path
if: ${{ matrix.os != 'windows' }}
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update Path for Windows
if: ${{ matrix.os == 'windows' }}
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH

- name: Enable long paths on Windows
if: ${{ matrix.os == 'windows' }}
run: git config --system core.longpaths true

- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Setup cache
uses: actions/cache@v4
id: cache
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.qt-version }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
version: "0.8.3"
enable-cache: true

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

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

- name: Check lock file
run: poetry check --lock
- name: Run tests
uses: coactions/setup-xvfb@v1
env:
QT_API: "${{ matrix.qt_version }}"
COVERAGE_FILE: ".coverage.${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}"
with:
run: uv run coverage run --context=${{matrix.qt-version}}

- name: Install dependencies
run: poetry install --with github-actions
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}
path: .coverage.${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.qt-version }}
include-hidden-files: true

coverage:
name: collect coverage
runs-on: ubuntu-latest
needs: tests
permissions:
pull-requests: write
contents: write

# - name: Run mypy
# run: poetry run mypy
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Install libxcb dependencies
if: ${{ matrix.os == 'ubuntu' }}
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get -qq update
sudo apt-get -qq install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl-dev
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3.35
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true
ANNOTATE_MISSING_LINES: true

- name: Run pytest
uses: coactions/setup-xvfb@v1
env:
QT_API: ${{ matrix.qt-version }}
- name: Store coverage comment to be posted
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
run: poetry run pytest --cov qasync -v
name: python-coverage-comment-action
path: python-coverage-comment-action.txt
36 changes: 15 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.10
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version-file: pyproject.toml

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.4 python - -y

- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build project for distribution
run: poetry build
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.3"
enable-cache: true

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

- name: Create Release
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'
allowUpdates: true
generateReleaseNotes: true
token: ${{ github.token }}

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: poetry publish
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish
15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.idea/*
.vscode/*
.python-version
.mise.toml
.DS_Store

# python
Expand All @@ -21,17 +22,7 @@ _build
.cache
*.so

# logs
pip-log.txt

# testing / coverage
.coverage
.coverage*
.pytest_cache

# release
/setup.cfg
MANIFEST.in
# /setup.py
/releases/*
pip-wheel-metadata
poetry.toml
.ruff_cache
42 changes: 23 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
default_stages:
- pre-commit
- pre-push
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.8.3
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: ^.*\.egg-info/
- id: check-merge-conflict
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: check-ast
- id: check-docstring-first

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
- id: uv-lock
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.12.5
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit
rev: v3.4.0
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: validate_manifest
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
exclude_types: [json]
- id: trailing-whitespace
exclude_types: [json]
33 changes: 0 additions & 33 deletions .pre-commit-hooks.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions Pipfile

This file was deleted.

Loading
Loading