guibranco/MaxiPago-SDK-dotnet

View on GitHub
appveyor.yml

Summary

Maintainability
Test Coverage
version: 3.0.{build}
skip_tags: true
image: Visual Studio 2022
configuration: Release

environment:
  CODACY_PROJECT_TOKEN:
    secure: 0NU4VMcsngkeQSMuGjjNUb8sC87SYbxbxoz8HC2eRw4iuWHHtdg6x3Ji+bv4pHM+
  CODECLIMATE_TOKEN:
    secure: n/VjTBZ72BBbORNn5afNhu6iU7/Zu41zAb06DAh/kD70C/AyHlMjjQPlLpspuPvBm1Hi5WSOMTievSMhErlKcBoR/ZZ6Z91R47L0kVa9BTc=

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 "/.*$",""
- ps: $env:LOCAL_PR = 0
- ps: if(-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $env:LOCAL_PR = 1 }
- ps: if($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -Eq $env:APPVEYOR_REPO_NAME) { $env:LOCAL_PR = 1 }
- 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`""
- ps: if($env:LOCAL_PR -Eq 1) { $Params +=  "/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: $TEST_PROJECTS = (Get-ChildItem -Path .\Tests\**\ -Recurse -Include *.csproj).Fullname
- ps: |
    foreach($testProject in $TEST_PROJECTS)
    {
        dotnet test $testProject /p:CollectCoverage=true "/p:CoverletOutputFormat=\`"cobertura,opencover,lcov\`""
    }
- if %LOCAL_PR% EQU 1 codecov -f "Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- if %LOCAL_PR% EQU 1 codeclimate-test-reporter format-coverage -t lcov -o "Tests\%SOLUTION_NAME%.Tests\code-climate.json" "Tests\%SOLUTION_NAME%.Tests\coverage.info"
- if %LOCAL_PR% EQU 1 codeclimate-test-reporter upload-coverage -i "Tests\%SOLUTION_NAME%.Tests\code-climate.json" -r %CODECLIMATE_TOKEN%
- if %LOCAL_PR% EQU 1 java -jar ./codacy-test-reporter.jar report -l CSharp -t %CODACY_PROJECT_TOKEN% -r "Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- if %LOCAL_PR% EQU 1 dotnet sonarscanner end /d:sonar.token="%SONAR_TOKEN%"

after_build:
- xcopy Src\%SOLUTION_NAME%\bin\Release\netstandard2.0\*.* Build\2.0\
- xcopy Src\%SOLUTION_NAME%\bin\Release\netstandard2.1\*.* Build\2.1\

- copy Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg

- rd /s /q Src\%SOLUTION_NAME%\bin\Release\

- xcopy Tests\%SOLUTION_NAME%.Tests\*.xml Coverage\
- xcopy Tests\%SOLUTION_NAME%.Tests\*.json Coverage\
- xcopy Tests\%SOLUTION_NAME%.Tests\*.info 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