From f332d2555c11b90f3c75161d7f92cf87af9f7ad0 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Mon, 25 Sep 2023 15:41:39 +0000 Subject: [PATCH] Refactor (ci): Use a `job_group_key` to group jobs --- .github/workflows/ci-master-pr.yml | 2 +- .vscode/tasks.json | 5 +---- generate/definitions/VARIANTS.ps1 | 5 +++-- generate/templates/.github/workflows/ci-master-pr.yml.ps1 | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index a9f5854..48d91d8 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -14,7 +14,7 @@ jobs: test-nogitdiff: runs-on: ubuntu-latest container: - image: mcr.microsoft.com/powershell:7.2.2-alpine-3.14-20220318 + image: mcr.microsoft.com/powershell:lts-7.2-alpine-3.17 steps: - run: | apk add --no-cache git diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5d409e9..1ed2a74 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -11,10 +11,7 @@ "-c", "Generate-DockerImageVariants ." ], - "group": { - "kind": "build", - "isDefault": true - } + "group": "build" }, { "label": "Install DockerImageVariants module", diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index 838bc98..dd783b3 100755 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -131,7 +131,7 @@ $VARIANTS = @( # Metadata object _metadata = @{ package = $variant['package'] - package_version = $variant['package_version'] -replace '-r\d+$', '' # Remove the '-r[0-9]' suffix + package_version = $variant['package_version'] distro = $variant['distro'] distro_version = $variant['distro_version'] platforms = & { @@ -142,10 +142,11 @@ $VARIANTS = @( } } components = $subVariant['components'] + job_group_key = $variant['package_version'] } # Docker image tag. E.g. 'v2.3.0.0-alpine-3.6' tag = @( - "v$( $variant['package_version'] )" -replace '-r\d+', '' # E.g. Strip out the '-r' in '2.3.0.0-r1' + "v$( $variant['package_version'] )" $subVariant['components'] | ? { $_ } $variant['distro'] $variant['distro_version'] diff --git a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 index c73c08f..9be7359 100644 --- a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 +++ b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 @@ -15,7 +15,7 @@ jobs: test-nogitdiff: runs-on: ubuntu-latest container: - image: mcr.microsoft.com/powershell:7.2.2-alpine-3.14-20220318 + image: mcr.microsoft.com/powershell:lts-7.2-alpine-3.17 steps: - run: | apk add --no-cache git @@ -36,7 +36,7 @@ jobs: '@ # Group variants by the package version -$groups = $VARIANTS | Group-Object -Property { $_['_metadata']['package_version'] } | Sort-Object -Property { [version]$_.Name } -Descending +$groups = $VARIANTS | Group-Object -Property { $_['_metadata']['job_group_key'] } | Sort-Object { [version]$_.Name.Split('-')[0] } -Descending $WORKFLOW_JOB_NAMES = $groups | % { "build-$( $_.Name.Replace('.', '-') )" } foreach ($g in $groups) { @"