2
2
# 🧪 PyTest & Coverage – Quality Gate
3
3
# ===============================================================
4
4
#
5
- # This workflow
6
5
# • runs the full test-suite across three Python versions
7
6
# • measures branch + line coverage (fails < 40 %)
8
7
# • uploads the XML/HTML coverage reports as build artifacts
9
- # • generates / commits an SVG badge (main branch only)
10
- # • posts a concise coverage table to the job summary
11
- # • executes on every push/ PR to *main* and weekly
8
+ # • (optionally) generates / commits an SVG badge — kept disabled
9
+ # • posts a concise per-file coverage table to the job summary
10
+ # • executes on every push / PR to *main* ➕ a weekly cron
12
11
# ---------------------------------------------------------------
13
12
14
13
name : Tests & Coverage
22
21
# - cron: '42 3 * * 1' # Monday 03:42 UTC
23
22
24
23
permissions :
25
- contents : write # needed to commit the badge
24
+ contents : write # needed *only* if the badge-commit step is enabled
26
25
checks : write
27
26
actions : read
28
27
29
28
jobs :
30
29
test :
31
- name : pytest (${{ matrix.python }})
30
+ name : pytest (py ${{ matrix.python }})
32
31
runs-on : ubuntu-latest
33
32
34
33
strategy :
35
34
fail-fast : false
36
35
matrix :
37
- python : ["3.10", "3. 11", "3.12"]
36
+ python : ["3.11", "3.12"]
38
37
39
38
env :
40
39
PYTHONUNBUFFERED : " 1"
@@ -56,19 +55,19 @@ jobs:
56
55
uses : actions/setup-python@v5
57
56
with :
58
57
python-version : ${{ matrix.python }}
59
- cache : " pip"
58
+ cache : pip
60
59
61
60
# -----------------------------------------------------------
62
- # 2️⃣ Install dependencies
61
+ # 2️⃣ Install project + dev/test dependencies
63
62
# -----------------------------------------------------------
64
- - name : 📦 Install requirements
63
+ - name : 📦 Install dependencies
65
64
run : |
66
65
python -m pip install --upgrade pip
67
- if [ -f requirements- dev.txt ]; then
68
- pip install -r requirements -dev.txt
69
- else
70
- pip install pytest pytest-cov pytest-asyncio coverage[toml]
71
- fi
66
+ # Install mcpgateway with its dev extras (defined in pyproject.toml)
67
+ # This is the same as: make install -dev
68
+ pip install '.[dev]'
69
+ # Ensure core testing tools are present (no-ops if already satisfied)
70
+ pip install pytest pytest-cov pytest-asyncio coverage[toml]
72
71
73
72
# -----------------------------------------------------------
74
73
# 3️⃣ Run the tests with coverage
@@ -85,58 +84,60 @@ jobs:
85
84
86
85
# -----------------------------------------------------------
87
86
# 4️⃣ Upload coverage artifacts (XML + HTML)
87
+ # ––– keep disabled unless you need them –––
88
88
# -----------------------------------------------------------
89
+ # - name: 📤 Upload coverage.xml
90
+ # uses: actions/upload-artifact@v4
91
+ # with:
92
+ # name: coverage-xml-${{ matrix.python }}
93
+ # path: coverage.xml
94
+ #
95
+ # - name: 📤 Upload HTML coverage
96
+ # uses: actions/upload-artifact@v4
97
+ # with:
98
+ # name: htmlcov-${{ matrix.python }}
99
+ # path: htmlcov/
89
100
90
- # - name: 📤 Upload coverage.xml
91
- # uses: actions/upload-artifact@v4
92
- # with:
93
- # name: coverage-xml-${{ matrix.python }}
94
- # path: coverage.xml
95
- #
96
- # - name: 📤 Upload HTML coverage
97
- # uses: actions/upload-artifact@v4
98
- # with:
99
- # name: htmlcov-${{ matrix.python }}
100
- # path: htmlcov/
101
-
102
- # -----------------------------------------------------------
103
- # 5️⃣ Generate + commit badge (once, on main / highest ver)
104
- # -----------------------------------------------------------
105
- # - name: 📊 Create coverage badge
106
- # if: matrix.python == '3.11' && github.ref == 'refs/heads/main'
107
- # id: make_badge
108
- # uses: tj-actions/coverage-badge@v2
109
- # with:
110
- # coverage-file: coverage.xml # input
111
- # output: .github/badges/coverage.svg # output file
112
- # env:
113
- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101
+ # -----------------------------------------------------------
102
+ # 5️⃣ Generate + commit badge (main branch, highest Python)
103
+ # ––– intentionally commented-out –––
104
+ # -----------------------------------------------------------
105
+ # - name: 📊 Create coverage badge
106
+ # if: matrix.python == '3.11' && github.ref == 'refs/heads/main'
107
+ # id: make_badge
108
+ # uses: tj-actions/coverage-badge@v2
109
+ # with:
110
+ # coverage-file: coverage.xml # input
111
+ # output: .github/badges/coverage.svg # output file
112
+ # env:
113
+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114
+ #
115
+ # - name: 🚀 Commit badge
116
+ # if: steps.make_badge.outputs.badge-updated == 'true'
117
+ # uses: stefanzweifel/git-auto-commit-action@v5
118
+ # with:
119
+ # commit_message: "docs(badge): update coverage badge"
120
+ # file_pattern: ".github/badges/coverage.svg"
114
121
115
- # - name: 🚀 Commit badge
116
- # if: steps.make_badge.outputs.badge-updated == 'true'
117
- # uses: stefanzweifel/git-auto-commit-action@v5
118
- # with:
119
- # commit_message: "docs(badge): update coverage badge"
120
- # file_pattern: ".github/badges/coverage.svg"
122
+ # -----------------------------------------------------------
123
+ # 6️⃣ Publish coverage table to the job summary
124
+ # -----------------------------------------------------------
121
125
122
- # -----------------------------------------------------------
123
- # 6️⃣ Publish coverage table to the job summary
124
- # -----------------------------------------------------------
125
126
# - name: 📝 Coverage summary
126
127
# if: always()
127
128
# run: |
128
- # echo "### Coverage – Python ${{ matrix.python }}" >> $GITHUB_STEP_SUMMARY
129
- # # table header
130
- # echo "| File | Stmts | Miss | Branch | BrMiss | Cover |" >> $GITHUB_STEP_SUMMARY
131
- # echo "|------|------:|-----:|-------:|-------:|------:|" >> $GITHUB_STEP_SUMMARY
132
- # # append trimmed coverage report
129
+ # echo "### Coverage – Python ${{ matrix.python }}" >> "$GITHUB_STEP_SUMMARY"
130
+ # echo "| File | Stmts | Miss | Branch | BrMiss | Cover |" >> "$GITHUB_STEP_SUMMARY"
131
+ # echo "|------|------:|-----:|-------:|-------:|------:|" >> "$GITHUB_STEP_SUMMARY"
133
132
# coverage json -q -o cov.json
134
133
# python - <<'PY'
135
- # import json, os, pathlib, sys
136
- # d = json.load(open("cov.json"))
137
- # for f in d["files"].values():
138
- # rel = pathlib.Path(f["filename"]).relative_to(pathlib.Path().resolve())
139
- # print(f"| {rel} | {f['summary']['num_statements']} | {f['summary']['missing_lines']} | "
140
- # f"{f['summary']['num_branches']} | {f['summary']['missing_branches']} | "
141
- # f"{f['summary']['percent_covered']:.1f}% |")
142
- # PY >> $GITHUB_STEP_SUMMARY
134
+ # import json, pathlib, sys, os
135
+ # data = json.load(open("cov.json"))
136
+ # root = pathlib.Path().resolve()
137
+ # for f in data["files"].values():
138
+ # rel = pathlib.Path(f["filename"]).resolve().relative_to(root)
139
+ # s = f["summary"]
140
+ # print(f"| {rel} | {s['num_statements']} | {s['missing_lines']} | "
141
+ # f"{s['num_branches']} | {s['missing_branches']} | "
142
+ # f"{s['percent_covered']:.1f}% |")
143
+ # PY >> "$GITHUB_STEP_SUMMARY"
0 commit comments