Skip to content

Commit a1362fe

Browse files
committed
refactor: Separate linting from unit tests workflows
- Added dedicated lint.yml workflow for ruff and flake8 linting - Single Python 3.11 version for consistency - Uses cached pip dependencies for speed - Runs ruff check and flake8 (syntax + style) - Updated tests.yml to focus only on unit tests - Removed linting steps - Added cached pip dependencies - Same Python matrix: 3.8, 3.10, 3.12 - Both workflows trigger on push/PR to main/dev + manual - Workflows now run in parallel for faster feedback
1 parent 7fc1c2d commit a1362fe

2 files changed

Lines changed: 60 additions & 14 deletions

File tree

.github/workflows/lint.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Lint code with ruff and flake8
2+
name: Lint Code
3+
4+
on:
5+
push:
6+
branches: ["main", "dev"]
7+
pull_request:
8+
branches: ["main", "dev"]
9+
workflow_dispatch:
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout source
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python 3.11
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Cache pip dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-lint-${{ hashFiles('requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-lint-
31+
32+
- name: Install linters
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install ruff flake8
36+
37+
- name: Lint with ruff
38+
run: |
39+
ruff check --output-format=github .
40+
41+
- name: Lint with flake8 (syntax)
42+
run: |
43+
# stop the build if there are Python syntax errors or undefined names
44+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
45+
46+
- name: Lint with flake8 (style)
47+
run: |
48+
# exit-zero treats all errors as warnings
49+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

.github/workflows/tests.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will install Python dependencies, run tests, and lint with a variety of Python versions
1+
# This workflow runs unit tests across multiple Python versions
22
name: Run Tests
33

44
on:
@@ -17,30 +17,27 @@ jobs:
1717
python-version: ["3.8", "3.10", "3.12"]
1818

1919
steps:
20-
- uses: actions/checkout@v4
20+
- name: Checkout source
21+
uses: actions/checkout@v4
2122

2223
- name: Set up Python ${{ matrix.python-version }}
2324
uses: actions/setup-python@v4
2425
with:
2526
python-version: ${{ matrix.python-version }}
2627

28+
- name: Cache pip dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip-tests-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-tests-${{ matrix.python-version }}-
35+
2736
- name: Install dependencies
2837
run: |
2938
python -m pip install --upgrade pip
30-
python -m pip install flake8 ruff
3139
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3240
33-
- name: Lint with ruff
34-
run: |
35-
ruff check --output-format=github .
36-
37-
- name: Lint with flake8
38-
run: |
39-
# stop the build if there are Python syntax errors or undefined names
40-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
41-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
42-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
43-
4441
- name: Run tests
4542
run: |
4643
python -m unittest discover tests

0 commit comments

Comments
 (0)