-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathMakefile.ps1
More file actions
76 lines (62 loc) · 2.27 KB
/
Copy pathMakefile.ps1
File metadata and controls
76 lines (62 loc) · 2.27 KB
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
71
72
73
74
75
76
# Copyright 2025-2026 The MathWorks, Inc.
# This script allows you to run build and test targets of a GitHub actions pipeline in an identical manner on your local machine.
# This ensures that the build and test actions are easily reproducible outside of a CI/CD pipeline.
param(
[Parameter(Mandatory=$False, Position=0, ValueFromRemainingArguments=$false)]
[System.String]
$Target = "BuildAndTest",
[Parameter(Mandatory=$False, ValueFromPipeline=$false)]
[System.String]
$ImageName = "matlab-on-windows",
[Parameter(Mandatory=$False, ValueFromPipeline=$false)]
[System.String]
$Release = "R2026a",
[Parameter(Mandatory=$False, ValueFromPipeline=$false)]
[System.String]
$ProductList = "MATLAB Text_Analytics_Toolbox Simulink_Coder Embedded_Coder MATLAB_Support_for_MinGW-w64_C/C++/Fortran_Compiler Requirements_Toolbox",
[Parameter(Mandatory=$False, ValueFromPipeline=$false)]
[System.String]
$Token = ""
)
$script:Version="0.6.0"
function defaultTag {
return (Get-Culture).TextInfo.ToTitleCase(${Release})
}
function additionalTags {
return @(${Release}.ToLower())
}
function Build {
$Tag = defaultTag
& docker build --isolation=hyperv --build-arg MATLAB_RELEASE=${Release} --build-arg MATLAB_PRODUCT_LIST="${ProductList}" -t "${ImageName}:${Tag}" .
}
function Test {
if (${Token} -eq "") {
Write-Error "Token argument must be supplied to test command"
throw "input error"
}
$Tag = defaultTag
$container = New-PesterContainer -Path .\test\Test-MATLABWindowsContainer.tests.ps1 -Data @{ Release = ${Release}; ImageName = "${ImageName}:${Tag}"; Token = ${Token} }
& Invoke-Pester -Container $container -Output Detailed
}
function TagImage {
$DefaultTag = defaultTag
$AdditionalTags = additionalTags
foreach ($Tag in $AdditionalTags) {
& docker tag "${ImageName}:${DefaultTag}" "${ImageName}:${Tag}"
}
}
function Publish {
docker push --all-tags ${ImageName}
}
function BuildAndTest {
Build
Test
}
switch (${Target}) {
'Build' { Build }
'Test' { Test }
'BuildAndTest' { BuildAndTest }
'TagImage' { TagImage }
'Publish' {Publish}
default { BuildAndTest }
}