Fixes milestone in -dependencies bom for ga or rc release. (#236)

* Updates isReleaseOrServiceRelease test for calver.

* clarifies test name

* Fixes milestone in -dependencies bom for ga or rc release.

Previously if there was a -M* or -RC* in a spring-cloud-*-dependencies/pom.xml this would be skipped. This was do to lines and java regex mismatches. The change moves to using Matcher.lookingAt() which only considers the start of the line, not the end.

Fixes gh-234
This commit is contained in:
Spencer Gibb
2021-03-15 10:13:54 -04:00
committed by GitHub
parent dd82284440
commit 3394310437
7 changed files with 587 additions and 13 deletions

View File

@@ -237,7 +237,7 @@ public class ProjectPomUpdater implements Closeable {
.stream()
.filter(pattern -> IGNORED_SNAPSHOT_LINE_PATTERNS.stream()
.noneMatch(line::matches)
&& pattern.matcher(line).matches())
&& pattern.matcher(line).lookingAt())
.findFirst().orElse(null);
if (matchingPattern != null) {
if (log.isDebugEnabled()) {

View File

@@ -54,7 +54,7 @@ public class ProjectVersion implements Comparable<ProjectVersion>, Serializable
private static final Pattern SNAPSHOT_PATTERN = Pattern
.compile("^.*[\\.|\\-](BUILD-)?SNAPSHOT.*$");
private static final String MILESTONE_REGEX = ".*[\\.|\\-]M[0-9]+";
private static final String MILESTONE_REGEX = "^.*[\\.|\\-]M[0-9]+.*$";
private static final String RC_REGEX = "^.*[\\.|\\-]RC.*$";

View File

@@ -115,7 +115,7 @@ public class PomUpdateAcceptanceTests {
}
@Test
public void should_not_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module()
public void should_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module()
throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
@@ -131,6 +131,61 @@ public class PomUpdateAcceptanceTests {
.hasMessageContaining("<version>0.3.1.BUILD-SNAPSHOT</version>");
}
@Test
public void should_fail_update_when_after_updating_a_release_version_there_still_is_a_milestone_version_in_a_non_deployable_module()
throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
Collections
.singletonList(MavenBomParserAccessor.maven(releaserProperties)));
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
projects.removeIf(projectVersion -> projectVersion.projectName
.contains("spring-cloud-build"));
projects.add(new ProjectVersion("spring-cloud-build", "1.4.2.RELEASE"));
File project = new File(this.temporaryFolder,
"/spring-cloud-sleuth-with-milestone-dep");
BDDAssertions
.thenThrownBy(() -> projectPomUpdater.updateProjectFromReleaseTrain(
project, projects, projects.forFile(project), true))
.hasMessageContaining("<zipkin.version>1.19.2-M2</zipkin.version>");
}
@Test
public void should_fail_update_when_after_updating_a_release_candidate_version_there_still_is_a_milestone_version_in_a_non_deployable_module()
throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
Collections
.singletonList(MavenBomParserAccessor.maven(releaserProperties)));
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
projects.removeIf(
projectVersion -> projectVersion.projectName.equals("spring-cloud"));
projects.add(new ProjectVersion("spring-cloud", "Camden.RC1"));
projects.removeIf(projectVersion -> projectVersion.projectName
.equals("spring-cloud-dependencies"));
projects.add(new ProjectVersion("spring-cloud-dependencies", "Camden.RC1"));
projects.removeIf(projectVersion -> projectVersion.projectName
.equals("spring-cloud-starter"));
projects.add(new ProjectVersion("spring-cloud-starter", "Camden.RC1"));
projects.removeIf(projectVersion -> projectVersion.projectName
.equals("spring-cloud-starter-build"));
projects.add(new ProjectVersion("spring-cloud-starter-build", "Camden.RC1"));
projects.removeIf(projectVersion -> projectVersion.projectName
.equals("spring-cloud-release"));
projects.add(new ProjectVersion("spring-cloud-release", "Camden.RC1"));
projects.removeIf(projectVersion -> projectVersion.projectName
.contains("spring-cloud-build"));
projects.add(new ProjectVersion("spring-cloud-build", "1.4.2.RELEASE"));
File project = new File(this.temporaryFolder,
"/spring-cloud-sleuth-with-milestone-dep");
BDDAssertions
.thenThrownBy(() -> projectPomUpdater.updateProjectFromReleaseTrain(
project, projects, projects.forFile(project), true))
.hasMessageContaining("<zipkin.version>1.19.2-M2</zipkin.version>");
}
@Test
public void should_update_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version_for_boot_snapshot_version()
throws Exception {

View File

@@ -35,7 +35,7 @@ import releaser.internal.git.GitRepoTests;
import releaser.internal.project.Project;
import releaser.internal.tech.PomReader;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.util.FileSystemUtils;
/**
@@ -44,7 +44,7 @@ import org.springframework.util.FileSystemUtils;
public class PomUpdaterTests {
@Rule
public OutputCapture capture = new OutputCapture();
public OutputCaptureRule capture = new OutputCaptureRule();
@Rule
public TemporaryFolder tmp = new TemporaryFolder();

View File

@@ -345,8 +345,10 @@ public class ProjectVersionTests {
public void should_return_true_when_checking_ga_version_against_ga() {
then(projectVersion("1.0.1.RELEASE").isReleaseOrServiceRelease()).isTrue();
then(projectVersion("1.0.1-SR1").isReleaseOrServiceRelease()).isTrue();
// then(projectVersion("1.0.0").isReleaseOrServiceRelease()).isTrue();
// then(projectVersion("1.0.1").isReleaseOrServiceRelease()).isTrue();
then(projectVersion("1.0.0").isReleaseOrServiceRelease()).isTrue();
then(projectVersion("1.0.1").isReleaseOrServiceRelease()).isTrue();
then(projectVersion("2021.0.0").isReleaseOrServiceRelease()).isTrue();
then(projectVersion("2022.0.3").isReleaseOrServiceRelease()).isTrue();
}
@Test
@@ -837,15 +839,25 @@ public class ProjectVersionTests {
then(unknownTypeOfVersion.get(1).pattern()).contains("M[0-9]");
then(unknownTypeOfVersion.get(2).pattern()).contains("RC");
then(unknownTypeOfVersion.get(0).matcher("SomeName-SNAPSHOT").matches()).isTrue();
then(unknownTypeOfVersion.get(0).matcher("SomeName.BUILD-SNAPSHOT").matches())
then(unknownTypeOfVersion.get(0).matcher("SomeName-SNAPSHOT").lookingAt())
.isTrue();
then(unknownTypeOfVersion.get(0).matcher("SomeName.BUILD-SNAPSHOT").lookingAt())
.isTrue();
then(unknownTypeOfVersion.get(0)
.matcher("\t\t<version>1.19.2-SNAPSHOT</version>\n").lookingAt())
.isTrue();
then(unknownTypeOfVersion.get(1).matcher("SomeName-M3").matches()).isTrue();
then(unknownTypeOfVersion.get(1).matcher("SomeName.M3").matches()).isTrue();
then(unknownTypeOfVersion.get(1).matcher("SomeName-M3").lookingAt()).isTrue();
then(unknownTypeOfVersion.get(1).matcher("SomeName.M3").lookingAt()).isTrue();
then(unknownTypeOfVersion.get(1)
.matcher("\t\t<zipkin.version>1.19.2-M2</zipkin.version>\n").lookingAt())
.isTrue();
then(unknownTypeOfVersion.get(2).matcher("SomeName-RC3").matches()).isTrue();
then(unknownTypeOfVersion.get(2).matcher("SomeName.RC3").matches()).isTrue();
then(unknownTypeOfVersion.get(2).matcher("SomeName-RC3").lookingAt()).isTrue();
then(unknownTypeOfVersion.get(2).matcher("SomeName.RC3").lookingAt()).isTrue();
then(unknownTypeOfVersion.get(2)
.matcher("<zipkin.version>1.19.2-RC1</zipkin.version>").lookingAt())
.isTrue();
}
private ProjectVersion projectVersion(String version) {

View File

@@ -0,0 +1,368 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-sleuth</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Sleuth</name>
<description>Spring Cloud Sleuth</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>1.4.2</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<scm>
<url>https://github.com/spring-cloud/spring-cloud-sleuth</url>
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-sleuth.git</connection>
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-sleuth.git</developerConnection>
<tag>HEAD</tag>
</scm>
<modules>
<module>spring-cloud-sleuth-dependencies</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArguments>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</compilerArguments>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArguments>
<source>${maven.compiler.testSource}</source>
<target>${maven.compiler.testTarget}</target>
</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>${maven.compiler.testTarget}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-tools</artifactId>
<version>${spring-cloud-build.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-dependencies</artifactId>
<version>${spring-cloud-netflix.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons-dependencies</artifactId>
<version>${spring-cloud-commons.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-dependencies</artifactId>
<version>${spring-cloud-stream.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spock -->
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>${spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-spring</artifactId>
<version>${spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.1</version>
<!-- not test because we need it in stream -->
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
<maven.compiler.testSource>1.8</maven.compiler.testSource>
<surefire.plugin.version>2.19.1</surefire.plugin.version>
<checkstyle.version>2.17</checkstyle.version>
<spring-cloud-build.version>0.3.1-SNAPSHOT</spring-cloud-build.version>
<spring-cloud-commons.version>0.2.0-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-stream.version>Foo-SNAPSHOT</spring-cloud-stream.version>
<spring-cloud-netflix.version>0.3.0-SNAPSHOT</spring-cloud-netflix.version>
</properties>
<profiles>
<profile>
<id>spring</id>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>ide</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.testSource}</source>
<target>${maven.compiler.testTarget}</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>benchmarks</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
<module>benchmarks</module>
</modules>
</profile>
<profile>
<id>sonar</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>1.4.2</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-sleuth-dependencies</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>spring-cloud-sleuth-dependencies</name>
<description>Spring Cloud Sleuth Dependencies</description>
<properties>
<zipkin.version>1.19.2-M2</zipkin.version>
<zipkin-reporter.version>0.6.12</zipkin-reporter.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-stream</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>${zipkin.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>${zipkin.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>${zipkin.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
<version>${zipkin.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-junit</artifactId>
<version>${zipkin.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.reporter</groupId>
<artifactId>zipkin-reporter</artifactId>
<version>${zipkin-reporter.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>spring</id>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>