Skip to content
Open
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
54 changes: 32 additions & 22 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: Lint

on:
push:
branches:
- master
pull_request:

concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to master will not cancel.
# Concurrency configuration to cancel previous runs on the same branch/PR,
# ensuring only the latest commit is tested.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

Expand All @@ -19,31 +17,43 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.10']
# Select a stable, modern Python version for running lint tools
python-version: ['3.10']
steps:
- uses: actions/checkout@v4
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Optimization: Cache Poetry path and setup automatically using setup-python
cache: 'poetry'

- name: Install poetry
run: make poetry-download

- name: Set up cache
uses: actions/cache@v4
- name: Install Poetry
# Optimization: Use a dedicated action for faster and cleaner Poetry setup
uses: snok/install-poetry@v1
with:
path: |
.venv
~/.cache/pre-commit
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.pre-commit-config.yaml') }}
# Lock to a specific stable version of Poetry for consistency
version: 1.8.0

- name: Install dependencies
- name: Configure and Install Python Dependencies
# Poetry installs dependencies based on poetry.lock. We use --no-root
# as the lint job primarily needs dependencies, not the project itself installed.
run: |
poetry config virtualenvs.in-project true
make install
poetry install --no-root

- name: Lint
run: |
make pre-commit
- name: Set up Pre-Commit Cache
# Cache for pre-commit hooks themselves, independent of Python dependencies.
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
# Key depends only on the config file defining the hooks
key: pre-commit-v1-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-v1-

- name: Run Pre-Commit Hooks
# Run pre-commit within the poetry environment to ensure local dependencies are used
run: poetry run pre-commit run --all-files