-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (139 loc) · 5.85 KB
/
build.yml
File metadata and controls
158 lines (139 loc) · 5.85 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
152
153
154
155
156
157
158
name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
runScenarioTests:
description: "Run MCP scenario (integration) tests"
required: false
default: "true"
# Cancel in-progress runs for the same branch to save CI resources
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "1"
steps:
- uses: actions/checkout@v6
- name: Setup .NET
id: setup_dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
- name: Display .NET info
id: dotnet_info
run: dotnet --info
- name: Restore dependencies
id: restore
run: dotnet restore DotNetMcp.slnx
- name: Build
id: build
run: dotnet build DotNetMcp.slnx --no-restore --configuration Release
- name: Validate server.json
id: validate_server_json
run: pwsh -File scripts/validate-server-json.ps1
- name: Run MCP Conformance Tests
id: conformance_tests
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests"
- name: Run MCP Scenario Tests
id: scenario_tests
# Run on all CI builds by default. Allow manual workflow runs to skip if desired.
if: ${{ github.event_name != 'workflow_dispatch' || inputs.runScenarioTests == 'true' }}
env:
DOTNET_MCP_SCENARIO_TESTS: "1"
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
- name: Test
id: test
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --coverage --coverage-output-format cobertura
- name: Collect coverage artifact
id: collect_coverage
shell: bash
run: |
set -euo pipefail
coverage_file=$(find DotNetMcp.Tests/bin/Release -name '*.cobertura.xml' | head -n 1)
if [[ -z "${coverage_file}" ]]; then
echo "Error: No coverage file found matching '*.cobertura.xml' under 'DotNetMcp.Tests/bin/Release'." >&2
exit 1
fi
echo "Found coverage file: ${coverage_file}"
cp "${coverage_file}" coverage.cobertura.xml
- name: Upload coverage to Codecov
id: upload_codecov
# Only upload from pushes (PR workflows from forks don't have secrets).
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: codecov/codecov-action@v5
with:
files: coverage.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Upload coverage artifact
id: upload_coverage_artifact
uses: actions/upload-artifact@v6
with:
name: coverage-cobertura
path: coverage.cobertura.xml
- name: Run Performance Smoke Tests
id: performance_smoke
# Performance tests are informational only and should not block CI
# Results are uploaded as artifacts for review
continue-on-error: true
shell: bash
run: |
set -uo pipefail
echo "Running performance smoke tests..."
dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj \
--no-build --configuration Release \
--verbosity detailed \
-- --filter-namespace "*Performance*" > performance-results.txt 2>&1 || true
echo "Performance smoke tests completed"
cat performance-results.txt
- name: Upload performance results artifact
id: upload_performance_artifact
uses: actions/upload-artifact@v6
with:
name: performance-results
path: performance-results.txt
if-no-files-found: warn
- name: Write workflow summary
if: always()
shell: bash
run: |
{
echo "## dotnet-mcp CI summary"
echo ""
echo "- Workflow: \`${{ github.workflow }}\`"
echo "- Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "- Ref: \`${{ github.ref }}\`"
echo "- SHA: \`${{ github.sha }}\`"
echo ""
echo "### Step outcomes"
echo "| Step | Outcome |"
echo "| --- | --- |"
echo "| Setup .NET | ${{ steps.setup_dotnet.outcome }} |"
echo "| dotnet --info | ${{ steps.dotnet_info.outcome }} |"
echo "| Restore | ${{ steps.restore.outcome }} |"
echo "| Build | ${{ steps.build.outcome }} |"
echo "| Validate server.json | ${{ steps.validate_server_json.outcome }} |"
echo "| Conformance tests | ${{ steps.conformance_tests.outcome }} |"
echo "| Scenario tests | ${{ steps.scenario_tests.outcome }} |"
echo "| Test (+coverage) | ${{ steps.test.outcome }} |"
echo "| Collect coverage artifact | ${{ steps.collect_coverage.outcome }} |"
echo "| Upload Codecov | ${{ steps.upload_codecov.outcome }} |"
echo "| Upload coverage artifact | ${{ steps.upload_coverage_artifact.outcome }} |"
echo "| Performance smoke | ${{ steps.performance_smoke.outcome }} |"
echo "| Upload performance artifact | ${{ steps.upload_performance_artifact.outcome }} |"
echo ""
echo "### Artifacts"
echo "- coverage-cobertura"
echo "- performance-results"
} >> "${GITHUB_STEP_SUMMARY}"