#7 - Added support to update project information on spring.io.
This commit introduces a command "sagan update …" to take a comma-separated list of release train names that are supported. The implementation will find the latest releases by inspecting the Git tags and the creating the necessary project metadata information. The code will then wipe the existing metadata and PUT the current information to the server.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2017 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.sagan;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MaintainedVersion}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class MaintainedVersionUnitTests {
|
||||
|
||||
@Test
|
||||
public void newerVersionIsOrderedFirst() {
|
||||
|
||||
MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"),
|
||||
ReleaseTrains.INGALLS);
|
||||
MaintainedVersion hopper = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.12.0.RELEASE"),
|
||||
ReleaseTrains.HOPPER);
|
||||
|
||||
assertThat(ingalls.compareTo(hopper)).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2017 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.sagan;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MaintainedVersions}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class MaintainedVersionsUnitTests {
|
||||
|
||||
@Test
|
||||
public void considersMostRecentReleaseVersionTheMainOne() {
|
||||
|
||||
MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"),
|
||||
ReleaseTrains.INGALLS);
|
||||
MaintainedVersion hopper = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.12.0.RELEASE"),
|
||||
ReleaseTrains.HOPPER);
|
||||
|
||||
MaintainedVersions versions = MaintainedVersions.of(ingalls, hopper);
|
||||
|
||||
assertThat(versions.isMainVersion(ingalls)).isTrue();
|
||||
assertThat(versions.isMainVersion(hopper)).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2017 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.sagan;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
|
||||
/**
|
||||
* Tests for serialization of {@link ProjectMetadata}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class ProjectMetadataSerializationTests {
|
||||
|
||||
@Test
|
||||
public void serializesMaintainedVersionsIntoProjectMetadata() throws Exception {
|
||||
|
||||
ObjectWriter mapper = new ObjectMapper().writerWithDefaultPrettyPrinter();
|
||||
|
||||
MaintainedVersion kay = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("2.0.0.RC1"), ReleaseTrains.KAY);
|
||||
MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.5.RELEASE"),
|
||||
ReleaseTrains.INGALLS);
|
||||
MaintainedVersion ingallsSnapshot = ingalls.nextDevelopmentVersion();
|
||||
MaintainedVersion hopper = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.12.8.RELEASE"),
|
||||
ReleaseTrains.HOPPER);
|
||||
|
||||
MaintainedVersions versions = MaintainedVersions.of(kay, ingalls, ingallsSnapshot, hopper);
|
||||
|
||||
System.out.println(mapper.writeValueAsString(new ProjectMetadata(kay, versions)));
|
||||
System.out.println(mapper.writeValueAsString(new ProjectMetadata(ingallsSnapshot, versions)));
|
||||
System.out.println(mapper.writeValueAsString(new ProjectMetadata(ingalls, versions)));
|
||||
System.out.println(mapper.writeValueAsString(new ProjectMetadata(hopper, versions)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2017 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.sagan;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SaganOperations}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class SaganOperationsIntegrationTests extends AbstractIntegrationTests {
|
||||
|
||||
@Autowired SaganOperations sagan;
|
||||
@Autowired SaganClient client;
|
||||
|
||||
@Test
|
||||
public void detectVersionsToUpdate() {
|
||||
|
||||
sagan.findVersions(ReleaseTrains.LOVELACE, ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
|
||||
.forEach((project, versions) -> {
|
||||
|
||||
System.out.println(project.getName());
|
||||
System.out.println("-----");
|
||||
|
||||
versions.forEach(version -> {
|
||||
|
||||
String output = version.toString();
|
||||
System.out.println(versions.isMainVersion(version) ? output.concat(" (main release)") : output);
|
||||
});
|
||||
|
||||
System.out.println();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateVersions() {
|
||||
sagan.updateProjectMetadata(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateJpa() {
|
||||
|
||||
MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
|
||||
.get(Projects.JPA);
|
||||
|
||||
System.out.println(versions);
|
||||
|
||||
client.updateProjectMetadata(Projects.JPA, versions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJpa() {
|
||||
System.out.println(client.getProjectMetadata(Projects.JPA));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBuild() {
|
||||
|
||||
MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
|
||||
.get(Projects.BUILD);
|
||||
|
||||
client.updateProjectMetadata(Projects.BUILD, versions);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user