Skip to content

Commit aa5a368

Browse files
committed
Testing the linux native binaries in docker containers
1 parent 8c29400 commit aa5a368

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

build/artifacts-test.cake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ Task("Artifacts-DotnetTool-Test")
2929
}
3030
});
3131

32+
Task("Artifacts-Native-Test")
33+
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnLinux, "Artifacts-Native-Test can be tested only on Linux agents.")
34+
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsReleasingCI, "Artifacts-Native-Test works only on Releasing CI.")
35+
.IsDependentOn("Zip-Files")
36+
.IsDependentOn("Artifacts-Prepare")
37+
.Does<BuildParameters>((parameters) =>
38+
{
39+
var rootPrefix = parameters.DockerRootPrefix;
40+
var version = parameters.Version.NugetVersion;
41+
42+
foreach(var dockerImage in parameters.Docker.Images)
43+
{
44+
var (os, distro, targetframework) = dockerImage;
45+
46+
var cmd = $"-file {rootPrefix}/scripts/Test-Native.ps1 -repoPath {rootPrefix}/repo -runtime {distro}";
47+
48+
DockerTestArtifact(dockerImage, parameters, cmd);
49+
}
50+
});
51+
3252
Task("Artifacts-MsBuildCore-Test")
3353
.WithCriteria<BuildParameters>((context, parameters) => !parameters.IsRunningOnMacOS, "Artifacts-MsBuildCore-Test can be tested only on Windows or Linux agents.")
3454
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsReleasingCI, "Artifacts-MsBuildCore-Test works only on Releasing CI.")
@@ -100,5 +120,6 @@ Task("Artifacts-MsBuildFull-Test")
100120
Task("Artifacts-Test")
101121
.WithCriteria<BuildParameters>((context, parameters) => !parameters.IsRunningOnMacOS, "Artifacts-Test can be tested only on Windows or Linux agents.")
102122
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsReleasingCI, "Artifacts-Test works only on Releasing CI.")
123+
.IsDependentOn("Artifacts-Native-Test")
103124
.IsDependentOn("Artifacts-DotnetTool-Test")
104125
.IsDependentOn("Artifacts-MsBuildCore-Test");

build/pack.cake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ void PackPrepareNative(ICakeContext context, BuildParameters parameters)
154154

155155
context.Information("Validating native lib:");
156156

157-
var nativeExe = outputPath.CombineWithFilePath(IsRunningOnWindows() ? "gitversion.exe" : "gitversion");
158-
ValidateOutput(nativeExe.FullPath, "/showvariable FullSemver", parameters.Version.GitVersion.FullSemVer);
157+
// testing windows and macos artifacts, ther linux is tested with docker
158+
if (platform != PlatformFamily.Linux)
159+
{
160+
var nativeExe = outputPath.CombineWithFilePath(IsRunningOnWindows() ? "gitversion.exe" : "gitversion");
161+
ValidateOutput(nativeExe.FullPath, "/showvariable FullSemver", parameters.Version.GitVersion.FullSemVer);
162+
}
159163
}
160-
161164
}

build/utils/docker.cake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ void DockerPullImage(DockerImage dockerImage, BuildParameters parameters)
109109
DockerContainerRunSettings GetDockerRunSettings(BuildParameters parameters)
110110
{
111111
var currentDir = MakeAbsolute(Directory("."));
112+
var root = parameters.DockerRootPrefix;
112113
var settings = new DockerContainerRunSettings
113114
{
114115
Rm = true,
115116
Volume = new[]
116117
{
117-
$"{currentDir}:{parameters.DockerRootPrefix}/repo",
118-
$"{currentDir}/artifacts/v{parameters.Version.SemVersion}/nuget:{parameters.DockerRootPrefix}/nuget",
119-
$"{currentDir}/test-scripts:{parameters.DockerRootPrefix}/scripts"
118+
$"{currentDir}:{root}/repo",
119+
$"{currentDir}/test-scripts:{root}/scripts",
120+
$"{currentDir}/artifacts/v{parameters.Version.SemVersion}/nuget:{root}/nuget",
121+
$"{currentDir}/artifacts/v{parameters.Version.SemVersion}/native/linux:{root}/native",
120122
}
121123
};
122124

build/utils/parameters.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public class BuildParameters
141141
NativeRuntimes = new Dictionary<PlatformFamily, string[]>
142142
{
143143
[PlatformFamily.Windows] = new[] { "win-x64", "win-x86" },
144-
[PlatformFamily.Linux] = new[] { "linux-x64" },
144+
[PlatformFamily.Linux] = new[] { "debian.9-x64", "centos.7-x64", "fedora.30-x64", "ubuntu.16.04-x64", "ubuntu.18.04-x64" },
145145
[PlatformFamily.OSX] = new[] { "osx-x64" },
146146
};
147147

test-scripts/Test-DotnetGlobalTool.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ param(
44
[parameter(Mandatory=$true, Position=2)][string] $repoPath
55
)
66

7-
$result = dotnet tool install GitVersion.Tool --version $version --tool-path $rootPrefix/tools --add-source $nugetPath | out-null;
7+
$result = dotnet tool install GitVersion.Tool --version $version --tool-path /tools --add-source $nugetPath | out-null;
88

99
if($LASTEXITCODE -eq 0) {
10-
& "$rootPrefix/tools/dotnet-gitversion" $repoPath /showvariable FullSemver;
10+
& "/tools/dotnet-gitversion" $repoPath /showvariable FullSemver;
1111
} else {
1212
Write-Output $result
1313
}

test-scripts/Test-Native.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
param(
2+
[parameter(Mandatory=$true, Position=0)][string] $runtime,
3+
[parameter(Mandatory=$true, Position=1)][string] $repoPath
4+
)
5+
6+
& "/native/$runtime/gitversion" $repoPath /showvariable FullSemver;

0 commit comments

Comments
 (0)