Moved release tool into dedicated sub-folder.

This commit is contained in:
Oliver Gierke
2015-07-07 08:30:23 +02:00
commit d2beb0bd7a
88 changed files with 7066 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Oliver Gierke
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = TestConfig.class)
public abstract class AbstractIntegrationTests {
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.release.maven.Artifact;
import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ReleaseTrains;
/**
* @author Oliver Gierke
*/
public class ArtifactUnitTests {
@Test
public void testname() {
Artifact artifact = new Artifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "JPA"));
assertThat(artifact.getArtifactId(), is("spring-data-jpa"));
assertThat(artifact.getVersion(), is(ArtifactVersion.parse("1.6.0.M1")));
assertThat(artifact.getNextDevelopmentVersion(), is(ArtifactVersion.parse("1.6.0.BUILD-SNAPSHOT")));
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author Oliver Gierke
*/
@Configuration
@ComponentScan
public class TestConfig {
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.cli;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.git.GitOperations;
import org.springframework.data.release.model.ReleaseTrains;
/**
* @author Oliver Gierke
*/
public class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests {
@Autowired ReleaseCommands releaseCommands;
@Autowired GitOperations git;
@Test
public void predictsReleaseTrainCorrectly() throws Exception {
git.update(ReleaseTrains.DIJKSTRA);
assertThat(releaseCommands.predictTrainAndIteration(), is("Dijkstra"));
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.git;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.IterationVersion;
import org.springframework.data.release.model.SimpleIterationVersion;
import org.springframework.data.release.model.Version;
/**
* @author Oliver Gierke
*/
public class BranchUnitTests {
@Test
public void testname() {
IterationVersion iterationVersion = new SimpleIterationVersion(new Version(1, 4), Iteration.RC1);
assertThat(Branch.from(iterationVersion).toString(), is("master"));
}
@Test
public void createsBugfixBranchForServiceRelease() {
IterationVersion iterationVersion = new SimpleIterationVersion(new Version(1, 4), Iteration.SR1);
assertThat(Branch.from(iterationVersion).toString(), is("1.4.x"));
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.git;
import static org.springframework.data.release.model.Projects.*;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.ReleaseTrains;
import org.springframework.util.StringUtils;
/**
* @author Oliver Gierke
*/
public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
@Autowired GitOperations gitOperations;
@Test
@Ignore
public void testname() throws Exception {
gitOperations.update(ReleaseTrains.CODD);
}
@Test
@Ignore
public void showTags() throws Exception {
Tags tags = gitOperations.getTags(COMMONS);
System.out.println(StringUtils.collectionToDelimitedString(tags.asList(), "\n"));
}
@Test
public void foo() throws Exception {
gitOperations.update(ReleaseTrains.EVANS);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.git;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.release.model.ReleaseTrains;
import org.springframework.data.release.model.Train;
/**
* @author Oliver Gierke
*/
public class GitProjectUnitTests {
@Test
public void testname() {
Train codd = ReleaseTrains.CODD;
GitProject project = new GitProject(codd.getModule("Commons").getProject(), new GitServer());
assertThat(project.getProjectUri(), is("https://www.github.com/spring-projects/spring-data-commons"));
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.io;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.Projects;
/**
* @author Oliver Gierke
*/
public class CommonsExecOsCommandOperationsIntegegrationTests extends AbstractIntegrationTests {
@Autowired OsCommandOperations operations;
@Test
public void testname() throws Exception {
// CommandResult result = operations
// .executeCommand("export GIT_TRACE=1 && git clone https://github.com/spring-projects/spring-data-build").get();
// CommandResult result = operations.executeCommand("git pull", Projects.BUILD).get();
CommandResult result = operations.executeCommand("git remote -v", Projects.BUILD).get();
// .get();
if (result.hasError()) {
System.out.println(result.getStatus());
System.out.println(result.getOutput());
System.out.println(result.getException().getMessage());
throw result.getException();
} else {
System.out.println(result.getOutput());
}
assertThat(result.hasError(), is(false));
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.jira;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.ReleaseTrains;
/**
* Unit tests for {@link JiraVersion}.
*
* @author Oliver Gierke
*/
public class JiraVersionUnitTests {
@Test
public void rendersJiraGaVersionCorrectly() {
assertIterationVersion(Iteration.M1, "1.8 M1 (Dijkstra)");
assertIterationVersion(Iteration.RC1, "1.8 RC1 (Dijkstra)");
assertIterationVersion(Iteration.GA, "1.8 GA (Dijkstra)");
assertIterationVersion(Iteration.SR1, "1.8.1 (Dijkstra SR1)");
assertIterationVersion(Iteration.SR2, "1.8.2 (Dijkstra SR2)");
assertIterationVersion(Iteration.SR3, "1.8.3 (Dijkstra SR3)");
assertIterationVersion(Iteration.SR4, "1.8.4 (Dijkstra SR4)");
}
@Test
public void usesCustomModuleIterationStartVersion() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "Elasticsearch");
JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is("1.0 M2 (Dijkstra)"));
}
@Test
public void doesNotUseCustomIterationOnNonFirstiterations() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.RC1, "Elasticsearch");
JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is("1.0 RC1 (Dijkstra)"));
}
private void assertIterationVersion(Iteration iteration, String expected) {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(iteration, "Commons");
JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is(expected));
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.maven;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.io.Workspace;
import org.springframework.data.release.model.ArtifactVersion;
import org.xmlbeam.ProjectionFactory;
import org.xmlbeam.io.XBFileIO;
/**
* @author Oliver Gierke
*/
public class MavenIntegrationTests extends AbstractIntegrationTests {
@Autowired Workspace workspace;
@Autowired ProjectionFactory projection;
public @Rule TemporaryFolder folder = new TemporaryFolder();
@Test
public void modifiesParentPomCorrectly() throws IOException {
XBFileIO io = projection.io().file(new ClassPathResource("parent-pom.xml").getFile());
ParentPom pom = io.read(ParentPom.class);
pom.setSharedResourcesVersion(ArtifactVersion.parse("1.2.0.RELEASE"));
// System.out.println(projection.asString(pom));
}
@Test
public void updatesRepositoriesCorrectly() throws Exception {
XBFileIO io = projection.io().file(new ClassPathResource("sample-pom.xml").getFile());
Pom pom = io.read(Pom.class);
pom.setRepositoryId("spring-libs-snapshot", "spring-libs-release");
pom.setRepositoryUrl("spring-libs-release", "https://repo.spring.io/libs-release");
// System.out.println(projection.asString(pom));
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.model;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.IterationVersion;
import org.springframework.data.release.model.Version;
/**
* @author Oliver Gierke
*/
public class ArtifactVersionUnitTests {
@Test(expected = IllegalArgumentException.class)
public void rejectsInvalidVersionSuffix() {
ArtifactVersion.parse("1.4.5.GA");
}
@Test
public void parsesReleaseVersionCorrectly() {
ArtifactVersion version = ArtifactVersion.parse("1.4.5.RELEASE");
assertThat(version.isReleaseVersion(), is(true));
assertThat(version.getNextDevelopmentVersion(), is(ArtifactVersion.parse("1.4.6.BUILD-SNAPSHOT")));
}
@Test
public void createsMilestoneVersionCorrectly() {
ArtifactVersion version = ArtifactVersion.parse("1.4.5.M1");
assertThat(version.isReleaseVersion(), is(false));
assertThat(version.isMilestoneVersion(), is(true));
}
@Test
public void createsReleaseVersionByDefault() {
ArtifactVersion version = new ArtifactVersion(new Version(1, 4, 5));
assertThat(version.isReleaseVersion(), is(true));
assertThat(version.toString(), is("1.4.5.RELEASE"));
}
@Test
public void createsMilestoneVersionFromIteration() {
IterationVersion oneFourMilestoneOne = new SimpleIterationVersion(new Version(1, 4), Iteration.M1);
ArtifactVersion version = ArtifactVersion.from(oneFourMilestoneOne);
assertThat(version.isMilestoneVersion(), is(true));
assertThat(version.toString(), is("1.4.0.M1"));
}
@Test
public void createsReleaseVersionFromIteration() {
IterationVersion oneFourGA = new SimpleIterationVersion(new Version(1, 4), Iteration.GA);
ArtifactVersion version = ArtifactVersion.from(oneFourGA);
assertThat(version.isReleaseVersion(), is(true));
assertThat(version.toString(), is("1.4.0.RELEASE"));
}
@Test
public void createsServiceReleaseVersionFromIteration() {
IterationVersion oneFourServiceReleaseTwo = new SimpleIterationVersion(new Version(1, 4), Iteration.SR2);
ArtifactVersion version = ArtifactVersion.from(oneFourServiceReleaseTwo);
assertThat(version.isReleaseVersion(), is(true));
assertThat(version.toString(), is("1.4.2.RELEASE"));
}
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.model;
/**
*
* @author Oliver Gierke
*/
public class IterationUnitTests {
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.model;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
/**
* @author Oliver Gierke
*/
public class ModuleIterationUnitTests {
@Test
public void abbreviatesTrailingZerosForNonServiceReleases() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.M1);
ModuleIteration module = iteration.getModule(Projects.JPA);
assertThat(module.getVersionString(), is("1.6 M1"));
}
@Test
public void doesNotListIterationSuffixForServiceReleases() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.SR1);
ModuleIteration module = iteration.getModule(Projects.JPA);
assertThat(module.getVersionString(), is("1.6.1"));
}
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.release.model;
import lombok.Value;
@Value
public class SimpleIterationVersion implements IterationVersion {
private final Version version;
private final Iteration iteration;
}