Skip to content

Commit f2efcde

Browse files
Moved dependency verification to pre release
1 parent edf6735 commit f2efcde

22 files changed

+366
-198
lines changed

src/e2eTest/java/io/micrometer/release/single/SingleProjectGithubActionsE2eTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import io.micrometer.release.common.GithubActions;
20-
import io.micrometer.release.common.ReleaseDateCalculator;
2120
import org.junit.jupiter.api.BeforeAll;
2221
import org.junit.jupiter.api.Test;
2322

src/e2eTest/java/io/micrometer/release/train/TrainGithubActionsE2eTests.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.fasterxml.jackson.core.JsonProcessingException;
1919
import io.micrometer.release.common.GithubActions;
20-
import io.micrometer.release.common.ReleaseDateCalculator;
2120
import org.junit.jupiter.api.BeforeAll;
2221
import org.junit.jupiter.api.Test;
2322
import org.junit.jupiter.params.ParameterizedTest;
@@ -120,7 +119,7 @@ void should_verify_next_milestone(String next, String previous) throws JsonProce
120119
Milestone milestone = githubClient.getMilestoneByTitle(next);
121120

122121
assertThat(milestone.state()).isEqualTo("open");
123-
assertThat(milestone.dueOn()).isEqualTo(ReleaseDateCalculator.calculateDueDate(LocalDate.now()));
122+
assertThat(milestone.dueOn()).isEqualTo(calculateDueDate(LocalDate.now()));
124123
List<Issue> issues = githubClient.getIssuesForMilestone(milestone.number());
125124
assertThat(issues).extracting(Issue::state).containsOnly("open");
126125
assertThat(issues).extracting(Issue::title).containsOnly("Open issue in concrete " + previous);
@@ -142,4 +141,15 @@ private static void runTrainPostReleaseWorkflow() {
142141
"train_versions=0.1.1,0.2.0-M2,1.0.0-RC1", "-f", "artifact_to_check=micrometer-bom"));
143142
}
144143

144+
private static LocalDate calculateDueDate(LocalDate now) {
145+
// Go to first day of the next month
146+
LocalDate nextMonth = now.withDayOfMonth(1).plusMonths(1);
147+
148+
// Find first Monday
149+
LocalDate firstMonday = nextMonth.plusDays((8 - nextMonth.getDayOfWeek().getValue()) % 7);
150+
151+
// Add a week to get to second Monday
152+
return firstMonday.plusWeeks(1);
153+
}
154+
145155
}

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.micrometer.release;
1717

18+
import io.micrometer.release.common.Input;
1819
import io.micrometer.release.common.ProcessRunner;
1920
import io.micrometer.release.single.PostReleaseWorkflow;
2021
import io.micrometer.release.train.ProjectTrainReleaseWorkflow;
@@ -47,7 +48,7 @@ public static void main(String[] args) throws Exception {
4748
void run() {
4849
ProcessRunner processRunner = new ProcessRunner();
4950
PostReleaseWorkflow postReleaseWorkflow = newPostReleaseWorkflow(processRunner);
50-
String githubOrgRepo = getGithubRepository();
51+
String githubOrgRepo = getGithubOrgRepository();
5152
String githubRefName = getGithubRefName();
5253
String previousRefName = getPreviousRefName();
5354
String trainVersions = getTrainVersions();
@@ -79,20 +80,20 @@ void run() {
7980
}
8081
}
8182

82-
String getGithubRepository() {
83-
return System.getenv("GITHUB_REPOSITORY");
83+
String getGithubOrgRepository() {
84+
return Input.getGithubOrgRepository();
8485
}
8586

8687
String getPreviousRefName() {
87-
return System.getenv("PREVIOUS_REF_NAME");
88+
return Input.getPreviousRefName();
8889
}
8990

9091
String getGithubRefName() {
91-
return System.getenv("GITHUB_REF_NAME");
92+
return Input.getGithubRefName();
9293
}
9394

9495
String getTrainVersions() {
95-
return System.getenv("TRAIN_VERSIONS");
96+
return Input.getTrainVersions();
9697
}
9798

9899
ProjectTrainReleaseWorkflow trainReleaseWorkflow(String githubOrgRepo, String artifactToCheck,

src/main/java/io/micrometer/release/single/Dependency.java src/main/java/io/micrometer/release/common/Dependency.java

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

18-
record Dependency(String group, String artifact, String version, boolean toIgnore) {
18+
public record Dependency(String group, String artifact, String version, boolean toIgnore) {
1919

2020
}

src/main/java/io/micrometer/release/single/GradleParser.java src/main/java/io/micrometer/release/common/GradleParser.java

+6-22
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.micrometer.release.single;
17-
18-
import io.micrometer.release.common.ProcessRunner;
19-
20-
import java.util.concurrent.atomic.AtomicReference;
16+
package io.micrometer.release.common;
2117

2218
import org.slf4j.Logger;
2319
import org.slf4j.LoggerFactory;
@@ -27,27 +23,20 @@
2723
import java.util.List;
2824
import java.util.Set;
2925

30-
class GradleParser {
26+
public class GradleParser {
3127

3228
private static final Logger log = LoggerFactory.getLogger(GradleParser.class);
3329

3430
private final List<String> excludedDependencyScopes = List.of("testCompile", "testImplementation", "checkstyle",
3531
"runtime", "nohttp", "testRuntime", "optional");
3632

37-
private final AtomicReference<Set<Dependency>> dependenciesCache = new AtomicReference<>();
38-
3933
private final ProcessRunner processRunner;
4034

41-
GradleParser(ProcessRunner processRunner) {
35+
public GradleParser(ProcessRunner processRunner) {
4236
this.processRunner = processRunner;
4337
}
4438

45-
Set<Dependency> fetchAllDependencies() {
46-
Set<Dependency> cachedDependencies = dependenciesCache.get();
47-
if (cachedDependencies != null) {
48-
log.info("Returned cached dependencies");
49-
return cachedDependencies;
50-
}
39+
public Set<Dependency> fetchAllDependencies() {
5140
log.info("Fetching test and optional dependencies...");
5241
List<String> projectLines = projectLines();
5342
List<String> subprojects = projectLines.stream()
@@ -94,14 +83,9 @@ else if (line.isEmpty() || line.isBlank()) {
9483
}
9584
}
9685
}
97-
dependenciesCache.set(dependencies);
9886
return dependencies;
9987
}
10088

101-
void clearCache() {
102-
dependenciesCache.set(null);
103-
}
104-
10589
static String extractVersion(String line) {
10690
if (line == null || line.trim().isEmpty()) {
10791
return null;
@@ -123,11 +107,11 @@ static String extractVersion(String line) {
123107
return null;
124108
}
125109

126-
List<String> dependenciesLines(List<String> gradleCommand) {
110+
public List<String> dependenciesLines(List<String> gradleCommand) {
127111
return processRunner.runSilently(gradleCommand);
128112
}
129113

130-
List<String> projectLines() {
114+
public List<String> projectLines() {
131115
return processRunner.runSilently("./gradlew", "projects");
132116
}
133117

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 Broadcom.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micrometer.release.common;
17+
18+
public class Input {
19+
20+
public static void assertInputs(String githubOrgRepo, String githubRefName, String previousRefName) {
21+
if (githubOrgRepo == null) {
22+
throw new IllegalStateException("No repo found, please provide the GITHUB_REPOSITORY env variable");
23+
}
24+
if (githubRefName == null) {
25+
throw new IllegalStateException("No github ref found, please provide the GITHUB_REF_NAME env variable");
26+
}
27+
if (!githubRefName.startsWith("v")) {
28+
throw new IllegalStateException("Github ref must be a tag (must start with 'v'): " + githubRefName);
29+
}
30+
if (previousRefName != null && !previousRefName.isBlank() && !previousRefName.startsWith("v")) {
31+
throw new IllegalStateException(
32+
"Previous github ref must be a tag (must start with 'v'): " + previousRefName);
33+
}
34+
}
35+
36+
public static String getGithubOrgRepository() {
37+
return System.getenv("GITHUB_REPOSITORY");
38+
}
39+
40+
public static String getPreviousRefName() {
41+
return System.getenv("PREVIOUS_REF_NAME");
42+
}
43+
44+
public static String getGithubRefName() {
45+
return System.getenv("GITHUB_REF_NAME");
46+
}
47+
48+
public static String getTrainVersions() {
49+
return System.getenv("TRAIN_VERSIONS");
50+
}
51+
52+
}

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
*/
1616
package io.micrometer.release.common;
1717

18-
import java.io.File;
19-
2018
import org.slf4j.Logger;
2119
import org.slf4j.LoggerFactory;
2220

2321
import java.io.BufferedReader;
22+
import java.io.File;
2423
import java.io.IOException;
2524
import java.io.InputStreamReader;
2625
import java.util.*;
@@ -33,14 +32,21 @@ public class ProcessRunner {
3332

3433
private final String repo;
3534

35+
private final File directory;
36+
3637
private final Map<String, String> envVars = new HashMap<>();
3738

3839
public ProcessRunner() {
39-
this.repo = null;
40+
this(null, null);
4041
}
4142

4243
public ProcessRunner(String repo) {
44+
this(repo, null);
45+
}
46+
47+
public ProcessRunner(String repo, File directory) {
4348
this.repo = repo;
49+
this.directory = directory;
4450
}
4551

4652
public ProcessRunner withEnvVars(Map<String, String> envVars) {
@@ -133,6 +139,9 @@ void log(String logLine) {
133139
Process startProcess(String... processedCommand) throws IOException, InterruptedException {
134140
runGitConfig();
135141
ProcessBuilder processBuilder = new ProcessBuilder(processedCommand).redirectErrorStream(false);
142+
if (directory != null) {
143+
processBuilder.directory(directory);
144+
}
136145
return doStartProcess(processBuilder);
137146
}
138147

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

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package io.micrometer.release.single;
1717

18+
import io.micrometer.release.common.Dependency;
19+
import io.micrometer.release.common.GradleParser;
1820
import io.micrometer.release.common.ProcessRunner;
1921
import io.micrometer.release.single.ChangelogSection.Section;
2022
import org.slf4j.Logger;

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

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.micrometer.release.single;
1717

1818
import io.micrometer.release.common.ProcessRunner;
19-
import io.micrometer.release.common.ReleaseDateCalculator;
2019
import io.micrometer.release.single.MilestoneMigrator.Milestone;
2120
import org.slf4j.Logger;
2221
import org.slf4j.LoggerFactory;

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

+9-36
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616
package io.micrometer.release.single;
1717

18+
import io.micrometer.release.common.Input;
1819
import io.micrometer.release.common.ProcessRunner;
1920

2021
import java.io.File;
2122

2223
public class PostReleaseWorkflow {
2324

24-
private final DependencyVerifier dependencyVerifier;
25-
2625
private final ChangelogGeneratorDownloader changelogGeneratorDownloader;
2726

2827
private final ChangelogGenerator changelogGenerator;
@@ -37,12 +36,10 @@ public class PostReleaseWorkflow {
3736

3837
private final NotificationSender notificationSender;
3938

40-
PostReleaseWorkflow(DependencyVerifier dependencyVerifier,
41-
ChangelogGeneratorDownloader changelogGeneratorDownloader, ChangelogGenerator changelogGenerator,
42-
ChangelogFetcher changelogFetcher, ChangelogProcessor changelogProcessor,
43-
ReleaseNotesUpdater releaseNotesUpdater, MilestoneUpdater milestoneUpdater,
44-
NotificationSender notificationSender) {
45-
this.dependencyVerifier = dependencyVerifier;
39+
PostReleaseWorkflow(ChangelogGeneratorDownloader changelogGeneratorDownloader,
40+
ChangelogGenerator changelogGenerator, ChangelogFetcher changelogFetcher,
41+
ChangelogProcessor changelogProcessor, ReleaseNotesUpdater releaseNotesUpdater,
42+
MilestoneUpdater milestoneUpdater, NotificationSender notificationSender) {
4643
this.changelogGeneratorDownloader = changelogGeneratorDownloader;
4744
this.changelogGenerator = changelogGenerator;
4845
this.changelogFetcher = changelogFetcher;
@@ -53,22 +50,18 @@ public class PostReleaseWorkflow {
5350
}
5451

5552
public PostReleaseWorkflow(ProcessRunner processRunner) {
56-
this(new DependencyVerifier(processRunner), new ChangelogGeneratorDownloader(),
57-
new ChangelogGenerator(processRunner), new ChangelogFetcher(processRunner),
58-
new ChangelogProcessor(processRunner), new ReleaseNotesUpdater(processRunner),
59-
new MilestoneUpdater(processRunner), new NotificationSender());
53+
this(new ChangelogGeneratorDownloader(), new ChangelogGenerator(processRunner),
54+
new ChangelogFetcher(processRunner), new ChangelogProcessor(processRunner),
55+
new ReleaseNotesUpdater(processRunner), new MilestoneUpdater(processRunner), new NotificationSender());
6056
}
6157

6258
// micrometer-metrics/tracing
6359
// v1.3.1
6460
// v1.2.5 (optional)
6561
public void run(String githubOrgRepo, String githubRefName, String previousRefName) {
66-
assertInputs(githubOrgRepo, githubRefName, previousRefName);
62+
Input.assertInputs(githubOrgRepo, githubRefName, previousRefName);
6763
String githubRepo = githubOrgRepo.contains("/") ? githubOrgRepo.split("/")[1] : githubOrgRepo;
6864

69-
// Run dependabot and wait for it to complete
70-
verifyDependencies(githubOrgRepo);
71-
7265
// Close milestone and move issues around
7366
MilestoneWithDeadline newMilestoneId = updateMilestones(githubRefName);
7467

@@ -94,26 +87,6 @@ public void run(String githubOrgRepo, String githubRefName, String previousRefNa
9487
sendNotifications(githubRepo, githubRefName, newMilestoneId);
9588
}
9689

97-
private void verifyDependencies(String githubOrgRepo) {
98-
dependencyVerifier.verifyDependencies(githubOrgRepo);
99-
}
100-
101-
void assertInputs(String githubOrgRepo, String githubRefName, String previousRefName) {
102-
if (githubOrgRepo == null) {
103-
throw new IllegalStateException("No repo found, please provide the GITHUB_REPOSITORY env variable");
104-
}
105-
if (githubRefName == null) {
106-
throw new IllegalStateException("No github ref found, please provide the GITHUB_REF_NAME env variable");
107-
}
108-
if (!githubRefName.startsWith("v")) {
109-
throw new IllegalStateException("Github ref must be a tag (must start with 'v'): " + githubRefName);
110-
}
111-
if (previousRefName != null && !previousRefName.isBlank() && !previousRefName.startsWith("v")) {
112-
throw new IllegalStateException(
113-
"Previous github ref must be a tag (must start with 'v'): " + previousRefName);
114-
}
115-
}
116-
11790
private File downloadChangelogGenerator() {
11891
try {
11992
return changelogGeneratorDownloader.downloadChangelogGenerator();

src/main/java/io/micrometer/release/common/ReleaseDateCalculator.java src/main/java/io/micrometer/release/single/ReleaseDateCalculator.java

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

1818
import java.time.LocalDate;
1919

2020
/**
2121
* Always second Monday of the next month
2222
*/
23-
public class ReleaseDateCalculator {
23+
class ReleaseDateCalculator {
2424

25-
public static LocalDate calculateDueDate(LocalDate now) {
25+
static LocalDate calculateDueDate(LocalDate now) {
2626
// Go to first day of the next month
2727
LocalDate nextMonth = now.withDayOfMonth(1).plusMonths(1);
2828

0 commit comments

Comments
 (0)