Skip to content

Commit bbb9c1d

Browse files
Added option of running a release train for a single project
1 parent 15173b1 commit bbb9c1d

File tree

68 files changed

+1846
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1846
-197
lines changed

build.gradle

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,17 @@ println "I'm configuring $project.name with version $project.version"
4444
dependencies {
4545
checkstyle libs.javaFormatForPlugins
4646

47-
// Use JUnit Jupiter for testing.
4847
implementation libs.slf4j
4948
implementation libs.logback
49+
implementation libs.jacksonDatabind
5050

5151
testImplementation 'org.junit.jupiter:junit-jupiter'
5252
testImplementation libs.assertj
53+
testImplementation libs.archunit
5354
testImplementation libs.mockitoCore
54-
testImplementation libs.jacksonDatabind
5555
testImplementation libs.jacksonDatatype
5656
testImplementation libs.wiremock
5757

58-
5958
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
6059

6160
// PIT JUnit 5 plugin
@@ -76,7 +75,6 @@ application {
7675
}
7776

7877
tasks.named('test') {
79-
// Use JUnit Platform for unit tests.
8078
useJUnitPlatform()
8179
}
8280

gradle/libs.versions.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[versions]
22
assertj = "3.27.3"
3+
archunit = "1.4.0"
34
jackson = "2.18.2"
45
javaFormatForPlugins = "0.0.43"
56
junit = "5.11.4"
@@ -12,6 +13,7 @@ wiremock = "3.12.0"
1213

1314
[libraries]
1415
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
16+
archunit = { module = "com.tngtech.archunit:archunit-junit5", version.ref = "archunit" }
1517
jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
1618
jacksonDatatype = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" }
1719
javaFormatForPlugins = { module = "io.spring.javaformat:spring-javaformat-checkstyle", version.ref = "javaFormatForPlugins" }

src/main/java/io/micrometer/release/Main.java

+72-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@
1515
*/
1616
package io.micrometer.release;
1717

18+
import io.micrometer.release.common.ProcessRunner;
19+
import io.micrometer.release.single.*;
20+
import io.micrometer.release.train.ProjectTrainReleaseWorkflow;
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
23+
1824
public class Main {
1925

26+
private static final Logger log = LoggerFactory.getLogger(Main.class);
27+
2028
public static void main(String[] args) throws Exception {
2129
// Env Vars
30+
31+
// Single Project Post Release
2232
// GH_TOKEN
2333
// CHANGELOG_GENERATOR_VERSION
2434
// GITHUB_REPOSITORY
@@ -27,14 +37,71 @@ public static void main(String[] args) throws Exception {
2737
// BSKY_IDENTIFIER
2838
// BSKY_HANDLE
2939
// SPRING_RELEASE_GCHAT_WEBHOOK_URL
30-
newWorkflow().run();
40+
41+
// Train Project Post Release
42+
// TRAIN_VERSIONS
43+
Main main = new Main();
44+
main.run();
3145
}
3246

33-
private static PostReleaseWorkflow newWorkflow() {
47+
void run() {
3448
ProcessRunner processRunner = new ProcessRunner();
35-
return new PostReleaseWorkflow(new ChangelogGeneratorDownloader(), new ChangelogGenerator(processRunner),
36-
new ChangelogFetcher(processRunner), new ChangelogProcessor(processRunner),
37-
new ReleaseNotesUpdater(processRunner), new MilestoneUpdater(processRunner), new NotificationSender());
49+
PostReleaseWorkflow postReleaseWorkflow = newPostReleaseWorkflow(processRunner);
50+
String githubOrgRepo = getGithubRepository();
51+
String githubRefName = getGithubRefName();
52+
String previousRefName = getPreviousRefName();
53+
String trainVersions = getTrainVersions();
54+
String artifactToCheck = System.getenv("ARTIFACT_TO_CHECK");
55+
56+
log.info("""
57+
!!!
58+
59+
@@@ MICROMETER RELEASE @@@
60+
61+
Processing following env variables:
62+
63+
GITHUB_REPOSITORY [%s]
64+
GITHUB_REF_NAME [%s]
65+
PREVIOUS_REF_NAME [%s]
66+
TRAIN_VERSIONS [%s]
67+
ARTIFACT_TO_CHECK [%s]
68+
69+
!!!
70+
""".formatted(githubOrgRepo, githubRefName, previousRefName, trainVersions, artifactToCheck));
71+
72+
if (trainVersions != null && !trainVersions.isBlank()) {
73+
log.info("Will proceed with train release...");
74+
trainReleaseWorkflow(githubOrgRepo, artifactToCheck, postReleaseWorkflow, processRunner).run(trainVersions);
75+
}
76+
else {
77+
log.info("Will proceed with single project post release workflow...");
78+
postReleaseWorkflow.run(githubOrgRepo, githubRefName, previousRefName);
79+
}
80+
}
81+
82+
String getGithubRepository() {
83+
return System.getenv("GITHUB_REPOSITORY");
84+
}
85+
86+
String getPreviousRefName() {
87+
return System.getenv("PREVIOUS_REF_NAME");
88+
}
89+
90+
String getGithubRefName() {
91+
return System.getenv("GITHUB_REF_NAME");
92+
}
93+
94+
String getTrainVersions() {
95+
return System.getenv("TRAIN_VERSIONS");
96+
}
97+
98+
ProjectTrainReleaseWorkflow trainReleaseWorkflow(String githubOrgRepo, String artifactToCheck,
99+
PostReleaseWorkflow postReleaseWorkflow, ProcessRunner processRunner) {
100+
return new ProjectTrainReleaseWorkflow(githubOrgRepo, artifactToCheck, processRunner, postReleaseWorkflow);
101+
}
102+
103+
PostReleaseWorkflow newPostReleaseWorkflow(ProcessRunner processRunner) {
104+
return new PostReleaseWorkflow(processRunner);
38105
}
39106

40107
}

src/main/java/io/micrometer/release/ProcessRunner.java src/main/java/io/micrometer/release/common/ProcessRunner.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.common;
1717

1818
import java.io.File;
1919

@@ -25,7 +25,7 @@
2525
import java.io.InputStreamReader;
2626
import java.util.*;
2727

28-
class ProcessRunner {
28+
public class ProcessRunner {
2929

3030
private static final Logger log = LoggerFactory.getLogger(ProcessRunner.class);
3131

@@ -35,24 +35,24 @@ class ProcessRunner {
3535

3636
private final Map<String, String> envVars = new HashMap<>();
3737

38-
ProcessRunner() {
38+
public ProcessRunner() {
3939
this.repo = null;
4040
}
4141

42-
ProcessRunner(String repo) {
42+
public ProcessRunner(String repo) {
4343
this.repo = repo;
4444
}
4545

46-
ProcessRunner withEnvVars(Map<String, String> envVars) {
46+
public ProcessRunner withEnvVars(Map<String, String> envVars) {
4747
this.envVars.putAll(envVars);
4848
return this;
4949
}
5050

51-
List<String> run(List<String> command) {
51+
public List<String> run(List<String> command) {
5252
return run(command.toArray(new String[0]));
5353
}
5454

55-
List<String> run(String... command) {
55+
public List<String> run(String... command) {
5656
List<String> lines = new ArrayList<>();
5757
String[] processedCommand = processCommand(command);
5858
try {
@@ -108,7 +108,7 @@ List<String> run(String... command) {
108108
return lines;
109109
}
110110

111-
Process startProcess(String[] processedCommand) throws IOException, InterruptedException {
111+
Process startProcess(String... processedCommand) throws IOException, InterruptedException {
112112
if (isGradleCommand(processedCommand)) {
113113
runGitConfig();
114114
}

src/main/java/io/micrometer/release/Changelog.java src/main/java/io/micrometer/release/single/Changelog.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

18-
import io.micrometer.release.ChangelogSection.Section;
18+
import io.micrometer.release.single.ChangelogSection.Section;
1919

2020
import java.io.File;
2121
import java.io.IOException;

src/main/java/io/micrometer/release/ChangelogFetcher.java src/main/java/io/micrometer/release/single/ChangelogFetcher.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

18+
import io.micrometer.release.common.ProcessRunner;
1819
import org.slf4j.Logger;
1920
import org.slf4j.LoggerFactory;
2021

src/main/java/io/micrometer/release/ChangelogGenerator.java src/main/java/io/micrometer/release/single/ChangelogGenerator.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
17+
18+
import io.micrometer.release.common.ProcessRunner;
1719

1820
import java.io.File;
1921

src/main/java/io/micrometer/release/ChangelogGeneratorDownloader.java src/main/java/io/micrometer/release/single/ChangelogGeneratorDownloader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

1818
import java.io.File;
1919
import java.net.URI;

src/main/java/io/micrometer/release/ChangelogProcessor.java src/main/java/io/micrometer/release/single/ChangelogProcessor.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

18-
import io.micrometer.release.ChangelogSection.Section;
18+
import io.micrometer.release.common.ProcessRunner;
19+
import io.micrometer.release.single.ChangelogSection.Section;
1920

2021
import java.io.*;
2122
import java.nio.file.Files;

src/main/java/io/micrometer/release/ChangelogSection.java src/main/java/io/micrometer/release/single/ChangelogSection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

1818
import java.util.*;
1919
import java.util.regex.Matcher;

src/main/java/io/micrometer/release/MilestoneIssueReassigner.java src/main/java/io/micrometer/release/single/MilestoneIssueReassigner.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

18-
import io.micrometer.release.MilestoneMigrator.Milestone;
18+
import io.micrometer.release.common.ProcessRunner;
19+
import io.micrometer.release.single.MilestoneMigrator.Milestone;
1920
import org.slf4j.Logger;
2021
import org.slf4j.LoggerFactory;
2122

src/main/java/io/micrometer/release/MilestoneMigrator.java src/main/java/io/micrometer/release/single/MilestoneMigrator.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
17+
18+
import io.micrometer.release.common.ProcessRunner;
1719

1820
import java.util.ArrayList;
1921
import java.util.List;

src/main/java/io/micrometer/release/MilestoneUpdater.java src/main/java/io/micrometer/release/single/MilestoneUpdater.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

18+
import io.micrometer.release.common.ProcessRunner;
1819
import org.slf4j.Logger;
1920
import org.slf4j.LoggerFactory;
2021

src/main/java/io/micrometer/release/MilestoneWithDeadline.java src/main/java/io/micrometer/release/single/MilestoneWithDeadline.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

1818
import java.time.LocalDate;
1919

src/main/java/io/micrometer/release/NotificationSender.java src/main/java/io/micrometer/release/single/NotificationSender.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
1717

1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;

src/main/java/io/micrometer/release/PostReleaseWorkflow.java src/main/java/io/micrometer/release/single/PostReleaseWorkflow.java

+28-23
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release;
16+
package io.micrometer.release.single;
17+
18+
import io.micrometer.release.common.ProcessRunner;
1719

1820
import java.io.File;
1921

20-
class PostReleaseWorkflow {
22+
public class PostReleaseWorkflow {
2123

2224
private final ChangelogGeneratorDownloader changelogGeneratorDownloader;
2325

@@ -46,12 +48,17 @@ class PostReleaseWorkflow {
4648
this.notificationSender = notificationSender;
4749
}
4850

49-
public void run() throws Exception {
50-
String githubOrgRepo = ghOrgRepo(); // micrometer-metrics/tracing
51-
String githubRefName = ghRef(); // v1.3.1
52-
String previousRefName = previousRefName(); // v1.2.5
53-
assertInputs(githubOrgRepo, githubRefName, previousRefName);
51+
public PostReleaseWorkflow(ProcessRunner processRunner) {
52+
this(new ChangelogGeneratorDownloader(), new ChangelogGenerator(processRunner),
53+
new ChangelogFetcher(processRunner), new ChangelogProcessor(processRunner),
54+
new ReleaseNotesUpdater(processRunner), new MilestoneUpdater(processRunner), new NotificationSender());
55+
}
5456

57+
// micrometer-metrics/tracing
58+
// v1.3.1
59+
// v1.2.5 (optional)
60+
public void run(String githubOrgRepo, String githubRefName, String previousRefName) {
61+
assertInputs(githubOrgRepo, githubRefName, previousRefName);
5562
String githubRepo = githubOrgRepo.contains("/") ? githubOrgRepo.split("/")[1] : githubOrgRepo;
5663

5764
// Step 1: Close milestone and move issues around
@@ -95,20 +102,13 @@ void assertInputs(String githubOrgRepo, String githubRefName, String previousRef
95102
}
96103
}
97104

98-
String ghRef() {
99-
return System.getenv("GITHUB_REF_NAME");
100-
}
101-
102-
String ghOrgRepo() {
103-
return System.getenv("GITHUB_REPOSITORY");
104-
}
105-
106-
String previousRefName() {
107-
return System.getenv("PREVIOUS_REF_NAME");
108-
}
109-
110-
private File downloadChangelogGenerator() throws Exception {
111-
return changelogGeneratorDownloader.downloadChangelogGenerator();
105+
private File downloadChangelogGenerator() {
106+
try {
107+
return changelogGeneratorDownloader.downloadChangelogGenerator();
108+
}
109+
catch (Exception e) {
110+
throw new IllegalStateException(e);
111+
}
112112
}
113113

114114
private File generateOldChangelog(String githubRefName, String githubOrgRepo) {
@@ -119,8 +119,13 @@ private File generateChangelog(String githubRefName, String githubOrgRepo, File
119119
return changelogGenerator.generateChangelog(githubRefName, githubOrgRepo, jarPath);
120120
}
121121

122-
private File processChangelog(File changelog, File oldChangelog) throws Exception {
123-
return changelogProcessor.processChangelog(changelog, oldChangelog);
122+
private File processChangelog(File changelog, File oldChangelog) {
123+
try {
124+
return changelogProcessor.processChangelog(changelog, oldChangelog);
125+
}
126+
catch (Exception e) {
127+
throw new IllegalStateException(e);
128+
}
124129
}
125130

126131
private void updateReleaseNotes(String refName, File changelog) {

0 commit comments

Comments
 (0)