Skip to content

Commit 099e402

Browse files
Use channel tags to make manifest list more automatic (#743)
* Use channel tags to make manifest list more automatic * Add unit test to verify we mix manifest list channels * Update unittests/generateManifestLists.tests.ps1 * Update unittests/generateManifestLists.tests.ps1 Co-authored-by: Aditya Patwardhan <[email protected]> * add new format of manifest list * update how we create the manifest create cmdline * fix release tests * mark amazon linux as unstable * mark mariner as arm for test purposes * remove community channel * mark the right image * remove community CI * skip tasks when matrix is empty --------- Co-authored-by: Aditya Patwardhan <[email protected]>
1 parent e8c2c57 commit 099e402

File tree

35 files changed

+100
-43
lines changed

35 files changed

+100
-43
lines changed

.vsts-ci/manifestSteps.yml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ steps:
77
- powershell: 'Get-ChildItem env:'
88
displayName: 'Capture Environment'
99

10+
- pwsh: |
11+
$PSVersionTable
12+
displayName: Capture pwsh Version
13+
1014
- powershell: |
1115
$dockerConfigFolder = "$env:userprofile/.docker"
1216
if(!(Test-Path $dockerConfigFolder)){ $null = new-item -Type Directory -Path $dockerConfigFolder}

.vsts-ci/templatesReleasePipeline/releaseJob.yml

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
}
103103
}
104104
displayName: 'release - $(channel) - $(imagename)'
105+
condition: and( succeeded(), ne(variables['Channel'],''))
105106
106107
- pwsh: 'az logout'
107108
displayName: 'az logout'

.vsts-ci/templatesReleasePipeline/testJob.yml

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jobs:
8484
}
8585
.\build.ps1 -test -Channel $(Channel) -Pull -ImageName $(dockerHost) -name '$(ImageName)' -Version $(Version) -TestLogPostfix windows-$(Channel) -Repository $(dockerNamespace)/powershell @extraParams
8686
displayName: 'Run Tests for $(Channel) - $(ImageName)'
87+
condition: and( succeeded(), ne(variables['Channel'],''))
88+
8789
8890
- task: PublishTestResults@2
8991
displayName: 'Publish Test Results **/test*.xml'

.vsts-ci/templatesReleasePipeline/testStage.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ stages:
5353

5454
- template: ./testJob.yml
5555
parameters:
56-
jobName: ${{ parameters.channel }}_linux
56+
jobName: ${{ parameters.channel }}_linux_arm64
5757
matrix: dependencies.GenerateYaml_${{ parameters.channel }}.outputs['matrix.matrix_${{ parameters.channel }}_linux_arm64']
5858
vmImage: ubuntu-latest
5959
dependsOn:
6060
- GenerateYaml_${{ parameters.channel }}
6161

6262
- template: ./testJob.yml
6363
parameters:
64-
jobName: ${{ parameters.channel }}_linux
64+
jobName: ${{ parameters.channel }}_linux_arm32
6565
matrix: dependencies.GenerateYaml_${{ parameters.channel }}.outputs['matrix.matrix_${{ parameters.channel }}_linux_arm32']
6666
vmImage: ubuntu-latest
6767
dependsOn:
6868
- GenerateYaml_${{ parameters.channel }}
69-
69+

build.ps1

+36-4
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,25 @@ End {
668668
if ($GenerateManifestLists.IsPresent) {
669669
$manifestLists = @()
670670
$tags = @()
671+
671672
foreach ($repo in $tagGroups.Keys | Sort-Object) {
672673
$channelGroups = $tagGroups.$repo | Group-Object -Property Channel
673674
foreach ($channelGroup in $channelGroups) {
674675
$channelName = $channelGroup.Name
676+
switch($channelName) {
677+
'stable' {
678+
$channelTag = 'latest'
679+
$channelTagPrefix = ''
680+
$channelTagPostfix = ''
681+
}
682+
683+
default {
684+
$channelTag = $channelName.ToLower()
685+
$channelTagPrefix = $channelTag + '-'
686+
$channelTagPostfix = '-' + $channelTag
687+
}
688+
}
689+
675690
Write-Verbose "generating $channelName json"
676691
$osGroups = $channelGroup.Group | Group-Object -Property os
677692
foreach ($osGroup in $osGroups) {
@@ -681,14 +696,31 @@ End {
681696
foreach ($tag in $osGroup.Group | Where-Object { $_.Name -notlike '*/*' } | Sort-Object -Property ManifestLists) {
682697
if ($tag.ManifestLists) {
683698
foreach ($manifestList in $tag.ManifestLists) {
699+
$originalManifestList = $manifestList
700+
if ($manifestList -notlike '*${channel*') {
701+
Write-Warning "Issue found with $osName $manifestList $($tag.Tags)"
702+
throw 'ManifestLists entries must contain on of: ${channelTag} ${channelTagPrefix} ${channelTagPostfix}'
703+
}
704+
705+
$manifestList = $manifestList -replace '\${channelTag}', $channelTag
706+
$manifestList = $manifestList -replace '\${channelTagPrefix}', $channelTagPrefix
707+
$manifestList = $manifestList -replace '\${channelTagPostfix}', $channelTagPostfix
708+
709+
if (!$manifestList) {
710+
throw "error formatting $originalManifestList"
711+
}
684712

685713
if ($manifestLists -notcontains $manifestList) {
686714
$manifestLists += $manifestList
687715
}
688716

689-
$tag | Add-Member -MemberType NoteProperty -Value $repo -Name 'Repo'
690-
691-
$tags += $tag
717+
$tags += [PSCustomObject]@{
718+
Repo = $repo
719+
FormattedManifestList = $manifestList
720+
Tags = $tag.Tags
721+
Channel = $tag.Channel
722+
ContinueOnError = $tag.ContinueOnError
723+
}
692724
}
693725
}
694726
}
@@ -707,7 +739,7 @@ End {
707739
Repo = ""
708740
}
709741

710-
foreach ($tag in $tags | Where-Object { $_.ManifestLists -contains $manifestList }) {
742+
foreach ($tag in $tags | Where-Object { $_.FormattedManifestList -eq $manifestList }) {
711743
if (-not $matrix.ContainsKey($manifestList)) {
712744
$matrix.Add($manifestList, @{ })
713745
}

createManifest.ps1

+9-4
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,31 @@ param(
2727

2828
[switch]
2929
$SkipPush
30-
3130
)
3231

3332
$first = $true
3433
$manifestList = @()
3534
foreach($tag in $TagList)
3635
{
36+
$arguments = @()
3737
$amend = ""
3838
if (!$first) {
39-
$amend = '--amend'
39+
$arguments += '--amend'
4040
}
41+
$arguments += @(
42+
"$ContainerRegistry/${Image}:$ManifestTag"
43+
"$ContainerRegistry/${Image}:$tag"
44+
)
4145

42-
Write-Verbose -Message "running: docker manifest create $ammend $ContainerRegistry/${Image}:$ManifestTag $ContainerRegistry/${Image}:$tag" -Verbose
43-
docker manifest create $amend $ContainerRegistry/${Image}:$ManifestTag "$ContainerRegistry/${Image}:$tag"
46+
Write-Verbose -Message "running: docker manifest create $arguments" -Verbose
47+
docker manifest create $arguments
4448
$first = $false
4549
}
4650

4751
# Create the manifest
4852

4953
# Inspect (print) the manifest
54+
Write-Verbose -Verbose "capturing the manifest..."
5055
docker manifest inspect $ContainerRegistry/${Image}:$ManifestTag
5156

5257
# push the manifest

release/7-2/nanoserver1809/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"nanoserver-#shorttag#"
1313
],
1414
"manifestLists": [
15-
"nanoserver"
15+
"${channelTagPrefix}nanoserver"
1616
],
1717
"Base64EncodePackageUrl": true,
1818
"TestProperties": {

release/7-2/nanoserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"nanoserver-#shorttag#"
1313
],
1414
"manifestLists": [
15-
"nanoserver"
15+
"${channelTagPrefix}nanoserver"
1616
],
1717
"Base64EncodePackageUrl": true,
1818
"TestProperties": {

release/7-2/ubi8/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
{"Tag": "8"}
1313
],
1414
"manifestLists": [
15-
"ubi"
15+
"ubi${channelTagPostfix}",
16+
"${channelTagPrefix}ubi"
1617
],
1718
"SubImage": "test-deps",
1819
"TestProperties": {

release/7-2/ubuntu22.04-arm32v7/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"Arm32": true
2121
},
2222
"manifestLists": [
23-
"latest"
23+
"${channelTag}"
2424
],
2525
"EndOfLife": "2023-04-02",
2626
"DistributionState": "Validated",

release/7-2/ubuntu22.04/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{"Tag": "22.04"}
1414
],
1515
"manifestLists": [
16-
"latest"
16+
"${channelTag}"
1717
],
1818
"TestProperties": {
1919
"size": 343

release/7-2/windowsserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"windowsserver-#shorttag#"
1414
],
1515
"manifestLists": [
16-
"windowsserver"
16+
"${channelTagPrefix}windowsserver"
1717
],
1818
"TestProperties": {
1919
"size": 1

release/7-2/windowsservercore2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"windowsservercore-#shorttag#"
1414
],
1515
"manifestLists": [
16-
"latest"
16+
"${channelTag}"
1717
],
1818
"TestProperties": {
1919
"size": 1

release/7-3/mariner2-arm64/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"TestProperties": {
1414
"size": 404,
15-
"arm64": true
15+
"Arm32": true
1616
},
1717
"EndOfLife": "2023-12-14",
1818
"DistributionState": "Validating",

release/7-3/nanoserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"ShortDistroName": "nanoserver",
1111
"manifestLists": [
12-
"nanoserver"
12+
"${channelTagPrefix}nanoserver"
1313
],
1414
"Base64EncodePackageUrl": true,
1515
"TestProperties": {

release/7-3/ubi9/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{"Tag": "9"}
1010
],
1111
"manifestLists": [
12-
"ubi-preview"
12+
"ubi${channelTagPostfix}",
13+
"${channelTagPrefix}ubi"
1314
],
1415
"SubImage": "test-deps",
1516
"TestProperties": {

release/7-3/ubuntu22.04-arm32v7/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Arm32": true
1717
},
1818
"manifestLists": [
19-
"preview"
19+
"${channelTag}"
2020
],
2121
"EndOfLife": "2023-04-02",
2222
"DistributionState": "Validated",

release/7-3/ubuntu22.04/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{"Tag": "22.04"}
1111
],
1212
"manifestLists": [
13-
"preview"
13+
"${channelTag}"
1414
],
1515
"TestProperties": {
1616
"size": 338

release/7-3/windowsserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Base64EncodePackageUrl": true,
1111
"ShortDistroName": "windowsserver",
1212
"manifestLists": [
13-
"windowsserver"
13+
"${channelTagPrefix}windowsserver"
1414
],
1515
"TestProperties": {
1616
"size": 1

release/7-3/windowsservercore2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
],
1010
"manifestLists": [
11-
"preview"
11+
"${channelTag}"
1212
],
1313
"Base64EncodePackageUrl": true,
1414
"ShortDistroName": "windowsservercore",

release/7-4/mariner2-arm64/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"TestProperties": {
1414
"size": 404,
15-
"arm64": true
15+
"Arm32": true
1616
},
1717
"EndOfLife": "2023-12-14",
1818
"DistributionState": "Validating",

release/7-4/ubi9/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{"Tag": "9"}
1010
],
1111
"manifestLists": [
12-
"ubi-preview"
12+
"ubi${channelTagPostfix}",
13+
"${channelTagPrefix}ubi"
1314
],
1415
"SubImage": "test-deps",
1516
"TestProperties": {

release/7-4/ubuntu22.04-arm32v7/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Arm32": true
1717
},
1818
"manifestLists": [
19-
"preview"
19+
"${channelTag}"
2020
],
2121
"EndOfLife": "2023-04-02",
2222
"DistributionState": "Validated",

release/7-4/ubuntu22.04/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{"Tag": "22.04"}
1111
],
1212
"manifestLists": [
13-
"preview"
13+
"${channelTag}"
1414
],
1515
"TestProperties": {
1616
"size": 338

release/7-4/windowsserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Base64EncodePackageUrl": true,
1111
"ShortDistroName": "windowsserver",
1212
"manifestLists": [
13-
"windowsserver"
13+
"${channelTagPrefix}windowsserver"
1414
],
1515
"TestProperties": {
1616
"size": 1

release/7-4/windowsservercore2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
],
1010
"manifestLists": [
11-
"preview"
11+
"${channelTag}"
1212
],
1313
"Base64EncodePackageUrl": true,
1414
"ShortDistroName": "windowsservercore",

release/unstable/7-4/nanoserver2022/meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"ShortDistroName": "nanoserver",
1111
"manifestLists": [
12-
"nanoserver"
12+
"${channelTagPrefix}nanoserver"
1313
],
1414
"Base64EncodePackageUrl": true,
1515
"TestProperties": {

tools/buildHelper/buildHelper.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class DockerImageMetaData {
266266
[bool]
267267
$ContinueOnError = $false
268268

269-
[string]
269+
[string[]]
270270
$ManifestLists = @()
271271

272272
[bool]

tools/buildHelper/channels.json

-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,5 @@
1818
"tagPrefix": "lts",
1919
"pwshInstallVersion": "7-lts",
2020
"packageTag": "-lts"
21-
},
22-
{
23-
"name": "community-stable",
24-
"path": "release/community-stable",
25-
"pwshInstallVersion": "7",
26-
"packageTag": ""
2721
}
2822
]

unittests/generateManifestLists.tests.ps1

+20
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,24 @@ Describe "build.ps1 -GenerateManifestLists" {
1313
$json | Should -Not -BeNullOrEmpty
1414
$json | ConvertFrom-Json -AsHashtable | Should -Not -BeNullOrEmpty
1515
}
16+
17+
It "Each tag should only be in one channel" {
18+
$json = & $buildScript -GenerateManifestLists -Channel stable, preview, lts -OsFilter All | ConvertFrom-Json
19+
$tags = @{}
20+
$json | ForEach-Object {
21+
$channel = $_.channel
22+
foreach ($tag in $_.tags) {
23+
if (!$tags.ContainsKey($tag)) {
24+
$tags[$tag] = @()
25+
}
26+
if ($tags[$tag] -notcontains $channel) {
27+
$tags[$tag] += $channel
28+
}
29+
}
30+
}
31+
32+
foreach($tag in $tags.Keys) {
33+
$tags.$tag.count | should -Be 1 -Because "$Tag should not be in multiple channels ($($tags.$tag))"
34+
}
35+
}
1636
}

0 commit comments

Comments
 (0)