Use astral-sh/ruff-action@v2 (#309) #813
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
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions | |
name: Lint and build | |
on: | |
workflow_dispatch: # Allows manual builds | |
inputs: | |
excludeBuildNumber: | |
description: "Exclude build number" | |
required: true | |
default: false | |
type: boolean | |
push: | |
branches: | |
- main | |
- master | |
- dev* | |
paths: | |
- "**.py" | |
- "**.ui" | |
- ".github/workflows/lint-and-build.yml" | |
- "**/requirements.txt" | |
pull_request: | |
branches: | |
- main | |
- master | |
- dev* | |
paths: | |
- "**.py" | |
- "**.pyi" | |
- "**.ui" | |
- ".github/workflows/lint-and-build.yml" | |
- "**/requirements*.txt" | |
env: | |
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} | |
GITHUB_EXCLUDE_BUILD_NUMBER: ${{ inputs.excludeBuildNumber }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
ruff: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout ${{ github.repository }}/${{ github.ref }} | |
uses: actions/checkout@v4 | |
- name: Get Ruff version | |
id: ruff_version | |
run: | | |
$Env:RUFF_VERSION=Select-String -path scripts/requirements-dev.txt -pattern 'ruff ?([=<>~]?= ?[\d\.]+)' | %{ $_.Matches[0].Groups[1].Value } | |
echo $Env:RUFF_VERSION | |
echo "RUFF_VERSION=$Env:RUFF_VERSION" >> $Env:GITHUB_OUTPUT | |
shell: pwsh | |
- uses: astral-sh/ruff-action@v2 | |
with: | |
version: ${{ steps.ruff_version.outputs.RUFF_VERSION }} | |
Pyright: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
# Pyright is version and platform sensible | |
matrix: | |
os: [windows-latest, ubuntu-22.04] | |
python-version: ["3.11", "3.12", "3.13"] | |
steps: | |
- name: Checkout ${{ github.repository }}/${{ github.ref }} | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
cache-dependency-path: "scripts/requirements*.txt" | |
- run: scripts/install.ps1 | |
shell: pwsh | |
- name: Get pyright version | |
id: pyright_version | |
run: | | |
PYRIGHT_VERSION=$(grep '$pyrightVersion = ' 'scripts/lint.ps1' | cut -d "#" -f 1 | cut -d = -f 2 | tr -d " '") | |
echo pyright version: "${PYRIGHT_VERSION}" | |
echo PYRIGHT_VERSION="${PYRIGHT_VERSION}" >> "${GITHUB_OUTPUT}" | |
shell: bash | |
- name: Analysing the code with Pyright | |
uses: jakebailey/pyright-action@v2 | |
with: | |
version: ${{ steps.pyright_version.outputs.PYRIGHT_VERSION }} | |
working-directory: src/ | |
python-version: ${{ matrix.python-version }} | |
Build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
# Only the Python version we plan on shipping matters. | |
matrix: | |
os: [windows-latest, ubuntu-22.04] | |
python-version: ["3.12", "3.13"] | |
include: | |
- os: ubuntu-22.04 | |
python-version: "3.11" # I had some Qt Wayland issues on 3.12 for ubuntu-22.04 iirc. TODO: test it | |
steps: | |
- name: Checkout ${{ github.repository }}/${{ github.ref }} | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
cache-dependency-path: "scripts/requirements.txt" | |
- run: scripts/install.ps1 | |
shell: pwsh | |
- run: scripts/build.ps1 | |
shell: pwsh | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: AutoSplit for ${{ matrix.os }} (Python ${{ matrix.python-version }}) | |
path: dist/AutoSplit* | |
if-no-files-found: error | |
- name: Upload Build logs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Build logs for ${{ matrix.os }} (Python ${{ matrix.python-version }}) | |
path: | | |
build/AutoSplit/*.toc | |
build/AutoSplit/*.txt | |
build/AutoSplit/*.html | |
if-no-files-found: error |