From 2191697194a3be6389321346ebd2214ee9701e7c Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 12 Mar 2024 14:02:25 -0700 Subject: [PATCH] Move logic to build script --- .../gradle/internal/BwcVersions.java | 10 +--------- .../gradle/internal/BwcVersionsSpec.groovy | 20 +++++++++---------- build.gradle | 17 ++++++++++------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java index cba2866357222..3147732267b07 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java @@ -86,15 +86,7 @@ public BwcVersions(Version currentVersionProperty, List allVersions) { throw new IllegalArgumentException("Could not parse any versions"); } - // Filter out all intermediate patch releases, so we only consider the latest patch for any given minor - this.versions = allVersions.stream() - .collect(groupingBy(v -> v.getMajor() + "." + v.getMinor(), reducing(BinaryOperator.maxBy(Version::compareTo)))) - .values() - .stream() - .map(Optional::orElseThrow) - .sorted() - .toList(); - + this.versions = allVersions; this.currentVersion = allVersions.get(allVersions.size() - 1); assertCurrentVersionMatchesParsed(currentVersionProperty); diff --git a/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/BwcVersionsSpec.groovy b/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/BwcVersionsSpec.groovy index 68d05fae61fbd..39a9af38e6a9c 100644 --- a/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/BwcVersionsSpec.groovy +++ b/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/BwcVersionsSpec.groovy @@ -46,7 +46,7 @@ class BwcVersionsSpec extends Specification { (v('8.1.0')): new UnreleasedVersionInfo(v('8.1.0'), 'main', ':distribution') ] bwc.wireCompatible == [v('7.17.0'), v('8.0.0'), v('8.1.0')] - bwc.indexCompatible == osFiltered([v('7.14.2'), v('7.15.2'), v('7.16.2'), v('7.17.0'), v('8.0.0'), v('8.1.0')]) + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.16.2'), v('7.17.0'), v('8.0.0'), v('8.1.0')]) } def "current version is next minor with next major and last minor both staged"() { @@ -75,7 +75,7 @@ class BwcVersionsSpec extends Specification { (v('8.1.0')): new UnreleasedVersionInfo(v('8.1.0'), 'main', ':distribution') ] bwc.wireCompatible == [v('7.17.0'), v('8.0.0'), v('8.1.0')] - bwc.indexCompatible == osFiltered([v('7.14.2'), v('7.15.2'), v('7.16.1'), v('7.17.0'), v('8.0.0'), v('8.1.0')]) + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.17.0'), v('8.0.0'), v('8.1.0')]) } def "current is next minor with upcoming minor staged"() { @@ -103,8 +103,8 @@ class BwcVersionsSpec extends Specification { (v('8.0.0')): new UnreleasedVersionInfo(v('8.0.0'), '8.0', ':distribution:bwc:staged'), (v('8.1.0')): new UnreleasedVersionInfo(v('8.1.0'), 'main', ':distribution') ] - bwc.wireCompatible == [v('7.17.1'), v('8.0.0'), v('8.1.0')] - bwc.indexCompatible == osFiltered([v('7.14.2'),v('7.15.2'), v('7.16.1'), v('7.17.1'), v('8.0.0'), v('8.1.0')]) + bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.1.0')] + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.1.0')]) } def "current version is staged major"() { @@ -130,8 +130,8 @@ class BwcVersionsSpec extends Specification { (v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:bugfix'), (v('8.0.0')): new UnreleasedVersionInfo(v('8.0.0'), 'main', ':distribution'), ] - bwc.wireCompatible == [v('7.17.1'), v('8.0.0')] - bwc.indexCompatible == osFiltered([v('7.14.2'), v('7.15.2'), v('7.16.1'), v('7.17.1'), v('8.0.0')]) + bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.0.0')] + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.17.0'), v('7.17.1'), v('8.0.0')]) } def "current version is next bugfix"() { @@ -158,8 +158,8 @@ class BwcVersionsSpec extends Specification { (v('7.17.1')): new UnreleasedVersionInfo(v('7.17.1'), '7.17', ':distribution:bwc:maintenance'), (v('8.0.1')): new UnreleasedVersionInfo(v('8.0.1'), 'main', ':distribution'), ] - bwc.wireCompatible == [v('7.17.1'), v('8.0.1')] - bwc.indexCompatible == osFiltered([v('7.14.2'), v('7.15.2'), v('7.16.1'), v('7.17.1'), v('8.0.1')]) + bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.0.1')] + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.0.1')]) } def "current version is next minor with no staged releases"() { @@ -188,8 +188,8 @@ class BwcVersionsSpec extends Specification { (v('8.0.1')): new UnreleasedVersionInfo(v('8.0.1'), '8.0', ':distribution:bwc:bugfix'), (v('8.1.0')): new UnreleasedVersionInfo(v('8.1.0'), 'main', ':distribution') ] - bwc.wireCompatible == [v('7.17.1'), v('8.0.1'), v('8.1.0')] - bwc.indexCompatible == osFiltered([v('7.14.2'), v('7.15.2'), v('7.16.1'), v('7.17.1'), v('8.0.1'), v('8.1.0')]) + bwc.wireCompatible == [v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.0.1'), v('8.1.0')] + bwc.indexCompatible == osFiltered([v('7.14.0'), v('7.14.1'), v('7.14.2'), v('7.15.0'), v('7.15.1'), v('7.15.2'), v('7.16.0'), v('7.16.1'), v('7.17.0'), v('7.17.1'), v('8.0.0'), v('8.0.1'), v('8.1.0')]) } private void addVersion(String elasticsearch, String lucene) { diff --git a/build.gradle b/build.gradle index 0cb4133f2ed6e..ebf0fb0392a68 100644 --- a/build.gradle +++ b/build.gradle @@ -118,22 +118,27 @@ tasks.register("updateCIBwcVersions") { writeBuildkitePipeline(outputFilePath, pipelineTemplatePath, [], [new StepExpansion(templatePath: stepTemplatePath, versions: versions, variable: "BWC_STEPS")]) } + // Filters out intermediate patch releases to reduce the load of CI testing + def filterIntermediatePatches = { List versions -> + versions.groupBy {"${it.major}.${it.minor}"}.values().collect {it.max()} + } + doLast { - writeVersions(file(".ci/bwcVersions"), BuildParams.bwcVersions.allIndexCompatible) - writeVersions(file(".ci/snapshotBwcVersions"), BuildParams.bwcVersions.unreleasedIndexCompatible) + writeVersions(file(".ci/bwcVersions"), filterIntermediatePatches(BuildParams.bwcVersions.allIndexCompatible)) + writeVersions(file(".ci/snapshotBwcVersions"), filterIntermediatePatches(BuildParams.bwcVersions.unreleasedIndexCompatible)) expandBwcList( ".buildkite/pipelines/intake.yml", ".buildkite/pipelines/intake.template.yml", - BuildParams.bwcVersions.unreleasedIndexCompatible + filterIntermediatePatches(BuildParams.bwcVersions.unreleasedIndexCompatible) ) writeBuildkitePipeline( ".buildkite/pipelines/periodic.yml", ".buildkite/pipelines/periodic.template.yml", [ - new ListExpansion(versions: BuildParams.bwcVersions.unreleasedIndexCompatible, variable: "BWC_LIST"), + new ListExpansion(versions: filterIntermediatePatches(BuildParams.bwcVersions.unreleasedIndexCompatible), variable: "BWC_LIST"), ], [ - new StepExpansion(templatePath: ".buildkite/pipelines/periodic.bwc.template.yml", versions: BuildParams.bwcVersions.allIndexCompatible, variable: "BWC_STEPS"), + new StepExpansion(templatePath: ".buildkite/pipelines/periodic.bwc.template.yml", versions: filterIntermediatePatches(BuildParams.bwcVersions.allIndexCompatible), variable: "BWC_STEPS"), ] ) @@ -141,7 +146,7 @@ tasks.register("updateCIBwcVersions") { ".buildkite/pipelines/periodic-packaging.yml", ".buildkite/pipelines/periodic-packaging.template.yml", ".buildkite/pipelines/periodic-packaging.bwc.template.yml", - BuildParams.bwcVersions.allIndexCompatible + filterIntermediatePatches(BuildParams.bwcVersions.allIndexCompatible) ) } }