Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not run spanner-pr tests in Java PR #1826

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/java-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ jobs:
- name: Run Integration Tests
run: |
./cicd/run-it-tests \
--modules-to-build="DEFAULT" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/spanner-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ on:
branches:
- 'main'
paths:
# Include spanner paths only
# Template wide common modules
- 'v2/common/**'
- 'v2/datastream-common/**'
- 'it/google-cloud-platform/**'
- 'it/conditions/**'
# Component common modules
- 'v2/spanner-common/**'
- 'v2/spanner-migrations-sdk/**'
- 'v2/spanner-custom-shard/**'
# Include spanner paths
- '.github/workflows/spanner-pr.yml'
- 'v2/datastream-to-spanner/**'
- 'v2/spanner-common/**'
- 'v2/spanner-change-streams-to-sharded-file-sink/**'
- 'v2/gcs-to-sourcedb/**'
- 'v2/spanner-migrations-sdk/**'
- 'v2/spanner-custom-shard/**'
- 'v2/sourcedb-to-spanner/**'
- 'v2/spanner-to-sourcedb/**'
schedule:
Expand Down
32 changes: 28 additions & 4 deletions cicd/internal/flags/common-flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,25 @@ import (
)

const (
ALL = "ALL"
ALL = "ALL" // All modules
DEFAULT = "DEFAULT" // Modules other than those excluded
SPANNER = "SPANNER"
)

// Avoid making these vars public.
var (
modulesToBuild string
moduleMap = map[string]string{ALL: "", SPANNER: "v2/datastream-to-spanner/,v2/spanner-change-streams-to-sharded-file-sink/,v2/gcs-to-sourcedb/,v2/sourcedb-to-spanner/,v2/spanner-to-sourcedb/,v2/spanner-custom-shard,plugins/templates-maven-plugin"}
moduleMap = map[string][]string{
ALL: {},
DEFAULT: {},
SPANNER: {"v2/datastream-to-spanner/",
"v2/spanner-change-streams-to-sharded-file-sink/",
"v2/gcs-to-sourcedb/",
"v2/sourcedb-to-spanner/",
"v2/spanner-to-sourcedb/",
"v2/spanner-custom-shard",
"plugins/templates-maven-plugin"},
}
)

// Registers all common flags. Must be called before flag.Parse().
Expand All @@ -40,8 +51,21 @@ func RegisterCommonFlags() {
// Returns all modules to build.
func ModulesToBuild() []string {
m := modulesToBuild
if val, ok := moduleMap[modulesToBuild]; ok {
m = val
if m == "DEFAULT" {
// "DEFAULT" is "ALL" minus other modules defined in moduleMap
var s []string
for k, v := range moduleMap {
if k != "ALL" && k != "DEFAULT" {
for _, n := range v {
if !strings.HasPrefix(n, "plugins/") {
s = append(s, "!"+n)
}
}
}
}
return s
} else if val, ok := moduleMap[modulesToBuild]; ok {
return val
}
if len(m) == 0 {
return make([]string, 0)
Expand Down
21 changes: 21 additions & 0 deletions cicd/internal/flags/common-flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package flags

import (
"reflect"
"strings"
"testing"
)

Expand Down Expand Up @@ -52,3 +53,23 @@ func TestModulesToBuild(t *testing.T) {
}
}
}

func TestDefaultExcludedSubModules(t *testing.T) {
Abacn marked this conversation as resolved.
Show resolved Hide resolved
// common modules won't excluded
modulesToBuild = "DEFAULT"
defaults := ModulesToBuild()
mods := []string{"SPANNER"}
var s []string
for _, m := range mods {
modulesToBuild = m
ms := ModulesToBuild()
for _, n := range ms {
if !strings.HasPrefix(n, "plugins/") {
s = append(s, "!"+n)
}
}
}
if !reflect.DeepEqual(defaults, s) {
t.Errorf("Returned modules are not equal. Expected %v. Got %v.", s, defaults)
}
}
Loading