Skip to content

Use channel tags to make manifest list more automatic #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vsts-ci/manifestSteps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ steps:
- powershell: 'Get-ChildItem env:'
displayName: 'Capture Environment'

- pwsh: |
$PSVersionTable
displayName: Capture pwsh Version

- powershell: |
$dockerConfigFolder = "$env:userprofile/.docker"
if(!(Test-Path $dockerConfigFolder)){ $null = new-item -Type Directory -Path $dockerConfigFolder}
Expand Down
1 change: 1 addition & 0 deletions .vsts-ci/templatesReleasePipeline/releaseJob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
}
}
displayName: 'release - $(channel) - $(imagename)'
condition: and( succeeded(), ne(variables['Channel'],''))

- pwsh: 'az logout'
displayName: 'az logout'
Expand Down
2 changes: 2 additions & 0 deletions .vsts-ci/templatesReleasePipeline/testJob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jobs:
}
.\build.ps1 -test -Channel $(Channel) -Pull -ImageName $(dockerHost) -name '$(ImageName)' -Version $(Version) -TestLogPostfix windows-$(Channel) -Repository $(dockerNamespace)/powershell @extraParams
displayName: 'Run Tests for $(Channel) - $(ImageName)'
condition: and( succeeded(), ne(variables['Channel'],''))


- task: PublishTestResults@2
displayName: 'Publish Test Results **/test*.xml'
Expand Down
6 changes: 3 additions & 3 deletions .vsts-ci/templatesReleasePipeline/testStage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ stages:

- template: ./testJob.yml
parameters:
jobName: ${{ parameters.channel }}_linux
jobName: ${{ parameters.channel }}_linux_arm64
matrix: dependencies.GenerateYaml_${{ parameters.channel }}.outputs['matrix.matrix_${{ parameters.channel }}_linux_arm64']
vmImage: ubuntu-latest
dependsOn:
- GenerateYaml_${{ parameters.channel }}

- template: ./testJob.yml
parameters:
jobName: ${{ parameters.channel }}_linux
jobName: ${{ parameters.channel }}_linux_arm32
matrix: dependencies.GenerateYaml_${{ parameters.channel }}.outputs['matrix.matrix_${{ parameters.channel }}_linux_arm32']
vmImage: ubuntu-latest
dependsOn:
- GenerateYaml_${{ parameters.channel }}

40 changes: 36 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,25 @@ End {
if ($GenerateManifestLists.IsPresent) {
$manifestLists = @()
$tags = @()

foreach ($repo in $tagGroups.Keys | Sort-Object) {
$channelGroups = $tagGroups.$repo | Group-Object -Property Channel
foreach ($channelGroup in $channelGroups) {
$channelName = $channelGroup.Name
switch($channelName) {
'stable' {
$channelTag = 'latest'
$channelTagPrefix = ''
$channelTagPostfix = ''
}

default {
$channelTag = $channelName.ToLower()
$channelTagPrefix = $channelTag + '-'
$channelTagPostfix = '-' + $channelTag
}
}

Write-Verbose "generating $channelName json"
$osGroups = $channelGroup.Group | Group-Object -Property os
foreach ($osGroup in $osGroups) {
Expand All @@ -681,14 +696,31 @@ End {
foreach ($tag in $osGroup.Group | Where-Object { $_.Name -notlike '*/*' } | Sort-Object -Property ManifestLists) {
if ($tag.ManifestLists) {
foreach ($manifestList in $tag.ManifestLists) {
$originalManifestList = $manifestList
if ($manifestList -notlike '*${channel*') {
Write-Warning "Issue found with $osName $manifestList $($tag.Tags)"
throw 'ManifestLists entries must contain on of: ${channelTag} ${channelTagPrefix} ${channelTagPostfix}'
}

$manifestList = $manifestList -replace '\${channelTag}', $channelTag
$manifestList = $manifestList -replace '\${channelTagPrefix}', $channelTagPrefix
$manifestList = $manifestList -replace '\${channelTagPostfix}', $channelTagPostfix

if (!$manifestList) {
throw "error formatting $originalManifestList"
}

if ($manifestLists -notcontains $manifestList) {
$manifestLists += $manifestList
}

$tag | Add-Member -MemberType NoteProperty -Value $repo -Name 'Repo'

$tags += $tag
$tags += [PSCustomObject]@{
Repo = $repo
FormattedManifestList = $manifestList
Tags = $tag.Tags
Channel = $tag.Channel
ContinueOnError = $tag.ContinueOnError
}
}
}
}
Expand All @@ -707,7 +739,7 @@ End {
Repo = ""
}

foreach ($tag in $tags | Where-Object { $_.ManifestLists -contains $manifestList }) {
foreach ($tag in $tags | Where-Object { $_.FormattedManifestList -eq $manifestList }) {
if (-not $matrix.ContainsKey($manifestList)) {
$matrix.Add($manifestList, @{ })
}
Expand Down
13 changes: 9 additions & 4 deletions createManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,31 @@ param(

[switch]
$SkipPush

)

$first = $true
$manifestList = @()
foreach($tag in $TagList)
{
$arguments = @()
$amend = ""
if (!$first) {
$amend = '--amend'
$arguments += '--amend'
}
$arguments += @(
"$ContainerRegistry/${Image}:$ManifestTag"
"$ContainerRegistry/${Image}:$tag"
)

Write-Verbose -Message "running: docker manifest create $ammend $ContainerRegistry/${Image}:$ManifestTag $ContainerRegistry/${Image}:$tag" -Verbose
docker manifest create $amend $ContainerRegistry/${Image}:$ManifestTag "$ContainerRegistry/${Image}:$tag"
Write-Verbose -Message "running: docker manifest create $arguments" -Verbose
docker manifest create $arguments
$first = $false
}

# Create the manifest

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

# push the manifest
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/nanoserver1809/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"nanoserver-#shorttag#"
],
"manifestLists": [
"nanoserver"
"${channelTagPrefix}nanoserver"
],
"Base64EncodePackageUrl": true,
"TestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/nanoserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"nanoserver-#shorttag#"
],
"manifestLists": [
"nanoserver"
"${channelTagPrefix}nanoserver"
],
"Base64EncodePackageUrl": true,
"TestProperties": {
Expand Down
3 changes: 2 additions & 1 deletion release/7-2/ubi8/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{"Tag": "8"}
],
"manifestLists": [
"ubi"
"ubi${channelTagPostfix}",
"${channelTagPrefix}ubi"
],
"SubImage": "test-deps",
"TestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/ubuntu22.04-arm32v7/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Arm32": true
},
"manifestLists": [
"latest"
"${channelTag}"
],
"EndOfLife": "2023-04-02",
"DistributionState": "Validated",
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/ubuntu22.04/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{"Tag": "22.04"}
],
"manifestLists": [
"latest"
"${channelTag}"
],
"TestProperties": {
"size": 343
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/windowsserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"windowsserver-#shorttag#"
],
"manifestLists": [
"windowsserver"
"${channelTagPrefix}windowsserver"
],
"TestProperties": {
"size": 1
Expand Down
2 changes: 1 addition & 1 deletion release/7-2/windowsservercore2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"windowsservercore-#shorttag#"
],
"manifestLists": [
"latest"
"${channelTag}"
],
"TestProperties": {
"size": 1
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/mariner2-arm64/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"TestProperties": {
"size": 404,
"arm64": true
"Arm32": true
},
"EndOfLife": "2023-12-14",
"DistributionState": "Validating",
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/nanoserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"ShortDistroName": "nanoserver",
"manifestLists": [
"nanoserver"
"${channelTagPrefix}nanoserver"
],
"Base64EncodePackageUrl": true,
"TestProperties": {
Expand Down
3 changes: 2 additions & 1 deletion release/7-3/ubi9/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{"Tag": "9"}
],
"manifestLists": [
"ubi-preview"
"ubi${channelTagPostfix}",
"${channelTagPrefix}ubi"
],
"SubImage": "test-deps",
"TestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/ubuntu22.04-arm32v7/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Arm32": true
},
"manifestLists": [
"preview"
"${channelTag}"
],
"EndOfLife": "2023-04-02",
"DistributionState": "Validated",
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/ubuntu22.04/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{"Tag": "22.04"}
],
"manifestLists": [
"preview"
"${channelTag}"
],
"TestProperties": {
"size": 338
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/windowsserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Base64EncodePackageUrl": true,
"ShortDistroName": "windowsserver",
"manifestLists": [
"windowsserver"
"${channelTagPrefix}windowsserver"
],
"TestProperties": {
"size": 1
Expand Down
2 changes: 1 addition & 1 deletion release/7-3/windowsservercore2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"manifestLists": [
"preview"
"${channelTag}"
],
"Base64EncodePackageUrl": true,
"ShortDistroName": "windowsservercore",
Expand Down
2 changes: 1 addition & 1 deletion release/7-4/mariner2-arm64/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"TestProperties": {
"size": 404,
"arm64": true
"Arm32": true
},
"EndOfLife": "2023-12-14",
"DistributionState": "Validating",
Expand Down
3 changes: 2 additions & 1 deletion release/7-4/ubi9/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{"Tag": "9"}
],
"manifestLists": [
"ubi-preview"
"ubi${channelTagPostfix}",
"${channelTagPrefix}ubi"
],
"SubImage": "test-deps",
"TestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion release/7-4/ubuntu22.04-arm32v7/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Arm32": true
},
"manifestLists": [
"preview"
"${channelTag}"
],
"EndOfLife": "2023-04-02",
"DistributionState": "Validated",
Expand Down
2 changes: 1 addition & 1 deletion release/7-4/ubuntu22.04/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{"Tag": "22.04"}
],
"manifestLists": [
"preview"
"${channelTag}"
],
"TestProperties": {
"size": 338
Expand Down
2 changes: 1 addition & 1 deletion release/7-4/windowsserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Base64EncodePackageUrl": true,
"ShortDistroName": "windowsserver",
"manifestLists": [
"windowsserver"
"${channelTagPrefix}windowsserver"
],
"TestProperties": {
"size": 1
Expand Down
2 changes: 1 addition & 1 deletion release/7-4/windowsservercore2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"manifestLists": [
"preview"
"${channelTag}"
],
"Base64EncodePackageUrl": true,
"ShortDistroName": "windowsservercore",
Expand Down
2 changes: 1 addition & 1 deletion release/unstable/7-4/nanoserver2022/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"ShortDistroName": "nanoserver",
"manifestLists": [
"nanoserver"
"${channelTagPrefix}nanoserver"
],
"Base64EncodePackageUrl": true,
"TestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion tools/buildHelper/buildHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class DockerImageMetaData {
[bool]
$ContinueOnError = $false

[string]
[string[]]
$ManifestLists = @()

[bool]
Expand Down
6 changes: 0 additions & 6 deletions tools/buildHelper/channels.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@
"tagPrefix": "lts",
"pwshInstallVersion": "7-lts",
"packageTag": "-lts"
},
{
"name": "community-stable",
"path": "release/community-stable",
"pwshInstallVersion": "7",
"packageTag": ""
}
]
20 changes: 20 additions & 0 deletions unittests/generateManifestLists.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,24 @@ Describe "build.ps1 -GenerateManifestLists" {
$json | Should -Not -BeNullOrEmpty
$json | ConvertFrom-Json -AsHashtable | Should -Not -BeNullOrEmpty
}

It "Each tag should only be in one channel" {
$json = & $buildScript -GenerateManifestLists -Channel stable, preview, lts -OsFilter All | ConvertFrom-Json
$tags = @{}
$json | ForEach-Object {
$channel = $_.channel
foreach ($tag in $_.tags) {
if (!$tags.ContainsKey($tag)) {
$tags[$tag] = @()
}
if ($tags[$tag] -notcontains $channel) {
$tags[$tag] += $channel
}
}
}

foreach($tag in $tags.Keys) {
$tags.$tag.count | should -Be 1 -Because "$Tag should not be in multiple channels ($($tags.$tag))"
}
}
}
Loading