Skip to content

Commit

Permalink
Merge pull request #53 from guibranco/52-add-codeclimate-coverage-report
Browse files Browse the repository at this point in the history
Update appveyor.yml
  • Loading branch information
guibranco committed Apr 9, 2023
2 parents 2bc24b9 + 554081a commit a7a95a0
Showing 1 changed file with 34 additions and 41 deletions.
75 changes: 34 additions & 41 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ environment:
secure: AD1z81FqZlvGkCEyDzJ3g6sIJ93ecUE9EuqfUxc4CMiFGW139pWZk+/huuTY5jzG
CODACY_PROJECT_TOKEN:
secure: Dz2jqsK+hAKCFEGgumfJORPt5Ka6/X7UMR5RyG10etlqiGkUH7TSrGtdFlnjaZm1
CODECLIMATE_TOKEN:
secure: dStWUK1y0OKwT48aK3F/dJzuiDAOXVct+Olg4il66JcOEe3i1zEqQdBeMip/xSSlDzswxEVBs9GzhM10dfilbRB9TZ54AZ7rnC+cuvdQ3CU=

dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'

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%
Expand All @@ -32,6 +34,7 @@ before_build:
- 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:
Expand All @@ -41,41 +44,22 @@ build:
verbosity: normal

build_script:
- ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { &
dotnet sonarscanner begin
/k:"$env:SONAR_PROJECT"
/o:"$env:SONAR_ORGANIZATION"
/d:sonar.branch.name="$env:APPVEYOR_REPO_BRANCH"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.login="$env:SONAR_TOKEN"
/v:"$env:APPVEYOR_BUILD_NUMBER"
/d:sonar.exclusions="**/bin/**/*,**/obj/**/*"
/d:sonar.coverage.exclusions="**/$env:SOLUTION_NAME.Tests/**,**/*Tests.cs"
/d:sonar.cs.opencover.reportsPaths="$env:CD\Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml"
}'
- ps: 'if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { &
dotnet sonarscanner begin
/k:"$env:SONAR_PROJECT"
/o:"$env:SONAR_ORGANIZATION"
/d:sonar.pullrequest.key="$env:APPVEYOR_PULL_REQUEST_NUMBER"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.login="$env:SONAR_TOKEN"
/v:"$env:APPVEYOR_BUILD_NUMBER"
/d:sonar.exclusions="**/bin/**/*,**/obj/**/*"
/d:sonar.coverage.exclusions="**/$env:SOLUTION_NAME.Tests/**,**/*Tests.cs"
/d:sonar.cs.opencover.reportsPaths="$env:CD\Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml"
}'
- 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.login=`"$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" }
- ps: Start-process "dotnet" "sonarscanner begin $($Params -join ' ')"
- codeclimate-test-reporter before-build
- dotnet build %SOLUTION_NAME%.sln
- dotnet test .\Tests\%SOLUTION_NAME%.Tests\%SOLUTION_NAME%.Tests.csproj
/p:CollectCoverage=true
/p:CoverletOutputFormat="opencover"
- dotnet test .\Tests\%SOLUTION_NAME%.Tests\%SOLUTION_NAME%.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="cobertura"
- dotnet test .\Tests\%SOLUTION_NAME%.Tests\%SOLUTION_NAME%.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="lcov"
- dotnet test .\Tests\%SOLUTION_NAME%.Tests\%SOLUTION_NAME%.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="opencover"
- 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"
- 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.login="%SONAR_TOKEN%"

after_build:
Expand All @@ -87,6 +71,7 @@ after_build:

- 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%

Expand Down Expand Up @@ -117,3 +102,11 @@ deploy:
auth_token: $(GITHUB_TOKEN)
force_update: true
artifact: ZipFile

- provider: GitHub
on:
branch: main
tag: $(appveyor_build_version)
auth_token: $(GITHUB_TOKEN)
force_update: true
artifact: Coverage

0 comments on commit a7a95a0

Please sign in to comment.