-
Notifications
You must be signed in to change notification settings - Fork 630
151 lines (131 loc) · 4.35 KB
/
lint.yml
File metadata and controls
151 lines (131 loc) · 4.35 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
140
141
142
143
144
145
146
147
148
149
150
151
# ===============================================================
# Lint & Static Analysis - Code Quality Gate
# ===============================================================
#
# - Lints both mcpgateway/ and plugins/ in a unified workflow
# - Python linters run per-target; repo-wide checks run once
# - Each job installs the project in dev-editable mode
# ---------------------------------------------------------------
name: Lint & Static Analysis
on:
push:
branches: ["main"]
paths:
- "mcpgateway/**"
- "plugins/**"
- "pyproject.toml"
- ".github/workflows/lint.yml"
pull_request:
types: [opened, synchronize, ready_for_review]
branches: ["main"]
paths:
- "mcpgateway/**"
- "plugins/**"
- "pyproject.toml"
- ".github/workflows/lint.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ---------------------------------------------------------------
# Python linters - run on both mcpgateway/ and plugins/
# ---------------------------------------------------------------
python-lint:
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
strategy:
fail-fast: false
matrix:
target: [mcpgateway, plugins]
tool:
- id: flake8
setup: pip install flake8
cmd: "flake8 $TARGET"
- id: ruff
setup: pip install ruff
cmd: "ruff check $TARGET"
- id: unimport
setup: pip install unimport
cmd: "unimport $TARGET"
- id: vulture
setup: pip install vulture
cmd: 'vulture $TARGET --min-confidence 80 --exclude "*_pb2.py,*_pb2_grpc.py"'
- id: pylint
setup: "true"
cmd: "uv run pylint $TARGET --rcfile=.pylintrc.$TARGET --fail-on E --fail-under=10"
- id: interrogate
setup: pip install interrogate
cmd: "interrogate -vv $TARGET --fail-under 100"
- id: radon
setup: pip install radon
cmd: "radon cc $TARGET --min C --show-complexity && radon mi $TARGET --min B"
name: "${{ matrix.tool.id }} (${{ matrix.target }})"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Install project (editable mode)
run: |
python3 -m pip install --upgrade pip
pip install -e .[dev]
- name: Install tool
run: ${{ matrix.tool.setup }}
- name: Run linter
env:
TARGET: ${{ matrix.target }}
run: ${{ matrix.tool.cmd }}
# ---------------------------------------------------------------
# Repo-wide syntax/format checkers (run once, not per-target)
# ---------------------------------------------------------------
syntax-check:
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
strategy:
fail-fast: false
matrix:
include:
- id: yamllint
setup: pip install yamllint
cmd: yamllint -c .yamllint .
- id: jsonlint
setup: |
sudo apt-get update -qq
sudo apt-get install -y jq
cmd: |
find . -type f -name '*.json' -not -path './node_modules/*' -print0 |
xargs -0 -I{} jq empty "{}"
- id: tomllint
setup: pip install tomlcheck
cmd: |
find . -type f -name '*.toml' \
-not -path './plugin_templates/*' \
-not -path './mcp-servers/templates/*' \
-print0 |
xargs -0 -I{} tomlcheck "{}"
name: ${{ matrix.id }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install tool
run: ${{ matrix.setup }}
- name: Run check
run: ${{ matrix.cmd }}