forked from dotnet/dotnet-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-and-test.ps1
70 lines (57 loc) · 2.18 KB
/
build-and-test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env pwsh
param(
# Version of .NET Core to filter by
[string]$Version = "*",
# Name of OS to filter by
[string]$OS,
# Type of architecture to filter by
[string]$Architecture,
# Additional custom path filters (overrides Version)
[string[]]$Paths,
# Additional args to pass to ImageBuilder
[string]$OptionalImageBuilderArgs,
# Execution mode of the script
[ValidateSet("BuildAndTest", "Build", "Test")]
[string]$Mode = "BuildAndTest",
# Categories of tests to run
[ValidateSet("runtime", "runtime-deps", "aspnet", "sdk", "pre-build", "sample", "image-size")]
[string[]]$TestCategories = @("runtime", "runtime-deps", "aspnet", "sdk", "sample", "image-size")
)
if ($Mode -eq "BuildAndTest" -or $Mode -eq "Test") {
& ./tests/run-tests.ps1 -TestCategories "pre-build"
}
if ($Mode -eq "BuildAndTest" -or $Mode -eq "Build") {
# Build the product images
& ./eng/common/build.ps1 `
-Version $Version `
-OS $OS `
-Architecture $Architecture `
-Paths $Paths `
-OptionalImageBuilderArgs $OptionalImageBuilderArgs
$activeOS = docker version -f "{{ .Server.Os }}"
if ($activeOS -eq "windows" -and -not $OS) {
Write-Host "Setting OS to match local Windows host version"
$windowsReleaseId = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId
$OS = "nanoserver-$windowsReleaseId"
}
# Build the sample images
& ./eng/common/build.ps1 `
-Version $Version `
-OS $OS `
-Architecture $Architecture `
-Paths $Paths `
-OptionalImageBuilderArgs $OptionalImageBuilderArgs `
-Manifest manifest.samples.json
}
if ($Mode -eq "BuildAndTest" -or $Mode -eq "Test") {
$localTestCategories = $TestCategories
if ($Version -ne "*" -and $TestCategories.Contains("sample")) {
$localTestCategories = $TestCategories | where { $_ -ne "sample" }
Write-Warning "Skipping sample image testing since Version was set"
}
& ./tests/run-tests.ps1 `
-Version $Version `
-OS $OS `
-Architecture $Architecture `
-TestCategories $localTestCategories
}