diff --git a/.github/workflows/mps_cli_build.yaml b/.github/workflows/mps_cli_build.yaml index b7f935a..1833067 100644 --- a/.github/workflows/mps_cli_build.yaml +++ b/.github/workflows/mps_cli_build.yaml @@ -1,6 +1,10 @@ name: MPS-CLI_CI -on: [push, pull_request] +on: + push: + branches: + - 'main' + pull_request: env: GITHUB_TOKEN: ${{ secrets.MPSCLI_GITHUB_PKG_REGISTRY }} diff --git a/.github/workflows/mps_cli_py_build.yaml b/.github/workflows/mps_cli_py_build.yaml index 4e72be6..59fac04 100644 --- a/.github/workflows/mps_cli_py_build.yaml +++ b/.github/workflows/mps_cli_py_build.yaml @@ -1,6 +1,10 @@ name: MPS-CLI-PY_CI -on: [push, pull_request] +on: + push: + branches: + - 'main' + pull_request: env: GITHUB_TOKEN: ${{ secrets.MPSCLI_GITHUB_PKG_REGISTRY }} diff --git a/mps-cli-gradle-plugin/plugin/build.gradle b/mps-cli-gradle-plugin/plugin/build.gradle index 1b3fa41..26d55c1 100644 --- a/mps-cli-gradle-plugin/plugin/build.gradle +++ b/mps-cli-gradle-plugin/plugin/build.gradle @@ -19,7 +19,7 @@ plugins { // Project versions ext.major = '0' -ext.minor = '14' +ext.minor = '15' sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/mps-cli-gradle-plugin/plugin/src/functionalTest/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTest_02.groovy b/mps-cli-gradle-plugin/plugin/src/functionalTest/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTest_02.groovy new file mode 100644 index 0000000..939dfca --- /dev/null +++ b/mps-cli-gradle-plugin/plugin/src/functionalTest/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTest_02.groovy @@ -0,0 +1,42 @@ +/* + * This Groovy source file was generated by the Gradle 'init' task. + */ +package org.mps_cli.gradle.plugin + +class ConeOfInfluenceComputerTest_02 extends TestBase { + + def "cone of influence computer test"() { + given: + settingsFile << "" + buildFile << ''' + +plugins { + id('com.mbeddr.mps_cli') +} + +buildModuleDependencies { + sourcesDir = ['../../../../../../../../../mps_test_projects/mps_cli_lanuse_file_per_root'] +} + +computeConeOfInfluence { + referenceBranchName = "origin/testing/do_not_delete/cone_of_influence_test_02" + gitRepoRootLocation = '../../../../../../../../../' +} + +task printConeOfInfluence { + dependsOn computeConeOfInfluence + doLast { + def affectedSolutions = computeConeOfInfluence.affectedSolutions + println "all affected solutions: ${affectedSolutions.collect { it.name }.sort()}" + } +} +''' + + when: + runTask("printConeOfInfluence") + + then: + result.output.contains "Solutions [mps.cli.lanuse.library_top2.msd] do not exist on current branch. The cone of influence is the entire set of solutions." + result.output.contains "all affected solutions: [mps.cli.lanuse.library_second, mps.cli.lanuse.library_top]" + } +} diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/ConeOfInfluenceComputer.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/ConeOfInfluenceComputer.groovy index 9cf7308..eeeaa65 100644 --- a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/ConeOfInfluenceComputer.groovy +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/ConeOfInfluenceComputer.groovy @@ -4,6 +4,7 @@ import org.mps_cli.model.SModuleBase import org.mps_cli.model.SSolutionModule import org.mps_cli.model.builder.SSolutionModuleBuilder +import java.nio.file.Files import java.nio.file.Path class ConeOfInfluenceComputer { @@ -12,7 +13,20 @@ class ConeOfInfluenceComputer { Map> module2AllUpstreamDependencies, Map> module2AllDownstreamDependencies) { - List differentModulesFiles = Filesystem2SSolutionBridge.computeModulesWhichAreModifiedInCurrentBranch(gitRepoLocation, allModifiedFiles) + def modulesUniverse = module2AllUpstreamDependencies.keySet() + + HashSet differentModulesFiles = Filesystem2SSolutionBridge.computeModulesWhichAreModifiedInCurrentBranch(gitRepoLocation, allModifiedFiles) + + println(">>>>>>>>>>>> All different modules files:") + differentModulesFiles.each { println it } + println("<<<<<<<<<<<<") + + // if any module is deleted (.msd file not available) then COI is the entire universe + def notExistingSolutions = differentModulesFiles.findAll { Files.notExists(it) } + if (notExistingSolutions) { + println("Solutions ${notExistingSolutions.fileName} do not exist on current branch. The cone of influence is the entire set of solutions.") + return new Tuple2(modulesUniverse.toList(), modulesUniverse.toList()) + } List differentModulesIds = differentModulesFiles.collect { SSolutionModuleBuilder builder = new SSolutionModuleBuilder() @@ -21,7 +35,7 @@ class ConeOfInfluenceComputer { } // directly affected modules - def differentModulesFromBranch = module2AllUpstreamDependencies.keySet().findAll {differentModulesIds.contains(it.moduleId) } + def differentModulesFromBranch = modulesUniverse.findAll {differentModulesIds.contains(it.moduleId) } // indirectly potentially affected modules def downstreamDependenciesOfDirectlyAffectedModules = differentModulesFromBranch.collectMany {module2AllDownstreamDependencies[it] } diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/Filesystem2SSolutionBridge.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/Filesystem2SSolutionBridge.groovy index 084220b..c3a6aa0 100644 --- a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/Filesystem2SSolutionBridge.groovy +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/Filesystem2SSolutionBridge.groovy @@ -8,10 +8,11 @@ import static groovy.io.FileType.FILES class Filesystem2SSolutionBridge { - static List computeModulesWhichAreModifiedInCurrentBranch(String gitRepoRootLocation, List allModifiedFiles) { + /** Returns a list of .msd Files representing the modified modules. **/ + static HashSet computeModulesWhichAreModifiedInCurrentBranch(String gitRepoRootLocation, List allModifiedFiles) { def gitRepoLocation = Paths.get(gitRepoRootLocation).toAbsolutePath().normalize() - List affectedModulesFiles = [] + LinkedHashSet affectedModulesFiles = [] allModifiedFiles.each { if (it.endsWith('.msd')) affectedModulesFiles.add(gitRepoLocation.resolve(it)) diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/GitFacade.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/GitFacade.groovy index 153a54a..dba97f5 100644 --- a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/GitFacade.groovy +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/cone_of_influence/GitFacade.groovy @@ -37,8 +37,9 @@ class GitFacade { def differencesString = standardOutputOfCommand('git', 'diff', '--name-only', mergeBase) def differences = differencesString.split('\n') - println("Differences:") + println(">>>>>>>>>>>>> Differences:") differences.each { println(it) } + println ("<<<<<<<<<<<<") differences } diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTask.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTask.groovy index 56f6de5..84fb10b 100644 --- a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTask.groovy +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/gradle/plugin/ConeOfInfluenceComputerTask.groovy @@ -44,7 +44,7 @@ class ConeOfInfluenceComputerTask extends DefaultTask { def solution2AllUpstreamDependencies = project.buildModuleDependencies.module2AllUpstreamDependencies def solution2AllDownstreamDependencies = project.buildModuleDependencies.module2AllDownstreamDependencies - def allModifiedFiles = modifiedFiles ?: + def allModifiedFiles = modifiedFiles != null ? modifiedFiles : GitFacade.computeFilesWhichAreModifiedInCurrentBranch(gitRepoRootLocation, referenceBranchName) ConeOfInfluenceComputer coiComputer = new ConeOfInfluenceComputer()