-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.21 KB
/
ci-lint.yml
File metadata and controls
82 lines (68 loc) · 2.21 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: "CI: Lint and Format Check"
run-name: "Lint: ${{ github.ref_name }}"
on:
push:
branches:
- main
- develop
- 'feature/**'
pull_request:
branches:
- main
- develop
- 'specification/**'
- 'implementation/**'
jobs:
lint:
name: Run Linting
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for Python changes
id: check
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA)
else
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
fi
echo "Changed files:"
echo "$CHANGED_FILES"
# Check if there are any Python files changed
PYTHON_CHANGES=$(echo "$CHANGED_FILES" | grep '\.py$' || true)
if [[ -n "$PYTHON_CHANGES" ]]; then
echo "Found Python changes, will run linting"
echo "should_lint=true" >> $GITHUB_OUTPUT
else
echo "No Python changes, skipping linting"
echo "should_lint=false" >> $GITHUB_OUTPUT
fi
- name: Set up Python
if: steps.check.outputs.should_lint == 'true'
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install uv
if: steps.check.outputs.should_lint == 'true'
uses: astral-sh/setup-uv@v7
- name: Install dependencies
if: steps.check.outputs.should_lint == 'true'
run: uv sync --extra dev
- name: Run linting
if: steps.check.outputs.should_lint == 'true'
run: uv run ruff check .
- name: Check code formatting
if: steps.check.outputs.should_lint == 'true'
run: uv run ruff format --check .
- name: Run type checking
if: steps.check.outputs.should_lint == 'true'
run: uv run --extra typecheck mypy api core --pretty
- name: Skip notice
if: steps.check.outputs.should_lint == 'false'
run: echo "::notice::Linting skipped - no Python files changed"