Skip to content

Commit 951c66a

Browse files
committed
Add linters
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 645f23e commit 951c66a

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

.github/workflows/lint.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# ===============================================================
2+
# 🔍 Lint & Static Analysis – Code Quality Gate
3+
# ===============================================================
4+
#
5+
# - runs each linter in its own matrix job for visibility
6+
# - mirrors the actual CLI commands used locally (no `make`)
7+
# - ensures fast-failure isolation: one failure doesn't hide others
8+
# - each job installs the project in dev-editable mode
9+
# - logs are grouped and plain-text for readability
10+
# ---------------------------------------------------------------
11+
12+
name: Lint & Static Analysis
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
branches: ["main"]
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
lint:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
# -------------------------------------------------------
30+
# 🧼 Syntax & Format Checkers
31+
# -------------------------------------------------------
32+
- id: yamllint
33+
setup: pip install yamllint
34+
cmd: yamllint -c .yamllint .
35+
36+
- id: jsonlint
37+
setup: |
38+
sudo apt-get update -qq
39+
sudo apt-get install -y jq
40+
cmd: |
41+
find . -type f -name '*.json' -not -path './node_modules/*' -print0 |
42+
xargs -0 -I{} jq empty "{}"
43+
44+
- id: tomllint
45+
setup: pip install tomlcheck
46+
cmd: |
47+
find . -type f -name '*.toml' -print0 |
48+
xargs -0 -I{} tomlcheck "{}"
49+
50+
# -------------------------------------------------------
51+
# 🐍 Python Linters & Type Checkers
52+
# -------------------------------------------------------
53+
- id: flake8
54+
setup: pip install flake8
55+
cmd: flake8 mcpgateway
56+
57+
- id: ruff
58+
setup: pip install ruff
59+
cmd: |
60+
ruff check .
61+
ruff format --check .
62+
63+
# - id: pylint
64+
# setup: pip install pylint
65+
# cmd: pylint mcpgateway
66+
67+
# - id: mypy
68+
# setup: pip install mypy
69+
# cmd: mypy mcpgateway
70+
71+
# - id: pycodestyle
72+
# setup: pip install pycodestyle
73+
# cmd: pycodestyle mcpgateway --max-line-length=200
74+
75+
# - id: pydocstyle
76+
# setup: pip install pydocstyle
77+
# cmd: pydocstyle mcpgateway
78+
79+
# - id: pyright
80+
# setup: npm install -g pyright
81+
# cmd: pyright mcpgateway tests
82+
83+
# -------------------------------------------------------
84+
# 🔒 Security & Packaging Checks
85+
# -------------------------------------------------------
86+
# - id: bandit
87+
# setup: pip install bandit
88+
# cmd: bandit -r mcpgateway
89+
90+
# - id: check-manifest
91+
# setup: pip install check-manifest
92+
# cmd: check-manifest
93+
94+
name: ${{ matrix.id }}
95+
runs-on: ubuntu-latest
96+
97+
steps:
98+
# -----------------------------------------------------------
99+
# 0️⃣ Checkout
100+
# -----------------------------------------------------------
101+
- name: ⬇️ Checkout source
102+
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 1
105+
106+
# -----------------------------------------------------------
107+
# 1️⃣ Python Setup
108+
# -----------------------------------------------------------
109+
- name: 🐍 Set up Python
110+
uses: actions/setup-python@v5
111+
with:
112+
python-version: "3.12"
113+
cache: pip
114+
115+
# -----------------------------------------------------------
116+
# 2️⃣ Install Project + Dev Dependencies
117+
# -----------------------------------------------------------
118+
- name: 📦 Install project (editable mode)
119+
run: |
120+
python -m pip install --upgrade pip
121+
pip install -e .[dev]
122+
123+
# -----------------------------------------------------------
124+
# 3️⃣ Install Tool-Specific Requirements
125+
# -----------------------------------------------------------
126+
- name: 🔧 Install tool - ${{ matrix.id }}
127+
run: ${{ matrix.setup }}
128+
129+
# -----------------------------------------------------------
130+
# 4️⃣ Run Linter / Validator
131+
# -----------------------------------------------------------
132+
- name: 🔍 Run ${{ matrix.id }}
133+
run: ${{ matrix.cmd }}

0 commit comments

Comments
 (0)