mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
123 lines
4.6 KiB
YAML
123 lines
4.6 KiB
YAML
pool:
|
|
vmImage: 'windows-2019'
|
|
|
|
variables:
|
|
Prerelease: 'ci'
|
|
buildId: "1$(Build.BuildId)"
|
|
buildProjects: '**/src/**/*.csproj'
|
|
|
|
steps:
|
|
# Print buildId
|
|
- script: |
|
|
echo "BuildId = $(buildId)"
|
|
displayName: 'Print buildId'
|
|
|
|
# Install Tools (SonarScanner)
|
|
- script: |
|
|
dotnet tool install --global dotnet-sonarscanner
|
|
displayName: Install Tools (SonarScanner)
|
|
|
|
- task: PowerShell@2
|
|
displayName: "Use JDK11 by default"
|
|
inputs:
|
|
targetType: 'inline'
|
|
script: |
|
|
$jdkPath = $env:JAVA_HOME_11_X64
|
|
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$jdkPath"
|
|
|
|
# Build tests and run tests for net452
|
|
- script: |
|
|
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net452
|
|
condition: and(succeeded(), eq(variables['RUN_TESTS_NET452'], 'yes'))
|
|
displayName: 'Build tests and run tests for net452'
|
|
|
|
- task: SonarCloudPrepare@1
|
|
displayName: 'Prepare analysis configuration'
|
|
inputs:
|
|
SonarCloud: 'SonarCloud'
|
|
organization: 'wiremock-net'
|
|
scannerMode: 'MSBuild'
|
|
projectKey: 'WireMock-Net_WireMock.Net'
|
|
extraProperties: |
|
|
sonar.cs.opencover.reportsPaths=**\coverage.netcoreapp3.1.opencover.xml
|
|
|
|
# Begin SonarScanner
|
|
- script: |
|
|
%USERPROFILE%\.dotnet\tools\dotnet-sonarscanner begin /k:"WireMock-Net_WireMock.Net" /o:"wiremock-net" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /v:"$(buildId)" /d:sonar.cs.opencover.reportsPaths="**\coverage.netcoreapp3.1.opencover.xml"
|
|
displayName: Begin SonarScanner
|
|
condition: and(succeeded(), eq(variables['RUN_SONAR_CMD'], 'yes'))
|
|
|
|
# Build tests and run tests for netcoreapp3.1 (with coverage)
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Build tests and run tests for netcoreapp3.1 (with coverage)'
|
|
inputs:
|
|
command: 'test'
|
|
projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj'
|
|
arguments: '--configuration Debug --framework netcoreapp3.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
|
|
|
|
- script: |
|
|
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework netcoreapp3.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
|
|
displayName: 'Build tests and run tests for netcoreapp3.1 (with coverage)'
|
|
condition: and(succeeded(), eq(variables['RUN_TESTS_NETCOREAPP31'], 'yes'))
|
|
|
|
- task: SonarCloudAnalyze@1
|
|
displayName: 'Run SonarCloud analysis'
|
|
|
|
- task: SonarCloudPublish@1
|
|
displayName: 'Publish results on build summary'
|
|
|
|
# End SonarScanner
|
|
- script: |
|
|
%USERPROFILE%\.dotnet\tools\dotnet-sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"
|
|
displayName: End SonarScanner
|
|
condition: and(succeeded(), eq(variables['RUN_SONAR_CMD'], 'yes'))
|
|
|
|
- task: whitesource.ws-bolt.bolt.wss.WhiteSource Bolt@19
|
|
displayName: 'WhiteSource Bolt'
|
|
condition: and(succeeded(), eq(variables['RUN_WHITESOURCE'], 'yes'))
|
|
|
|
# Upload coverage to codecov.io
|
|
- script: |
|
|
%USERPROFILE%\.nuget\packages\codecov\1.12.3\tools\codecov.exe -f "./test/WireMock.Net.Tests/coverage.netcoreapp3.1.opencover.xml" -t $(CODECOV_TOKEN)
|
|
displayName: Upload coverage to codecov.io
|
|
|
|
# https://github.com/microsoft/azure-pipelines-tasks/issues/12212
|
|
- task: PublishTestResults@2
|
|
condition: and(succeeded(), eq(variables['PUBLISH_TESTRESULTS'], 'yes'))
|
|
inputs:
|
|
testRunner: VSTest
|
|
testResultsFiles: '**/*.trx'
|
|
|
|
# Based on https://whereslou.com/2018/09/versioning-and-publishing-nuget-packages-automatically-using-azure-devops-pipelines/
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Build Release
|
|
inputs:
|
|
command: 'build'
|
|
arguments: /p:Configuration=Release # https://github.com/MicrosoftDocs/vsts-docs/issues/1976
|
|
projects: $(buildProjects)
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Pack
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
|
inputs:
|
|
command: pack
|
|
configuration: 'Release'
|
|
packagesToPack: $(buildProjects)
|
|
nobuild: true
|
|
packDirectory: '$(Build.ArtifactStagingDirectory)/packages'
|
|
verbosityPack: 'normal'
|
|
|
|
- task: PublishBuildArtifacts@1
|
|
displayName: Publish Artifacts
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
|
inputs:
|
|
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
# https://github.com/NuGet/Home/issues/8148
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Push to MyGet
|
|
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
|
inputs:
|
|
command: custom
|
|
custom: nuget
|
|
arguments: push $(Build.ArtifactStagingDirectory)\packages\*.nupkg -n true -s https://www.myget.org/F/wiremock-net/api/v3/index.json -k $(MyGetKey) |