generated from GuilhermeStracini/apiclient-boilerplate-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 7
/
appveyor.yml
110 lines (93 loc) · 4.67 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
version: 1.1.{build}
skip_tags: true
image: Visual Studio 2022
configuration: Release
environment:
CODACY_PROJECT_TOKEN:
secure: bqp3Vwf5Ft5sm/p8WP1AwuSu8msKg1sRYqH28kx2mK39mEN9L15BWl2wKHAUlNKd
CODECLIMATE_TOKEN:
secure: w2RdqAp3D471W/s2qVXBww3qWIBrzVQPgAaWJHqrnE4FtRB5GGPLGhzr+Pxb3UHIjZnIIndbSZwOTKJQJe8FVVcfrYfLW7HErhqwvZW+Wcg=
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
init:
- SET JAVA_HOME=C:\Program Files\Java\jdk19
- SET PATH=%JAVA_HOME%\bin;%PATH%
before_build:
- ps: $env:SOLUTION_NAME = $([io.path]::GetFileNameWithoutExtension($(Get-ChildItem -Path .\* -Include *.sln)))
- ps: $env:SONAR_PROJECT = "$env:APPVEYOR_REPO_NAME" -replace "/","_"
- ps: $env:SONAR_ORGANIZATION = "$env:APPVEYOR_REPO_NAME" -replace "/.*$",""
- cmd: nuget restore
- cmd: choco install opencover.portable
- cmd: choco install codecov
- cmd: curl -L https://github.com/codacy/codacy-coverage-reporter/releases/latest/download/codacy-coverage-reporter-assembly.jar > ./codacy-test-reporter.jar
- cmd: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-windows-amd64 > codeclimate-test-reporter.exe
- cmd: dotnet tool install --global dotnet-sonarscanner
build:
publish_nuget: true
include_nuget_references: true
parallel: true
verbosity: normal
build_script:
- ps: $Params = "/k:`"$env:SONAR_PROJECT`"", "/o:`"$env:SONAR_ORGANIZATION`"", "/v:`"$env:APPVEYOR_BUILD_NUMBER`""
- ps: $Params += "/d:sonar.host.url=`"https://sonarcloud.io`"", "/d:sonar.token=`"$env:SONAR_TOKEN`""
- ps: $Params += "/d:sonar.exclusions=`"**/bin/**/*,**/obj/**/*`"", "/d:sonar.coverage.exclusions=`"**/$env:SOLUTION_NAME.Tests/**,**/*Tests.cs`""
- ps: $Params += "/d:sonar.cs.opencover.reportsPaths=`"$env:CD\Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml`""
- ps: if(-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $Params += "/d:sonar.branch.name=`"$env:APPVEYOR_REPO_BRANCH`"" }
- ps: if($env:APPVEYOR_PULL_REQUEST_NUMBER) { $Params += "/d:sonar.pullrequest.key=$env:APPVEYOR_PULL_REQUEST_NUMBER", "/d:sonar.pullrequest.branch=`"$env:APPVEYOR_REPO_BRANCH`"" }
- ps: Start-process "dotnet" "sonarscanner begin $($Params -join ' ')"
- codeclimate-test-reporter before-build
- dotnet build %SOLUTION_NAME%.sln
- ps: $testProjects = (Get-ChildItem -Path .\Tests\**\ -Recurse -Include *.csproj).Fullname
- ps: $coverletFormats = @('cobertura', 'lcov', 'opencover')
- ps: |
foreach($testProject in $testProjects)
{
foreach($coverletFormat in $coverletFormats)
{
dotnet test $testProject /p:CollectCoverage=true /p:CoverletOutputFormat="$coverletFormat"
}
}
- codeclimate-test-reporter format-coverage -t lcov -o "%CD%\Tests\%SOLUTION_NAME%.Tests\code-climate.json" "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.info"
- codeclimate-test-reporter upload-coverage -i "%CD%\Tests\%SOLUTION_NAME%.Tests\code-climate.json" -r %CODECLIMATE_TOKEN%
- codecov -f "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- java -jar ./codacy-test-reporter.jar report -l CSharp -t %CODACY_PROJECT_TOKEN% -r "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- dotnet sonarscanner end /d:sonar.token="%SONAR_TOKEN%"
after_build:
- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.0\*.* %CD%\Build\.netstandard2.0\
- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.1\*.* %CD%\Build\.netstandard2.1\
- copy %CD%\Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg
- rd /s /q %CD%\Src\%SOLUTION_NAME%\bin\Release\
- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.xml %CD%\Coverage\
- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.json %CD%\Coverage\
- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.info %CD%\Coverage\
- cd %CD%
- 7z a -tzip -mx9 "%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.zip" Build
- 7z a -tzip -mx9 "%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.Coverage.zip" Coverage
artifacts:
- path: $(SOLUTION_NAME).%APPVEYOR_BUILD_VERSION%.zip
name: ZipFile
- path: $(SOLUTION_NAME).%APPVEYOR_BUILD_VERSION%.nupkg
name: Package
- path: $(SOLUTION_NAME).%APPVEYOR_BUILD_VERSION%.Coverage.zip
name: Coverage
deploy:
- provider: NuGet
api_key: $(NUGET_TOKEN)
skip_symbols: false
on:
branch: main
artifact: Package
- provider: GitHub
on:
branch: main
tag: v$(appveyor_build_version)
description: 'Release of $(SOLUTION_NAME) - v$(appveyor_build_version)'
auth_token: $(GITHUB_TOKEN)
force_update: true
artifact: ZipFile, Package, Coverage