Skip to content

Commit

Permalink
[#201] #EXTEND 'assemblyName: DotNet.Testcontainers; function SonarCl…
Browse files Browse the repository at this point in the history
…oud'

{Add Windows test results to SonarCloud.}
  • Loading branch information
HofmeisterAn committed Jan 30, 2020
1 parent aff55c4 commit a1e7770
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 55 deletions.
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ pr:

jobs:
# Run Windows build and tests.
- template: template/build.yml
- template: azure/build.yml
parameters:
name: BuildAndTestsOnWindows
displayName: Windows
vmImage: windows-2019
dotNetCoreVersion3: $(dotNetCoreVersion3)
cakeVersion: $(cakeVersion)
testFilter: FullyQualifiedName~DotNet.Testcontainers.Tests.Unit.Windows
testFilter: FullyQualifiedName~DotNet.Testcontainers.Tests.Unit.Containers.Windows

# Run Linux build and tests.
- template: template/build.yml
# Run Unix build and tests.
- template: azure/build.yml
parameters:
name: BuildAndTestsOnUnix
displayName: Linux
displayName: Unix
vmImage: ubuntu-18.04
dotNetCoreVersion3: $(dotNetCoreVersion3)
cakeVersion: $(cakeVersion)
Expand All @@ -41,7 +41,7 @@ jobs:
# Run static code analysis and publish artifact.
# Until now, we do not cover Windows only tests.
- ${{ if in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/develop') }}:
- template: template/publish.yml
- template: azure/publish.yml
parameters:
name: Release
displayName: Release
Expand Down
17 changes: 13 additions & 4 deletions template/build.yml → azure/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
inputs:
version: ${{ parameters.dotNetCoreVersion3 }}

- powershell: docker ps -a -q | % { docker rm $_ --force }
displayName: Remove All Orphaned Containers

- powershell: dotnet tool install --tool-path ./tools --version ${{ parameters.cakeVersion }} Cake.Tool
displayName: Setup prerequisites

Expand All @@ -27,8 +24,20 @@ jobs:
- powershell: ./tools/dotnet-cake --target=Build
displayName: Build

- powershell: ./tools/dotnet-cake --target=Tests --test-filter="${{ parameters.testFilter }}"
- powershell: ./tools/dotnet-cake --target=Tests --test-filter='${{ parameters.testFilter }}'
displayName: Tests

- powershell: Get-ChildItem -Path . -Include *.log -Recurse | % { Get-Content -Path $_.FullName }
displayName: Logs

- powershell: Get-ChildItem -Path 'test-coverage' -Filter *.xml | Rename-Item -NewName { $_.Name -Replace 'coverage.netcoreapp3.1', '${{ parameters.displayName }}'.ToLower() }
displayName: Rename Test And Coverage Results

- powershell: "@('test-results', 'test-coverage') | % { Copy-Item -Path $_ -Destination '$(Build.ArtifactStagingDirectory)' -Recurse }"
displayName: Copy Test And Coverage Results To Staging Directory

- task: PublishPipelineArtifact@1
displayName: Publish Test And Coverage Results
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifactName: ${{ parameters.displayName }}.TestAndCoverageResults
64 changes: 64 additions & 0 deletions azure/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
jobs:
- job: ${{ parameters.name }}
displayName: CI build for ${{ parameters.displayName }}

pool:
vmImage: ${{ parameters.vmImage }}

dependsOn:
- BuildAndTestsOnWindows
- BuildAndTestsOnUnix

steps:
- checkout: self
clean: true
lfs: true

- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: Unix.TestAndCoverageResults
path: $(Build.SourcesDirectory)

- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: Windows.TestAndCoverageResults
path: $(Build.SourcesDirectory)

- task: UseDotNet@2
displayName: Use .NET Core SDK ${{ parameters.dotNetCoreVersion3 }}
inputs:
version: ${{ parameters.dotNetCoreVersion3 }}

- task: UseDotNet@2
displayName: Use .NET Core SDK ${{ parameters.dotNetCoreVersion2 }}
inputs:
version: ${{ parameters.dotNetCoreVersion2 }}

- powershell: Get-ChildItem -Path 'test-coverage' -Filter *.xml | % { (Get-Content $_) -Replace '[A-Za-z0-9:\\\/]+src', '$(Build.SourcesDirectory)/src' | Set-Content $_ }
displayName: Fix Absolute Code Coverage Paths

- powershell: dotnet tool install --tool-path ./tools --version ${{ parameters.cakeVersion }} Cake.Tool
displayName: Setup prerequisites

- powershell: ./tools/dotnet-cake --target=Restore-NuGet-Packages
displayName: Prepare

- powershell: |
$env:SONARCLOUD_TOKEN = "$(sonarcloud.token)"
./tools/dotnet-cake --target=Sonar-Begin
displayName: Sonar Begin
- powershell: ./tools/dotnet-cake --target=Build
displayName: Build

- powershell: |
$env:SONARCLOUD_TOKEN = "$(sonarcloud.token)"
./tools/dotnet-cake --target=Sonar-End
displayName: Sonar End
- powershell: |
$env:FEED_APIKEY = "$(feed.apikey)"
./tools/dotnet-cake --target=Publish
displayName: Publish
3 changes: 1 addition & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ Task("Publish-NuGet-Packages")
{
foreach(var package in GetFiles($"{param.Paths.Directories.NugetRoot}/*.(nupkg|snupkgs)"))
{
NuGetPush(package, new NuGetPushSettings
DotNetCoreNuGetPush(package.FullPath, new DotNetCoreNuGetPushSettings
{
ToolPath = "./tools/nuget.exe",
Source = param.NuGetCredentials.Source,
ApiKey = param.NuGetCredentials.ApiKey
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DotNet.Testcontainers.Tests.Unit.Containers.Linux.MessageBroker
namespace DotNet.Testcontainers.Tests.Unit.Containers.Unix.MessageBroker
{
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DotNet.Testcontainers.Tests.Unit.Containers.Linux
namespace DotNet.Testcontainers.Tests.Unit.Containers.Unix
{
using System;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace DotNet.Testcontainers.Tests.Unit.Containers.Windows
using DotNet.Testcontainers.Containers;
using DotNet.Testcontainers.Containers.Builders;
using DotNet.Testcontainers.Containers.Modules;
using DotNet.Testcontainers.Containers.WaitStrategies;
using Xunit;

public static class TestcontainersContainerTest
Expand All @@ -18,11 +19,12 @@ public async Task IsWindowsEngineEnabled()
}

[IgnoreOnLinuxEngine]
public async Task Disposable()
public async Task SafeDisposable()
{
// Given
var testcontainersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
.WithImage("mcr.microsoft.com/windows/nanoserver:1809");
.WithImage("mcr.microsoft.com/windows/nanoserver:1809")
.WithWaitStrategy(Wait.ForWindowsContainer());

// When
// Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal sealed class DoNotConsumeStdoutOrStderr : IOutputConsumer

public void Dispose()
{
this.Stdout.Dispose();
this.Stderr.Dispose();
}
}
}
4 changes: 3 additions & 1 deletion src/Shared.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Company>Andre Hofmeister</Company>
<Description>A lightweight library to run tests with throwaway instances of Docker containers.</Description>
<Summary>.NET Testcontainers makes it easy to run tests with Docker containers. Create reliable and fast environments within seconds and throw them away if not needed anymore.</Summary>
<PackageIcon>DotNet.Testcontainers.png</PackageIcon>
<PackageIconUrl>https://github.com/HofmeisterAn/dotnet-testcontainers/raw/develop/docs/DotNet.Testcontainers.png</PackageIconUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/HofmeisterAn/dotnet-testcontainers</PackageProjectUrl>
Expand All @@ -32,6 +33,7 @@
<!-- Global solution information -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)SolutionInfo.cs" />
<None Include="../../LICENSE" Pack="true" PackagePath=""/>
<None Include="$(MSBuildThisFileDirectory)../LICENSE" Pack="true" PackagePath="" />
<None Include="$(MSBuildThisFileDirectory)../docs/DotNet.Testcontainers.png" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
38 changes: 0 additions & 38 deletions template/publish.yml

This file was deleted.

0 comments on commit a1e7770

Please sign in to comment.