-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First quick and dirty attempt * Introduce TaggedCommits * Refactor method name: currentPostion(path) -> positionOfLastChangeIn(path) * Wrapper class around TagsOnCommit, with factory methods * #291 Initial commit * #310 #291 Updated JGit & GrGit to exclude dirs when calculating versions. * #310 #291 Implement requested changes.
- Loading branch information
1 parent
2e86885
commit 7202376
Showing
29 changed files
with
733 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
...ation/groovy/pl/allegro/tech/build/axion/release/MultiModuleProjectIntegrationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
package pl.allegro.tech.build.axion.release | ||
|
||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
import java.util.stream.Collectors | ||
|
||
class MultiModuleProjectIntegrationTest extends BaseIntegrationTest { | ||
|
||
File getSubmoduleDir(String projectName) { | ||
return new File(temporaryFolder.root, projectName) | ||
} | ||
|
||
void generateSubmoduleBuildFile(String projectName) { | ||
File submoduleDir = getSubmoduleDir(projectName) | ||
submoduleDir.mkdirs() | ||
File buildFile = new File(submoduleDir, "build.gradle") | ||
buildFile << """ | ||
plugins { | ||
id 'pl.allegro.tech.build.axion-release' | ||
} | ||
scmVersion { | ||
tag { | ||
prefix = '${projectName}' | ||
} | ||
} | ||
project.version = scmVersion.version | ||
""" | ||
} | ||
|
||
void generateSettingsFile(File dir, List<String> submodules) { | ||
String submodulesIncludeString = submodules.stream().map({ m -> "'${m}'" }).collect(Collectors.joining(',')) | ||
File settings = new File(dir, "settings.gradle") | ||
settings << """ | ||
include ${submodulesIncludeString} | ||
""" | ||
} | ||
|
||
void generateGitIgnoreFile(File dir) { | ||
File gitIgnore = new File(dir, ".gitignore") | ||
gitIgnore << """\ | ||
.gradle | ||
""".stripIndent() | ||
} | ||
|
||
/** | ||
* Configure the multi-module project for testing. | ||
* We start off with v1.0.0 on the parent project and versions 2.0.0 and 3.0.0 for the 2 child projects. | ||
*/ | ||
void initialProjectConfiguration() { | ||
List<String> submodules = ["project1", "project2"] | ||
buildFile(''' | ||
scmVersion { | ||
monorepos { | ||
projectDirs = project.subprojects.collect({p -> p.name}) | ||
} | ||
} | ||
''' | ||
) | ||
generateSettingsFile(temporaryFolder.root, submodules) | ||
generateGitIgnoreFile(temporaryFolder.root) | ||
|
||
repository.commit(['.'], "initial commit of top level project") | ||
|
||
// create version for main project | ||
runGradle(':createRelease', '-Prelease.version=1.0.0', '-Prelease.disableChecks') | ||
|
||
// create submodules | ||
int versionCounter = 2 | ||
for (String module : submodules) { | ||
// generate the project files | ||
generateSubmoduleBuildFile(module) | ||
// add to repo | ||
repository.commit(["${module}"], "commit submodule ${module}") | ||
// tag release for that project | ||
runGradle(":${module}:createRelease", "-Prelease.version=${versionCounter}.0.0", '-Prelease.disableChecks') | ||
versionCounter++ | ||
} | ||
} | ||
|
||
def "plugin can distinguish between submodules versions"() { | ||
given: | ||
initialProjectConfiguration() | ||
|
||
when: | ||
def result = runGradle(':currentVersion') | ||
def match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '1.0.0' | ||
result.task(":currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
when: | ||
result = runGradle(':project1:currentVersion') | ||
match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '2.0.0' | ||
result.task(":project1:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
when: | ||
result = runGradle(':project2:currentVersion') | ||
match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '3.0.0' | ||
result.task(":project2:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
} | ||
|
||
def "change to submodule should not change sibling project version"() { | ||
given: | ||
initialProjectConfiguration() | ||
File dummy = new File(getSubmoduleDir("project1"), "dummy.txt") | ||
dummy.createNewFile() | ||
repository.commit(["project1"], "commit submodule project1") | ||
runGradle(":project1:release", "-Prelease.version=4.0.0", '-Prelease.localOnly', '-Prelease.disableChecks') | ||
|
||
when: | ||
def result = runGradle(':project1:currentVersion') | ||
def match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '4.0.0' | ||
result.task(":project1:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
when: | ||
result = runGradle(':project2:currentVersion') | ||
match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '3.0.0' | ||
result.task(":project2:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
} | ||
|
||
def "change to submodule should not change root project version"() { | ||
given: | ||
initialProjectConfiguration() | ||
File dummy = new File(getSubmoduleDir("project1"), "dummy.txt") | ||
dummy.createNewFile() | ||
repository.commit(["project1"], "commit submodule project1") | ||
runGradle(":project1:release", "-Prelease.version=4.0.0", '-Prelease.localOnly', '-Prelease.disableChecks') | ||
|
||
when: | ||
def result = runGradle(':currentVersion') | ||
def match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '1.0.0' | ||
result.task(":currentVersion").outcome == TaskOutcome.SUCCESS | ||
} | ||
|
||
def "change to root project should not change child project versions"() { | ||
given: | ||
initialProjectConfiguration() | ||
File dummy = new File(temporaryFolder.root, "dummy.txt") | ||
dummy.createNewFile() | ||
repository.commit(["dummy.txt"], "commit parent project") | ||
runGradle(":release", "-Prelease.version=4.0.0", '-Prelease.localOnly', '-Prelease.disableChecks') | ||
|
||
when: | ||
def result = runGradle(':currentVersion') | ||
def match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '4.0.0' | ||
result.task(":currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
when: | ||
result = runGradle(':project1:currentVersion') | ||
match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '2.0.0' | ||
result.task(":project1:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
when: | ||
result = runGradle(':project2:currentVersion') | ||
match = result.output =~ /(?m)^.*Project version: (.*)$/ | ||
|
||
then: | ||
match[0][1] == '3.0.0' | ||
result.task(":project2:currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/groovy/pl/allegro/tech/build/axion/release/domain/MonorepoConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package pl.allegro.tech.build.axion.release.domain | ||
|
||
class MonorepoConfig { | ||
public List<String> projectDirs = [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.