-
Notifications
You must be signed in to change notification settings - Fork 31
/
.appveyor.yml
160 lines (129 loc) · 5.8 KB
/
.appveyor.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
environment:
VERIFY_STRONG_NAME: true
MYGET_FEED_NAME: protobuf-net-data
MYGET_API_KEY:
secure: nytRGOBtWS0dWOqFC+An404HzC6atrfxE6svU7krxgdSFtZsk1PCl9SHrXfwIo5P
NUGET_API_KEY:
secure: BUBZyq3OI1NQfIkROEWc/9gKWwOt2uC/0RGj0/ikIbUzdIkzyD9oaYM2il1tu9RV
SONARQUBE_ORGANIZATION: dotarj-github
SONARQUBE_TOKEN:
secure: HQS7qJC86vzZyNvzPucVQGBtwGXeZDcXtFm41i/Whb4NG9WqFLXtVN1DGYW1AlsP
SONARQUBE_GITHUB_TOKEN:
secure: qiHkpCjbUnNIsRJoHhjZNwVqyJIBHTI8KToNRyATp03ilRQfKp4xkWoaGgTcHLCv
image: Visual Studio 2017
skip_tags: false
branches:
only:
- master
configuration: Release
init:
- ps: |
function Execute-Action {
param($description, $action)
Write-Host (Get-Date).ToString("hh:mm:ss.fff") "STARTED $description" -ForegroundColor Magenta
&$action
Write-Host (Get-Date).ToString("hh:mm:ss.fff") "FINISHED $description" -ForegroundColor Magenta
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
}
- ps: |
Execute-Action "updating build version" {
If ($env:APPVEYOR_REPO_TAG -eq $true) {
$env:RELEASE_VERSION = $env:APPVEYOR_REPO_TAG_NAME
}
else {
$env:RELEASE_VERSION = "0.0.0-ci.sha.$($env:APPVEYOR_REPO_COMMIT.Substring(0, 7)).build.$env:APPVEYOR_BUILD_NUMBER"
}
Write-Host "Build version:" $env:RELEASE_VERSION -ForegroundColor White
Update-AppveyorBuild -Version $env:RELEASE_VERSION
}
- ps: |
Execute-Action "updating path variable" {
$env:PATH = $env:PATH + ";C:/Program Files (x86)/Microsoft SDKs/Windows/v10.0A/bin/NETFX 4.7 Tools"
}
install:
- ps: |
Execute-Action "installing tools" {
choco install codecov mono msbuild-sonarqube-runner opencover.portable
}
dotnet_csproj:
patch: true
file: src\$(APPVEYOR_PROJECT_NAME)\$(APPVEYOR_PROJECT_NAME).csproj
version: $(RELEASE_VERSION)
before_build:
- ps: |
Execute-Action "restoring project dependencies" {
dotnet restore -v m
}
- ps: |
Execute-Action "beginning code analysis" {
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
# For security reasons, AppVeyor only exposes secure variables for pull requests from the same repositoy.
# If $env:SONARQUBE_GITHUB_TOKEN is not set, then it is a pull request from another repository and we'll
# skip SonarQube analysis.
if ($env:SONARQUBE_GITHUB_TOKEN) {
MSBuild.SonarQube.Runner.exe begin /o:$env:SONARQUBE_ORGANIZATION /k:$env:APPVEYOR_PROJECT_NAME /v:$env:APPVEYOR_BUILD_VERSION /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=$env:SONARQUBE_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.xml /d:sonar.coverage.exclusions=**/*Tests.cs,**/*Tests.*.cs,**/*Mock.cs /d:sonar.github.pullRequest=$env:APPVEYOR_PULL_REQUEST_NUMBER /d:sonar.github.repository=$env:APPVEYOR_REPO_NAME /d:sonar.github.oauth=$env:SONARQUBE_GITHUB_TOKEN
$env:SONARQUBE_RUNNING = $true
}
}
else {
MSBuild.SonarQube.Runner.exe begin /o:$env:SONARQUBE_ORGANIZATION /k:$env:APPVEYOR_PROJECT_NAME /v:$env:APPVEYOR_BUILD_VERSION /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=$env:SONARQUBE_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.xml /d:sonar.coverage.exclusions=**/*Tests.cs,**/*Tests.*.cs,**/*Mock.cs
$env:SONARQUBE_RUNNING = $true
}
}
build_script:
- ps: |
Execute-Action "building project" {
msbuild -p:Configuration=$env:CONFIGURATION -v:m /p:SourceLinkCreate=true /p:SourceLinkTest=true
}
after_build:
- ps: |
If ($env:VERIFY_STRONG_NAME -eq $true) {
Execute-Action "verifying strong name" {
foreach ($assembly in ls "src/$env:APPVEYOR_PROJECT_NAME/bin/$env:CONFIGURATION/*/$env:APPVEYOR_PROJECT_NAME.dll") {
sn.exe -vf $assembly
if ($LastExitCode -ne 0) { Break }
}
}
}
- ps: |
Execute-Action "creating NuGet package" {
msbuild -t:pack -p:Configuration=$env:CONFIGURATION -p:NoBuild=true -p:IncludeSymbols=true -p:PackageOutputPath=../../artifacts -v:m ./src/$env:APPVEYOR_PROJECT_NAME
}
test_script:
- ps: |
Execute-Action "running unit tests" {
dotnet test test/$env:APPVEYOR_PROJECT_NAME.Tests -c $env:CONFIGURATION --no-restore --no-build -v m
& "$env:ProgramFiles\Mono\bin\mono.exe” “$env:XUNIT20/xunit.console.exe” “test/$env:APPVEYOR_PROJECT_NAME.Tests/bin/$env:CONFIGURATION/net471/$env:APPVEYOR_PROJECT_NAME.Tests.dll”
}
after_test:
- ps: |
Execute-Action "generating code coverage report" {
msbuild -p:Configuration=$env:CONFIGURATION -v:m -p:codecov=true
OpenCover.Console.exe -target:"$env:XUNIT20/xunit.console.x86.exe" -targetargs:"test/$env:APPVEYOR_PROJECT_NAME.Tests/bin/$env:CONFIGURATION/net471/$env:APPVEYOR_PROJECT_NAME.Tests.dll -noshadow" -register:user -filter:"+[*]* -[$env:APPVEYOR_PROJECT_NAME.Tests]* -[$env:APPVEYOR_PROJECT_NAME.Samples]*" -hideskipped:All -output:"./coverage.xml"
}
- ps: |
Execute-Action "uploading code coverage report" {
codecov.exe -f coverage.xml
}
- ps: |
Execute-Action "ending code analysis" {
if ($env:SONARQUBE_RUNNING -eq $true) {
MSBuild.SonarQube.Runner.exe end /d:sonar.login=$env:SONARQUBE_TOKEN
}
}
artifacts:
- path: artifacts/*.nupkg
name: NuGet
deploy:
- provider: NuGet
server: https://www.myget.org/F/$(MYGET_FEED_NAME)/api/v2
api_key: $(MYGET_API_KEY)
skip_symbols: false
symbol_server: https://www.myget.org/F/$(MYGET_FEED_NAME)/symbols/api/v2/package
on:
appveyor_repo_tag: false
- provider: NuGet
api_key: $(NUGET_API_KEY)
skip_symbols: false
on:
appveyor_repo_tag: true