Skip to content

Commit

Permalink
Add Linux & macOS leg to CI, add code coverage (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
qmfrederik authored and brendandburns committed Mar 25, 2019
1 parent a58f908 commit 7b8a36c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 29 deletions.
80 changes: 53 additions & 27 deletions .azure-pipelines.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jobs:

- job: build_xamarin
- job: xamarin_build
pool:
vmImage: 'VS2017-Win2016'
steps:
Expand All @@ -21,11 +21,10 @@ jobs:
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/nupkg/'

- job: Build
- job: windows_build
pool:
vmImage: 'VS2017-Win2016'


steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
Expand All @@ -37,22 +36,6 @@ jobs:
inputs:
projects: '**/*.sln'

# - task: MSBuild@1
# displayName: 'Build solution **/*.sln'
# inputs:
# msbuildArchitecture: x64

# configuration: Release

# - task: VSTest@2
# displayName: 'VsTest - testAssemblies'
# inputs:
# testAssemblyVer2: |
# tests\**\*Tests*.dll
# !**\obj\**

# codeCoverageEnabled: true

- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
Expand All @@ -64,15 +47,13 @@ jobs:
displayName: 'publish coverage results'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.cobertura.xml'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.cobertura.xml'

- task: alanwales.resharper-code-analysis.custom-build-task.ResharperCli@1
displayName: 'Automated code quality checks'
inputs:
SolutionOrProjectPath: 'kubernetes-client.sln'

FailBuildOnCodeIssues: false

continueOnError: true

- task: DotNetCoreCLI@2
Expand All @@ -81,15 +62,60 @@ jobs:
command: pack
packagesToPack: src/KubernetesClient/KubernetesClient.csproj
packDirectory: '$(Build.ArtifactStagingDirectory)/nupkg'
majorVersion: 1
minorVersion: 4
versioningScheme: byPrereleaseNumber


- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/nupkg'
PathtoPublish: '$(Build.ArtifactStagingDirectory)/nupkg'

- job: macos_build
pool:
vmImage: 'xcode9-macos10.13'
steps:
- script: |
brew install coreutils
which realpath
./ci.sh
displayName: 'Build & Test'
- task: PublishTestResults@1
displayName: 'Publish Test Results'
inputs:
testRunner: VSTest
testResultsFiles: '$(Build.SourcesDirectory)/tests/**/*.xunit.trx'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@1
displayName: 'publish coverage results'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/tests/coveragereport/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/tests/coveragereport/'
condition: succeededOrFailed()

- job: ubuntu_build
pool:
vmImage: 'ubuntu-16.04'
steps:
- script: |
./install-linux.sh
displayName: 'Install .NET & set up minikube'
- script: |
./ci.sh
displayName: 'Build & Test'
- task: PublishTestResults@1
displayName: 'Publish Test Results'
inputs:
testRunner: VSTest
testResultsFiles: '$(Build.SourcesDirectory)/tests/**/*.xunit.trx'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@1
displayName: 'publish coverage results'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/tests/coveragereport/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/tests/coveragereport/'
condition: succeededOrFailed()
24 changes: 22 additions & 2 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ cd ../..
# Execute Unit tests
cd tests/KubernetesClient.Tests
dotnet restore
dotnet test
# Save the test results to a file
# Collect code coverage of the KuberetsClient assembly, but exclude the
# auto-generated models from the coverage reports.
dotnet test \
-l "trx;LogFileName=KubernetesClient.Tests.xunit.trx" \
/p:CollectCoverage=true \
/p:Include="[KubernetesClient]*" \
/p:Exclude="[KubernetesClient]k8s.Models.*" \
/p:Exclude="[KubernetesClient]k8s.Internal.*" \
/p:CoverletOutputFormat="opencover" \
/p:CoverletOutput="KubernetesClient.Tests.opencover.xml"

cd ../..
cd ..
echo Generating Code Coverage reports
export PATH="$PATH:$HOME/.dotnet/tools"
export DOTNET_ROOT=$(dirname $(realpath $(which dotnet))) # https://github.com/dotnet/cli/issues/9114#issuecomment-401670622
dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.0.15
reportgenerator "-reports:**/*.opencover.xml" "-targetdir:coveragereport" "-reporttypes:HTMLInline;Cobertura"

ls coveragereport
ls coveragereport/Cobertura.xml

cd ..
3 changes: 3 additions & 0 deletions install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ echo 'Creating the minikube cluster'
sudo minikube start --vm-driver=none --kubernetes-version=v1.13.4 --extra-config=apiserver.authorization-mode=RBAC
sudo chown -R $USER $HOME/.minikube
sudo chgrp -R $USER $HOME/.minikube
sudo chown -R $USER $HOME/.kube
sudo chgrp -R $USER $HOME/.kube

minikube update-context

echo 'Waiting for the cluster nodes to be ready'
Expand Down

0 comments on commit 7b8a36c

Please sign in to comment.