Skip to content

Commit 010f14e

Browse files
committed
CI, Linters, formatter, release flow
1 parent f776a3e commit 010f14e

24 files changed

+2500
-395
lines changed

.github/dependabot.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Python dependencies
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
open-pull-requests-limit: 10
11+
commit-message:
12+
prefix: "deps"
13+
include: "scope"
14+
labels:
15+
- "dependencies"
16+
17+
# Enable version updates for GitHub Actions
18+
- package-ecosystem: "github-actions"
19+
directory: "/"
20+
schedule:
21+
interval: "weekly"
22+
day: "monday"
23+
time: "09:00"
24+
open-pull-requests-limit: 5
25+
commit-message:
26+
prefix: "ci"
27+
include: "scope"
28+
labels:
29+
- "dependencies"
30+
31+
# Enable version updates for Docker
32+
- package-ecosystem: "docker"
33+
directory: "/"
34+
schedule:
35+
interval: "weekly"
36+
day: "monday"
37+
time: "09:00"
38+
open-pull-requests-limit: 5
39+
commit-message:
40+
prefix: "docker"
41+
include: "scope"
42+
labels:
43+
- "dependencies"

.github/workflows/ci.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- '[0-9].[0-9]'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- '[0-9].[0-9]'
12+
schedule:
13+
- cron: '0 1 * * *' # nightly build
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
lint-and-format:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: ⚙️ Harden Runner
23+
uses: step-security/harden-runner@v2
24+
with:
25+
egress-policy: audit
26+
27+
- name: ⚙️ Checkout the project
28+
uses: actions/checkout@v4
29+
30+
- name: ⚙️ Install uv
31+
uses: astral-sh/setup-uv@v4
32+
with:
33+
version: "latest"
34+
35+
- name: ⚙️ Set Python up and add dependencies
36+
run: |
37+
uv python install 3.12
38+
uv sync --all-extras --dev
39+
uv add --dev ruff isort mypy
40+
41+
- name: ⚙️ Run linters and formatters
42+
run: |
43+
uv run ruff check src/ tests/
44+
uv run ruff format --check src/ tests/
45+
uv run isort --check-only src/ tests/
46+
uv run mypy src/ --ignore-missing-imports
47+
48+
49+
security-scan:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: ⚙️ Harden Runner
53+
uses: step-security/harden-runner@v2
54+
with:
55+
egress-policy: audit
56+
57+
- name: ⚙️ Checkout the project
58+
uses: actions/checkout@v4
59+
60+
- name: ⚙️ Install uv
61+
uses: astral-sh/setup-uv@v4
62+
with:
63+
version: "latest"
64+
65+
- name: ⚙️ Set Python up and add dependencies
66+
run: |
67+
uv python install 3.12
68+
uv sync --all-extras --dev
69+
uv add --dev bandit safety
70+
71+
- name: ⚙️ Run security scan with bandit
72+
run: |
73+
uv run bandit -r src/ -f json -o bandit-report.json || true
74+
uv run bandit -r src/
75+
uv run safety check --output json > safety-report.json || true
76+
uv run safety check
77+
78+
- name: ⚙️ Upload security reports
79+
uses: actions/upload-artifact@v4
80+
if: always()
81+
with:
82+
name: security-reports
83+
path: |
84+
bandit-report.json
85+
safety-report.json
86+
retention-days: 30
87+
88+
89+
test:
90+
runs-on: ${{ matrix.os }}
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
os: [ubuntu-latest, windows-latest, macos-latest]
95+
python-version: ["3.10", "3.11", "3.12", "3.13"]
96+
97+
services:
98+
redis:
99+
image: redis:latest
100+
ports:
101+
- 6379:6379
102+
options: >-
103+
--health-cmd "redis-cli ping"
104+
--health-interval 10s
105+
--health-timeout 5s
106+
--health-retries 5
107+
108+
steps:
109+
- name: ⚙️ Harden Runner
110+
uses: step-security/harden-runner@v2
111+
with:
112+
egress-policy: audit
113+
if: matrix.os == 'ubuntu-latest'
114+
115+
- name: ⚙️ Checkout the project
116+
uses: actions/checkout@v4
117+
118+
- name: ⚙️ Install uv
119+
uses: astral-sh/setup-uv@v4
120+
with:
121+
version: "latest"
122+
123+
- name: ⚙️ Set Python ${{ matrix.python-version }} up and add dependencies
124+
run: |
125+
uv python install ${{ matrix.python-version }}
126+
uv sync --all-extras --dev
127+
uv add --dev pytest pytest-cov pytest-asyncio coverage
128+
129+
- name: ⚙️ Run tests with coverage
130+
run: |
131+
uv run pytest tests/ -v --cov=src --cov-report=xml --cov-report=html --cov-report=term
132+
env:
133+
REDIS_HOST: localhost
134+
REDIS_PORT: 6379
135+
136+
- name: ⚙️ Test MCP server startup
137+
run: |
138+
timeout 10s uv run python src/main.py || test $? = 124
139+
env:
140+
REDIS_HOST: localhost
141+
REDIS_PORT: 6379
142+
if: matrix.os != 'windows-latest'
143+
144+
- name: ⚙️ Test MCP server startup (Windows)
145+
run: |
146+
Start-Process -FilePath "uv" -ArgumentList "run", "python", "src/main.py" -PassThru | Wait-Process -Timeout 10 -ErrorAction SilentlyContinue
147+
env:
148+
REDIS_HOST: localhost
149+
REDIS_PORT: 6379
150+
if: matrix.os == 'windows-latest'
151+
152+
- name: ⚙️ Upload coverage reports
153+
uses: codecov/codecov-action@v4
154+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
155+
with:
156+
file: ./coverage.xml
157+
flags: unittests
158+
name: codecov-umbrella
159+
160+
161+
build-test:
162+
runs-on: ubuntu-latest
163+
needs: [lint-and-format, security-scan, test]
164+
steps:
165+
- name: ⚙️ Harden Runner
166+
uses: step-security/harden-runner@v2
167+
with:
168+
egress-policy: audit
169+
170+
- name: ⚙️ Checkout the project
171+
uses: actions/checkout@v4
172+
with:
173+
fetch-depth: 0 # Full history for hatch-vcs
174+
175+
- name: ⚙️ Install uv
176+
uses: astral-sh/setup-uv@v4
177+
with:
178+
version: "latest"
179+
180+
- name: ⚙️ Set up Python
181+
run: uv python install 3.12
182+
183+
- name: ⚙️ Build package
184+
run: |
185+
uv build --sdist --wheel
186+
187+
- name: ⚙️ Check package
188+
run: |
189+
uv add --dev twine
190+
uv run twine check dist/*
191+
192+
- name: ⚙️ Test package installation
193+
run: |
194+
uv venv test-env
195+
source test-env/bin/activate
196+
pip install dist/*.whl
197+
redis-mcp-server --help
198+
199+
- name: ⚙️ Upload build artifacts
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: dist-files
203+
path: dist/
204+
retention-days: 7
205+
206+
207+
docker-test:
208+
runs-on: ubuntu-latest
209+
needs: [lint-and-format, security-scan]
210+
steps:
211+
- name: ⚙️ Harden Runner
212+
uses: step-security/harden-runner@v2
213+
with:
214+
egress-policy: audit
215+
216+
- name: ⚙️ Checkout the project
217+
uses: actions/checkout@v4
218+
219+
- name: ⚙️ Build Docker image
220+
run: docker build -t redis-mcp-server:test .
221+
222+
- name: ⚙️ Test Docker image
223+
run: |
224+
docker run --rm redis-mcp-server:test uv run python -c "import src.main; print('Docker build successful')"

0 commit comments

Comments
 (0)