Skip to content

Commit 5abd8f2

Browse files
author
Sandeep Mishra
committed
isolation
1 parent 8bdbd82 commit 5abd8f2

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

cicd/cmd/run-it-tests/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
* WARRANTIES OR CONDITIONS OF ANY, either express or implied. See the
1313
* License for the specific language governing permissions and limitations under
1414
* the License.
1515
*/
@@ -20,8 +20,8 @@ import (
2020
"flag"
2121
"log"
2222

23-
"github.com/GoogleCloudPlatform/DataflowTemplates/cicd/internal/flags"
2423
"github.com/GoogleCloudPlatform/DataflowTemplates/cicd/internal/workflows"
24+
"github.comcom/GoogleCloudPlatform/DataflowTemplates/cicd/internal/flags"
2525
)
2626

2727
func main() {
@@ -31,7 +31,8 @@ func main() {
3131

3232
// Run mvn install before running integration tests
3333
mvnFlags := workflows.NewMavenFlags()
34-
err := workflows.MvnCleanInstall().Run(
34+
// CHANGED: Pass projects to build to the clean install step as well.
35+
err := workflows.MvnCleanInstall(flags.ProjectsToBuild()...).Run(
3536
mvnFlags.IncludeDependencies(),
3637
mvnFlags.SkipDependencyAnalysis(),
3738
mvnFlags.SkipCheckstyle(),
@@ -47,7 +48,8 @@ func main() {
4748

4849
// Run integration tests
4950
mvnFlags = workflows.NewMavenFlags()
50-
err = workflows.MvnVerify().Run(
51+
// CHANGED: Pass projects to build to the verify step.
52+
err = workflows.MvnVerify(flags.ProjectsToBuild()...).Run(
5153
mvnFlags.IncludeDependencies(),
5254
mvnFlags.SkipDependencyAnalysis(),
5355
mvnFlags.SkipCheckstyle(),
@@ -68,8 +70,7 @@ func main() {
6870
flags.SpannerHost(),
6971
flags.FailureMode(),
7072
flags.RetryFailures(),
71-
flags.TestToRun(), // ADD THIS LINE TO USE THE NEW FLAG
72-
flags.ModuleToTest(),
73+
flags.TestToRun(),
7374
flags.StaticOracleHost(),
7475
flags.StaticOracleSysPassword(),
7576
flags.CloudProxyHost(),

cicd/internal/flags/common-flags.go

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
* WARRANTIES OR CONDITIONS OF ANY, either express or implied. See the
1313
* License for the specific language governing permissions and limitations under
1414
* the License.
1515
*/
@@ -18,19 +18,19 @@ package flags
1818

1919
import (
2020
"flag"
21+
"fmt" // ADDED: Import fmt package
2122
"strings"
2223
)
2324

2425
const (
25-
ALL = "ALL" // All modules
26-
DEFAULT = "DEFAULT" // Modules other than those excluded
26+
ALL = "ALL"
27+
DEFAULT = "DEFAULT"
2728
KAFKA = "KAFKA"
2829
SPANNER = "SPANNER"
2930
BIGTABLE = "BIGTABLE"
3031
DATASTREAM = "DATASTREAM"
3132
)
3233

33-
// Avoid making these vars public.
3434
var (
3535
modulesToBuild string
3636
moduleMap = map[string][]string{
@@ -68,16 +68,24 @@ var (
6868
}
6969
)
7070

71-
// Registers all common flags. Must be called before flag.Parse().
7271
func RegisterCommonFlags() {
7372
flag.StringVar(&modulesToBuild, "modules-to-build", ALL, "List of modules to build/run commands against")
7473
}
7574

76-
// Returns all modules to build.
77-
func ModulesToBuild() []string {
75+
// CHANGED: This function now contains all logic for deciding which modules to build.
76+
// It returns a slice of strings that will be passed to Maven.
77+
func ProjectsToBuild() []string {
78+
// If a specific module is given for testing, it takes highest priority.
79+
if ModuleToTest != "" {
80+
// -pl tells Maven to build only this project
81+
// -am tells Maven to also build any dependencies it needs
82+
return []string{"-pl", ModuleToTest, "-am"}
83+
}
84+
85+
// Otherwise, use the default behavior with --modules-to-build
7886
m := modulesToBuild
87+
var modules []string
7988
if m == "DEFAULT" {
80-
// "DEFAULT" is "ALL" minus other modules defined in moduleMap
8189
var s []string
8290
for k, v := range moduleMap {
8391
if k != "ALL" && k != "DEFAULT" {
@@ -88,12 +96,17 @@ func ModulesToBuild() []string {
8896
}
8997
}
9098
}
91-
return s
99+
modules = s
92100
} else if val, ok := moduleMap[modulesToBuild]; ok {
93-
return val
101+
modules = val
102+
} else if len(m) > 0 {
103+
modules = strings.Split(m, ",")
94104
}
95-
if len(m) == 0 {
96-
return make([]string, 0)
105+
106+
if len(modules) > 0 {
107+
return []string{"-pl", strings.Join(modules, ","), "-am"}
97108
}
98-
return strings.Split(m, ",")
109+
110+
// Return empty if ALL modules should be built (Maven's default)
111+
return []string{}
99112
}

0 commit comments

Comments
 (0)