forked from zereight/gitlab-mcp
-
Notifications
You must be signed in to change notification settings - Fork 2
121 lines (105 loc) · 3.63 KB
/
Copy pathcoverage-pages.yml
File metadata and controls
121 lines (105 loc) · 3.63 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
# GitHub Actions Workflow: Coverage Reports for Pull Requests
#
# This workflow runs tests with coverage on PRs and comments the results.
# Actual deployment to GitHub Pages is handled by docs.yml workflow.
#
# Coverage reports on the live site:
# https://gitlab-mcp.sw.foundation/coverage/
name: Coverage Report
on:
pull_request:
branches:
- main
paths:
- "src/**"
- "package.json"
- "yarn.lock"
- "tsconfig.json"
- "jest.config.*"
concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
issues: write
jobs:
coverage:
name: Generate Coverage Report
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Run tests with coverage
run: yarn test:cov
working-directory: packages/gitlab-mcp
- name: Extract coverage percentage
id: coverage
run: |
COVERAGE=$(cat packages/gitlab-mcp/coverage/lcov-report/index.html | grep -o 'class="strong">[0-9.]*%' | head -1 | grep -o '[0-9.]*')
echo "percentage=${COVERAGE:-0}" >> $GITHUB_OUTPUT
- name: Comment coverage on PR
continue-on-error: true
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
let summary;
try {
const json = JSON.parse(fs.readFileSync('packages/gitlab-mcp/coverage/coverage-summary.json', 'utf8'));
const t = json.total;
summary = [
'## Test Coverage Report',
'',
`**Overall Coverage:** ${t.lines.pct}%`,
'',
'| Metric | Percentage |',
'|--------|------------|',
`| Statements | ${t.statements.pct}% |`,
`| Branches | ${t.branches.pct}% |`,
`| Functions | ${t.functions.pct}% |`,
`| Lines | ${t.lines.pct}% |`,
'',
'[View detailed coverage report](https://gitlab-mcp.sw.foundation/coverage/)',
].join('\n');
} catch {
summary = `## Test Coverage Report\n\n**Coverage:** ${{ steps.coverage.outputs.percentage }}%`;
}
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.data.find(c => c.body.includes('## Test Coverage Report'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: summary
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: summary
});
}
- name: Upload coverage artifacts
uses: actions/upload-artifact@v7
with:
name: coverage-reports-${{ github.sha }}
path: packages/gitlab-mcp/coverage/
retention-days: 14