Skip to content

Commit

Permalink
Move logic to build script
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Mar 12, 2024
1 parent 45f5cf9 commit 2191697
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,7 @@ public BwcVersions(Version currentVersionProperty, List<Version> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"() {
Expand Down Expand Up @@ -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"() {
Expand Down Expand Up @@ -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"() {
Expand All @@ -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"() {
Expand All @@ -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"() {
Expand Down Expand Up @@ -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) {
Expand Down
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,35 @@ 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<Version> 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"),
]
)

expandBwcSteps(
".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)
)
}
}
Expand Down

0 comments on commit 2191697

Please sign in to comment.