-
-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (153 loc) · 5.23 KB
/
dotnet.yml
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
name: dotNet
on:
push:
branches:
- main
- develop
- feature/ci
pull_request:
branches:
- main
- develop
- feature/ci
jobs:
build-and-test-debug:
name: Build and test in Debug configuration
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
version: [6.x, 7.x]
defaults:
run:
working-directory: ./src
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup dotNET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Debug
- name: Test
run: dotnet test --no-build --verbosity normal
build-and-test-release:
name: Build and test in Release configuration
needs: build-and-test-debug
defaults:
run:
working-directory: ./src
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup dotNET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
#- name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: release-buid
# path: |
# ./jjm-one_jjm.one.Microsoft.Extensions.Logging.Helpers/bin/Release/*.nupkg
# retention-days: 1
sonarcloud:
name: Build and analyze with SonarCloud
needs: build-and-test-release
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Cache dotnet-coverage
id: cache-dotnet-coverage
uses: actions/cache@v1
with:
path: .\.dotnet-coverage\dotnet-coverage
key: ${{ runner.os }}-dotnet-coverage
restore-keys: ${{ runner.os }}-dotnet-coverage
- name: Setup dotNET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Install dotnet-coverage
if: steps.cache-dotnet-coverage.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.dotnet-coverage\dotnet-coverage -ItemType Directory
dotnet tool update dotnet-coverage --tool-path .\.dotnet-coverage\dotnet-coverage
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
cd .\src
.\..\.sonar\scanner\dotnet-sonarscanner begin /k:"jjm-one_jjm.one.Serilog.Sinks.SlackWebHook" /o:"jjm-one" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet restore
dotnet build --no-restore -c Debug
.\..\.dotnet-coverage\dotnet-coverage\dotnet-coverage collect "dotnet test --no-build --verbosity normal" -f xml -o "coverage.xml"
cat coverage.xml
.\..\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
#publish-nuget:
# name: Publish the NuGet package
# needs: [build-and-test-debug, build-and-test-release, sonarcloud, publish-doc]
# if: github.ref_type == 'tag' && startsWith(github.event.ref, 'refs/tags/version-')
# runs-on: ubuntu-latest
# steps:
# - name: Download a single artifact
# uses: actions/download-artifact@v3
# with:
# name: release-buid
# - name: Setup dotNET
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: 7.x
# - name: Publish the package to nuget.org
# run: |
# ls -la
# #run: dotnet nuget push */bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
# #env:
# # NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
publish-doc:
name: Publish Documentation
needs: [build-and-test-debug]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: DenverCoder1/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: doc/html
config_file: Doxyfile
target_folder: ${{ github.ref_name }}/doc/html