Add python linting #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/python-linting.yml | |
name: Run python linting | |
on: | |
workflow_call: | |
inputs: | |
runs-on: | |
description: 'The type of runner that the job will run on' | |
required: true | |
default: 'windows-latest' | |
jobs: | |
linters: | |
runs-on: ${{ inputs.runs-on }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read Python versions | |
id: read-python-versions | |
run: | | |
if [ ! -f .python-version ]; then | |
echo ".python-version file not found" | |
exit 1 | |
fi | |
PYTHON_VERSIONS=$(cat .python-version | tr ',' '\n' | xargs) | |
echo "PYTHON_VERSIONS=$PYTHON_VERSIONS" >> $GITHUB_ENV | |
echo "::set-output name=versions::$(echo $PYTHON_VERSIONS | jq -R 'split(" ")')" | |
- name: Set up matrix dynamically | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const versions = process.env.PYTHON_VERSIONS.split(" "); | |
return { python: versions }; | |
- name: Run tests on matrix | |
strategy: | |
matrix: | |
python-version: ${{ fromJSON(steps.read-python-versions.outputs.versions) }} | |
fail-fast: false | |
name: Run tests on Python ${{ matrix.python-version }} | |
steps: | |
- uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Set up Python ${{ matrix.python-version }} | |
run: uv python install ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --extra dev | |
- name: Run ruff format | |
run: uv run ruff format . --config .\pyproject.toml | |
- name: Run ruff check | |
run: uv run ruff check . --config .\pyproject.toml | |
- name: Run codespell | |
run: uv run codespell . |