Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
Closes gh-24500
  • Loading branch information
mbhave committed Dec 14, 2020
2 parents 26e7e61 + 822ae0d commit e5e654c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public void run(ApplicationArguments args) throws Exception {
String version = nonOptionArgs.get(2);
boolean makeDefault = false;
if (nonOptionArgs.size() == 4) {
String releaseBranch = nonOptionArgs.get(3);
makeDefault = ("master".equals(releaseBranch));
makeDefault = Boolean.parseBoolean(nonOptionArgs.get(3));
}
this.service.publish(version, makeDefault);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void broadcast(String version) {
private void makeDefault(String version) {
logger.debug("Making this version the default");
Request request = new Request(version);
RequestEntity<Request> requestEntity = RequestEntity.post(URI.create(SDKMAN_URL + "default"))
RequestEntity<Request> requestEntity = RequestEntity.put(URI.create(SDKMAN_URL + "default"))
.header(CONSUMER_KEY_HEADER, this.properties.getConsumerKey())
.header(CONSUMER_TOKEN_HEADER, this.properties.getConsumerToken())
.contentType(MediaType.APPLICATION_JSON).body(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,36 @@ void setup() {
@Test
void runWhenReleaseTypeNotSpecifiedShouldThrowException() throws Exception {
Assertions.assertThatIllegalStateException()
.isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishGradlePlugin")));
.isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishToSdkman")));
}

@Test
void runWhenVersionNotSpecifiedShouldThrowException() throws Exception {
Assertions.assertThatIllegalStateException()
.isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "RELEASE")));
.isThrownBy(() -> this.command.run(new DefaultApplicationArguments("publishToSdkman", "RELEASE")));
}

@Test
void runWhenReleaseTypeMilestoneShouldDoNothing() throws Exception {
this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "M", "1.2.3"));
this.command.run(new DefaultApplicationArguments("publishToSdkman", "M", "1.2.3"));
verifyNoInteractions(this.service);
}

@Test
void runWhenReleaseTypeRCShouldDoNothing() throws Exception {
this.command.run(new DefaultApplicationArguments("publishGradlePlugin", "RC", "1.2.3"));
this.command.run(new DefaultApplicationArguments("publishToSdkman", "RC", "1.2.3"));
verifyNoInteractions(this.service);
}

@Test
void runWhenBranchNotSpecifiedShouldCallServiceWithMakeDefaultFalse() throws Exception {
void runWhenLatestGANotSpecifiedShouldCallServiceWithMakeDefaultFalse() throws Exception {
DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3");
testRun(args, false);
}

@Test
void runWhenBranchNotMasterShouldCallServiceWithMakeDefaultFalse() throws Exception {
DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "other");
testRun(args, false);
}

@Test
void runWhenReleaseTypeReleaseShouldCallService() throws Exception {
DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "master");
DefaultApplicationArguments args = new DefaultApplicationArguments("promote", "RELEASE", "1.2.3", "true");
testRun(args, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void tearDown() {
void publishWhenMakeDefaultTrue() throws Exception {
setupExpectation("https://vendors.sdkman.io/release",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}");
setupExpectation("https://vendors.sdkman.io/default",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}");
setupExpectation("https://vendors.sdkman.io/default", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}",
HttpMethod.PUT);
setupExpectation("https://vendors.sdkman.io/announce/struct",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\"}");
this.service.publish("1.2.3", true);
Expand All @@ -78,7 +78,11 @@ void publishWhenMakeDefaultFalse() throws Exception {
}

private void setupExpectation(String url, String body) {
this.server.expect(requestTo(url)).andExpect(method(HttpMethod.POST)).andExpect(content().json(body))
setupExpectation(url, body, HttpMethod.POST);
}

private void setupExpectation(String url, String body, HttpMethod method) {
this.server.expect(requestTo(url)).andExpect(method(method)).andExpect(content().json(body))
.andExpect(header("Consumer-Key", "sdkman-consumer-key"))
.andExpect(header("Consumer-Token", "sdkman-consumer-token"))
.andExpect(header("Content-Type", MediaType.APPLICATION_JSON.toString())).andRespond(withSuccess());
Expand Down
1 change: 1 addition & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ jobs:
<<: *sdkman-task-params
RELEASE_TYPE: RELEASE
BRANCH: ((branch))
LATEST_GA: false
groups:
- name: "builds"
jobs: ["build", "jdk11-build", "jdk15-build", "windows-build"]
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/publish-to-sdkman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source $(dirname $0)/common.sh

version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )

java -jar /spring-boot-release-scripts.jar publishToSdkman $RELEASE_TYPE $version $BRANCH || { exit 1; }
java -jar /spring-boot-release-scripts.jar publishToSdkman $RELEASE_TYPE $version $LATEST_GA || { exit 1; }

echo "Push to SDKMAN complete"
1 change: 1 addition & 0 deletions ci/tasks/publish-to-sdkman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ inputs:
params:
RELEASE_TYPE:
BRANCH:
LATEST_GA:
SDKMAN_CONSUMER_KEY:
SDKMAN_CONSUMER_TOKEN:
run:
Expand Down

0 comments on commit e5e654c

Please sign in to comment.