test(ci): add coverage for static-checks

Runs mypy and ruff. Add basic test.

- Update pyproject.toml dependencies groups
  - PDM can use top-level [dependency-groups] (PEP 735), support was added in pdm 2.20.0 (October 2024)
- Fix Ruff warnings
This commit is contained in:
Götz 2026-03-01 09:39:13 -05:00
parent 49a75f8118
commit b922d34db8
6 changed files with 299 additions and 35 deletions

39
.github/runtime/action.yml vendored Normal file
View file

@ -0,0 +1,39 @@
---
name: Install runtime
description: Install the required runtime and related base dependencies
inputs:
python:
description: "Install Python"
default: "true"
outputs:
python:
description: "Resolved version"
value: ${{ steps.get_version.outputs.python }}
runs:
using: "composite"
steps:
- name: Determine version
id: get_version
shell: bash -eo pipefail {0}
run: |
python="$(grep -E '^requires-python\s*=\s*\"' pyproject.toml | sed -E 's/.*\"[^0-9]*([0-9]+\.[0-9]+).*/\1/' | head -n1)"
if [ -z "$python" ]; then
exit 1
fi
echo "python=${python}" >> "$GITHUB_OUTPUT"
- name: Install Python
if: ${{ inputs.python == 'true' }}
uses: actions/setup-python@v6
with:
python-version: ${{ steps.get_version.outputs.python }}
- name: Show tooling information
shell: bash -eo pipefail {0}
run: |
set -x
python --version

67
.github/workflows/static-checks.yml vendored Normal file
View file

@ -0,0 +1,67 @@
name: Static Checks
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: static-checks-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
lint-and-typecheck:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install runtime
id: runtime
uses: ./.github/runtime
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ steps.runtime.outputs.python }}
cache: true
- name: Install dependencies
run: pdm sync -dG:all
- name: Ruff
run: pdm run ruff check src
- name: Mypy
run: pdm run mypy -p mpd_now_playable
tests:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install runtime
id: runtime
uses: ./.github/runtime
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ steps.runtime.outputs.python }}
cache: true
- name: Install dependencies
run: pdm sync -dG:all
- name: Run tests
run: pdm run pytest tests