-
Notifications
You must be signed in to change notification settings - Fork 785
139 lines (134 loc) · 4.94 KB
/
code-quality.yml
File metadata and controls
139 lines (134 loc) · 4.94 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Code Quality
on:
push:
branches: ["main"]
paths:
- "backend/**"
- ".github/workflows/code-quality.yml"
pull_request:
branches: ["main"]
paths:
- "backend/**"
- ".github/workflows/code-quality.yml"
permissions:
contents: read
jobs:
ruff:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: 2.3.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-lint-deps
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./backend/.venv
key: lint-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install lint dependencies
if: steps.cached-lint-deps.outputs.cache-hit != 'true'
run: poetry install --only lint --no-interaction --no-root
- name: Ruff lint
if: github.event_name == 'push'
run: poetry run ruff check airweave/ --exclude airweave/alembic/
- name: Ruff format
if: github.event_name == 'push'
run: poetry run ruff format --check --diff airweave/ --exclude airweave/alembic/
- name: Run ruff check
if: github.event_name == 'pull_request'
run: |
poetry run ruff check airweave/ --exclude airweave/alembic/ \
--output-format pylint > ruff_report.txt || true
- name: Ruff lint (changed lines)
if: github.event_name == 'pull_request'
run: |
poetry run diff-quality --violations=ruff.check \
--compare-branch=origin/${{ github.base_ref }} \
--fail-under=100 \
ruff_report.txt
# Format is checked across the full codebase on PRs: since push
# ensures main is formatted, any failure must be from the PR.
- name: Ruff format (changed files)
if: github.event_name == 'pull_request'
run: poetry run ruff format --check --diff airweave/ --exclude airweave/alembic/
mypy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: 2.3.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-mypy-deps
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./backend/.venv
key: mypy-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-mypy-deps.outputs.cache-hit != 'true'
run: poetry install --no-interaction
- name: Run mypy
if: github.event_name == 'push'
run: poetry run mypy --config-file pyproject.toml airweave/
- name: Run mypy
if: github.event_name == 'pull_request'
run: |
poetry run mypy --config-file pyproject.toml airweave/ \
> mypy_report.txt || true
- name: Run mypy (changed lines)
if: github.event_name == 'pull_request'
run: |
poetry run diff-quality --violations=mypy \
--compare-branch=origin/${{ github.base_ref }} \
--fail-under=100 \
mypy_report.txt
import-linter:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: 2.3.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-importlint-deps
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./backend/.venv
key: lint-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install lint dependencies
if: steps.cached-importlint-deps.outputs.cache-hit != 'true'
run: poetry install --only lint --no-interaction --no-root
- name: Run import-linter
run: poetry run lint-imports