-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New release notes generator tasks (#71125)
Part of #67335. Add tasks for generating release notes, using information stored in files in the repository: * `generateReleaseNotes` - generates new release notes, release highlights and breaking changes * `validateChangelogs` - validates that all the changelog YAML files are well-formed (confirm to schema, have required fields depending on the `type` value) I also changed `Version` to allow a `v` prefix in relaxed mode
- Loading branch information
1 parent
a81f0b4
commit f34d9ad
Showing
20 changed files
with
1,681 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../main/java/org/elasticsearch/gradle/internal/precommit/ValidateYamlAgainstSchemaTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal.precommit; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
|
||
/** | ||
* Incremental task to validate a set of YAML files against against a schema. | ||
*/ | ||
public class ValidateYamlAgainstSchemaTask extends ValidateJsonAgainstSchemaTask { | ||
@Override | ||
protected String getFileType() { | ||
return "YAML"; | ||
} | ||
|
||
protected ObjectMapper getMapper() { | ||
return new ObjectMapper(new YAMLFactory()); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...nal/src/main/java/org/elasticsearch/gradle/internal/release/BreakingChangesGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal.release; | ||
|
||
import groovy.text.SimpleTemplateEngine; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
import org.elasticsearch.gradle.Version; | ||
import org.elasticsearch.gradle.VersionProperties; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.TreeMap; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Generates the page that lists the breaking changes and deprecations for a minor version release. | ||
*/ | ||
public class BreakingChangesGenerator { | ||
|
||
static void update(File templateFile, File outputFile, List<ChangelogEntry> entries) throws IOException { | ||
try (FileWriter output = new FileWriter(outputFile)) { | ||
generateFile(Files.readString(templateFile.toPath()), output, entries); | ||
} | ||
} | ||
|
||
@VisibleForTesting | ||
private static void generateFile(String template, FileWriter outputWriter, List<ChangelogEntry> entries) throws IOException { | ||
final Version version = VersionProperties.getElasticsearchVersion(); | ||
|
||
final Map<Boolean, Map<String, List<ChangelogEntry.Breaking>>> breakingChangesByNotabilityByArea = entries.stream() | ||
.map(ChangelogEntry::getBreaking) | ||
.filter(Objects::nonNull) | ||
.collect( | ||
Collectors.groupingBy( | ||
ChangelogEntry.Breaking::isNotable, | ||
Collectors.groupingBy(ChangelogEntry.Breaking::getArea, TreeMap::new, Collectors.toList()) | ||
) | ||
); | ||
|
||
final Map<String, List<ChangelogEntry.Deprecation>> deprecationsByArea = entries.stream() | ||
.map(ChangelogEntry::getDeprecation) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.groupingBy(ChangelogEntry.Deprecation::getArea, TreeMap::new, Collectors.toList())); | ||
|
||
final Map<String, Object> bindings = new HashMap<>(); | ||
bindings.put("breakingChangesByNotabilityByArea", breakingChangesByNotabilityByArea); | ||
bindings.put("deprecationsByArea", deprecationsByArea); | ||
bindings.put("isElasticsearchSnapshot", VersionProperties.isElasticsearchSnapshot()); | ||
bindings.put("majorDotMinor", version.getMajor() + "." + version.getMinor()); | ||
bindings.put("majorMinor", String.valueOf(version.getMajor()) + version.getMinor()); | ||
bindings.put("nextMajor", (version.getMajor() + 1) + ".0"); | ||
bindings.put("version", version); | ||
|
||
try { | ||
final SimpleTemplateEngine engine = new SimpleTemplateEngine(); | ||
engine.createTemplate(template).make(bindings).writeTo(outputWriter); | ||
} catch (ClassNotFoundException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.