From d60053de8beedc990f33544314408d704f4c151a Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Fri, 22 Nov 2024 10:49:11 +0100 Subject: [PATCH] fix: limit the amount of minor to build Since we are limited to 256 job per run in a github workflow, we can't keep building all the minor versions for every major. This limit the amount of minor version to build to the 5 most recent ones. --- build-matrix/main.go | 7 ++++++- build-matrix/main_test.go | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/build-matrix/main.go b/build-matrix/main.go index 679ce9e..9593405 100755 --- a/build-matrix/main.go +++ b/build-matrix/main.go @@ -14,6 +14,8 @@ import ( const ( // Define the oldest major version we care about, we do not want to build image starting ansible 1.0 minSupportedMajor = 7 + // Numbed of latest minor release to keep building + maxSupportedMinor = 5 ) type ReleaseResponse struct { @@ -38,6 +40,7 @@ type Matrix []matrixVersion // - 10.1 // - 10.3 // - 10.4, additional_tags: 10 +// We also only keep the latest 5 minor versions because we are limited to 256 jobs per workflow run // Check main_test.go for a quick overview of the expected behavior. func main() { resp, err := http.Get("https://pypi.org/pypi/ansible/json") @@ -87,7 +90,9 @@ func GenerateBuildMatrix(reader io.Reader, minSupportedMajor uint64) Matrix { if _, exists := versionGroupedByMajor[major]; !exists { majorVersions = append(majorVersions, major) } - versionGroupedByMajor[major] = append(versionGroupedByMajor[major], version) + if len(versionGroupedByMajor[major]) < maxSupportedMinor { + versionGroupedByMajor[major] = append(versionGroupedByMajor[major], version) + } } sort.Sort(sort.Reverse(sort.IntSlice(majorVersions))) diff --git a/build-matrix/main_test.go b/build-matrix/main_test.go index 0398763..32dbe06 100644 --- a/build-matrix/main_test.go +++ b/build-matrix/main_test.go @@ -20,6 +20,10 @@ func TestGenerateBuildMatrix(t *testing.T) { "3.1.0": struct{}{}, "3.1.1": struct{}{}, "3.2.0": struct{}{}, + "3.3.0": struct{}{}, + "3.4.0": struct{}{}, + "3.5.0": struct{}{}, + "3.6.0": struct{}{}, }, } @@ -29,11 +33,23 @@ func TestGenerateBuildMatrix(t *testing.T) { matrix := GenerateBuildMatrix(bytes.NewReader(fakeJsonResponse), 2) expectedMatrix := Matrix{ { - Ansible: "3.2", + Ansible: "3.6", AdditionalTags: []string{"3"}, }, { - Ansible: "3.1", + Ansible: "3.5", + AdditionalTags: []string{}, + }, + { + Ansible: "3.4", + AdditionalTags: []string{}, + }, + { + Ansible: "3.3", + AdditionalTags: []string{}, + }, + { + Ansible: "3.2", AdditionalTags: []string{}, }, {