-
-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (131 loc) · 4.54 KB
/
build.yml
File metadata and controls
162 lines (131 loc) · 4.54 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
159
160
161
162
name: Build and Test
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
DOTNET_VERSION: '9.0.x'
SOLUTION_FILE: 'DotNetDevMCP.sln'
jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
contents: read
checks: write
pull-requests: write
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Display .NET info
run: dotnet --info
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_FILE }}
- name: Build solution
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration ${{ matrix.configuration }} --no-restore
- name: Run tests with coverage
run: dotnet test tests/DotNetDevMCP.Core.Tests/DotNetDevMCP.Core.Tests.csproj --configuration ${{ matrix.configuration }} --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --results-directory ./coverage
timeout-minutes: 5
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.configuration == 'Release'
uses: codecov/codecov-action@v4
with:
directory: ./coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.os }}-${{ matrix.configuration }}
path: '**/test-results.trx'
- name: Publish test results
uses: dorny/test-reporter@v1
if: always()
with:
name: Test Results (${{ matrix.os }}-${{ matrix.configuration }})
path: '**/test-results.trx'
reporter: dotnet-trx
code-quality:
name: Code Quality Analysis
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_FILE }}
- name: Build solution
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Release --no-restore
- name: Run code analysis
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Release --no-restore /p:EnforceCodeStyleInBuild=true /p:TreatWarningsAsErrors=false
package:
name: Create NuGet Packages
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build, code-quality]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_FILE }}
- name: Build solution
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Release --no-restore
- name: Pack NuGet packages
run: dotnet pack ${{ env.SOLUTION_FILE }} --configuration Release --no-build --output ./artifacts
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./artifacts/*.nupkg
retention-days: 7
publish-demo:
name: Publish Sample Applications
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish OrchestrationDemo
run: dotnet publish samples/OrchestrationDemo/OrchestrationDemo.csproj --configuration Release --output ./publish/OrchestrationDemo
- name: Publish TestingServiceDemo
run: dotnet publish samples/TestingServiceDemo/TestingServiceDemo.csproj --configuration Release --output ./publish/TestingServiceDemo
- name: Upload published artifacts
uses: actions/upload-artifact@v4
with:
name: sample-applications
path: ./publish/**/*
retention-days: 7