-
Notifications
You must be signed in to change notification settings - Fork 525
59 lines (51 loc) · 1.98 KB
/
lint.yml
File metadata and controls
59 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Lint
on:
push:
branches:
- master
pull_request:
concurrency:
# 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
jobs:
pre-commit:
runs-on: ubuntu-24.04
strategy:
matrix:
# Select a stable, modern Python version for running lint tools
python-version: ['3.10']
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- 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
# Optimization: Use a dedicated action for faster and cleaner Poetry setup
uses: snok/install-poetry@v1
with:
# Lock to a specific stable version of Poetry for consistency
version: 1.8.0
- 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
poetry install --no-root
- 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