Skip to content

Commit 620e3df

Browse files
authored
Merge pull request #3072 from sharwell/azure-pipelines
Initial Azure Pipelines build configuration
2 parents 59adc83 + 863e40d commit 620e3df

7 files changed

Lines changed: 92 additions & 23 deletions

File tree

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
root = true
22

3+
[*.yml]
4+
indent_style = space
5+
indent_size = 2
6+
37
[*.cs]
48
charset = utf-8-bom
59
insert_final_newline = true

.nuget/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Codecov" version="1.8.0" />
3+
<package id="Codecov" version="1.9.0" />
44
<package id="OpenCover" version="4.6.519" />
55
<package id="ReportGenerator" version="2.3.5.0" targetFramework="net452" />
66
<package id="xunit.runner.console" version="2.4.1" />

NuGet.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
46
<add key="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
57
<add key="roslyn-analyzers" value="https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json" />
68

StyleCop.Analyzers/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"cloudBuild": {
1515
"buildNumber": {
16-
"enabled": true
16+
"enabled": false
1717
}
1818
}
1919
}

appveyor.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ build:
1212
project: StyleCopAnalyzers.sln
1313
verbosity: minimal
1414
test_script:
15-
- cd build
16-
- ps: |
17-
if ($env:Configuration -eq 'Debug') {
18-
.\opencover-report.ps1 -Debug -NoBuild -NoReport -AppVeyor
19-
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
20-
$packageConfig = [xml](Get-Content ..\.nuget\packages.config)
21-
$codecov_version = $packageConfig.SelectSingleNode('/packages/package[@id="Codecov"]').version
22-
$codecov = "..\packages\Codecov.$codecov_version\tools\codecov.exe"
23-
&$codecov -f '..\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml'
24-
} else {
25-
.\opencover-report.ps1 -NoBuild -NoReport -AppVeyor
26-
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
27-
}
28-
- cd ..
2915
- .\StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\bin\%Configuration%\net46\StyleCop.Analyzers.Status.Generator.exe .\StyleCopAnalyzers.sln > StyleCop.Analyzers.Status.json
3016
cache:
3117
- packages -> **\packages.config

azure-pipelines.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
pool:
2+
name: Azure Pipelines
3+
vmImage: windows-latest
4+
demands:
5+
- msbuild
6+
- visualstudio
7+
- vstest
8+
9+
jobs:
10+
- job: Build
11+
variables:
12+
BuildSolution: StyleCopAnalyzers.sln
13+
BuildPlatform: Any CPU
14+
strategy:
15+
matrix:
16+
Debug:
17+
BuildConfiguration: Debug
18+
_debugArg: '-Debug'
19+
Release:
20+
BuildConfiguration: Release
21+
_debugArg: ''
22+
steps:
23+
- task: NuGetToolInstaller@0
24+
displayName: 'Use NuGet 5.3.1'
25+
inputs:
26+
versionSpec: 5.3.1
27+
28+
- task: NuGetCommand@2
29+
displayName: 'NuGet restore'
30+
inputs:
31+
restoreSolution: '$(BuildSolution)'
32+
feedsToUse: 'config'
33+
nugetConfigPath: 'NuGet.config'
34+
35+
- task: VSBuild@1
36+
displayName: 'Build solution StyleCopAnalyzers.sln'
37+
inputs:
38+
solution: '$(BuildSolution)'
39+
platform: '$(BuildPlatform)'
40+
configuration: '$(BuildConfiguration)'
41+
msbuildArgs: '/bl:$(Build.SourcesDirectory)/msbuild.binlog'
42+
43+
- task: PowerShell@2
44+
displayName: Run Tests
45+
inputs:
46+
workingDirectory: '$(Build.SourcesDirectory)/build'
47+
filePath: build/opencover-report.ps1
48+
arguments: '$(_debugArg) -NoBuild -NoReport -Azure'
49+
50+
- task: PublishTestResults@2
51+
displayName: Publish test results
52+
inputs:
53+
testResultsFormat: xUnit
54+
testResultsFiles: 'build/*.xml'
55+
mergeTestResults: true
56+
testRunTitle: '$(BuildConfiguration)'
57+
58+
- task: PowerShell@2
59+
displayName: Upload coverage reports to codecov.io
60+
condition: eq(variables['BuildConfiguration'], 'Debug')
61+
inputs:
62+
workingDirectory: '$(Build.SourcesDirectory)/build'
63+
targetType: inline
64+
script: |
65+
$packageConfig = [xml](Get-Content ..\.nuget\packages.config)
66+
$codecov_version = $packageConfig.SelectSingleNode('/packages/package[@id="Codecov"]').version
67+
$codecov = "..\packages\Codecov.$codecov_version\tools\codecov.exe"
68+
&$codecov -f '..\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml' --required
69+
70+
- task: PublishBuildArtifacts@1
71+
displayName: Publish build logs
72+
inputs:
73+
pathtoPublish: msbuild.binlog
74+
condition: failed()

build/opencover-report.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ param (
22
[switch]$Debug,
33
[switch]$NoBuild,
44
[switch]$NoReport,
5-
[switch]$AppVeyor
5+
[switch]$AppVeyor,
6+
[switch]$Azure
67
)
78

89
If (-not $NoBuild) {
@@ -51,6 +52,8 @@ $register_mode = 'user'
5152
If ($AppVeyor) {
5253
$AppVeyorArg = '-appveyor'
5354
$register_mode = 'Path32'
55+
} ElseIf ($Azure) {
56+
$register_mode = 'Path32'
5457
}
5558

5659
&$opencover_console `
@@ -63,9 +66,9 @@ If ($AppVeyor) {
6366
-excludebyfile:*\*Designer.cs `
6467
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
6568
-target:"$xunit_runner_console_net452" `
66-
-targetargs:"$target_dll -noshadow $AppVeyorArg"
69+
-targetargs:"$target_dll -noshadow $AppVeyorArg -xml StyleCopAnalyzers.xunit.xml"
6770

68-
If ($AppVeyor -and -not $?) {
71+
If (($AppVeyor -or $Azure) -and -not $?) {
6972
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
7073
Exit $LASTEXITCODE
7174
}
@@ -81,9 +84,9 @@ If ($AppVeyor -and -not $?) {
8184
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
8285
-mergebyhash -mergeoutput `
8386
-target:"$xunit_runner_console_net46" `
84-
-targetargs:"$target_dll_csharp7 -noshadow $AppVeyorArg"
87+
-targetargs:"$target_dll_csharp7 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp7.xunit.xml"
8588

86-
If ($AppVeyor -and -not $?) {
89+
If (($AppVeyor -or $Azure) -and -not $?) {
8790
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
8891
Exit $LASTEXITCODE
8992
}
@@ -99,9 +102,9 @@ If ($AppVeyor -and -not $?) {
99102
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
100103
-mergebyhash -mergeoutput `
101104
-target:"$xunit_runner_console_net472" `
102-
-targetargs:"$target_dll_csharp8 -noshadow $AppVeyorArg"
105+
-targetargs:"$target_dll_csharp8 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp8.xunit.xml"
103106

104-
If ($AppVeyor -and -not $?) {
107+
If (($AppVeyor -or $Azure) -and -not $?) {
105108
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
106109
Exit $LASTEXITCODE
107110
}

0 commit comments

Comments
 (0)