Skip to content

Commit

Permalink
Remove testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shell32-Natsu committed May 21, 2020
1 parent 44f5093 commit 68d6b9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
32 changes: 13 additions & 19 deletions releasing/releasing/releasing.go
Expand Up @@ -107,13 +107,10 @@ var release = &cobra.Command{
}
return nil
},
PreRun: func(cmd *cobra.Command, args []string) {
logDebug("Preparing Git environemnt")
prepareGit()
},
Run: func(cmd *cobra.Command, args []string) {
modName := args[0]
versionType := args[1]
createTempDir()
logInfo("Creating tag for module %s", modName)
pwd, err := os.Getwd()
if err != nil {
Expand Down Expand Up @@ -156,20 +153,16 @@ var release = &cobra.Command{
mod.Tag(),
)

// Run module tests
output, err := mod.RunTest()
if err != nil {
logWarn(output)
} else if !noDryRun {
if !noDryRun {
logInfo("Skipping push module %s. Run with --no-dry-run to push the release.", mod.name)
} else {
pushRelease(tempDir, branch, mod)
}
// Clean
cleanGit()
removeTempDir()
pruneWorktree(pwd)
deleteBranch(pwd, branch)
logInfo("Module %s completes", mod.name)
logInfo("Releasing for module %s completes", mod.name)
},
}

Expand Down Expand Up @@ -304,7 +297,7 @@ func (m *module) Tag() string {
return m.name + "/" + m.version.String()
}

func (m *module) RunTest() (string, error) {
func (m module) RunTest() (string, error) {
if noTest {
logInfo("Tests disabled.")
return "", nil
Expand All @@ -323,17 +316,21 @@ func (m *module) RunTest() (string, error) {

// === Git environment functions ===

func prepareGit() {
var err error
func createTempDir() {
// Create temporary directory
tempDir, err = ioutil.TempDir("", "kustomize-releases")
temp, err := ioutil.TempDir("", "kustomize-releases")
if err != nil {
logFatal(err.Error())
}
logDebug("Created git temp dir: " + tempDir)
tempDir = path.Join(temp, "sigs.k8s.io/kustomize")
err = os.MkdirAll(tempDir, 0700)
if err != nil {
logFatal(err.Error())
}
}

func cleanGit() {
func removeTempDir() {
logDebug("Deleting git temp dir: " + tempDir)
err := os.RemoveAll(tempDir)
if err != nil {
Expand Down Expand Up @@ -395,7 +392,6 @@ func newBranch(path, name string) {
if err != nil {
logFatal(string(stdoutStderr))
}
logInfo("Finished creating branch")
}

func deleteBranch(path, name string) {
Expand All @@ -417,7 +413,6 @@ func addWorktree(path, tempDir, branch string) {
if err != nil {
logFatal(string(stdoutStderr))
}
logInfo("Finished adding worktree")
}

func pruneWorktree(path string) {
Expand All @@ -440,7 +435,6 @@ func merge(path, branch string) {
if err != nil {
logFatal(string(stdoutStderr))
}
logInfo("Finished merging")
}

func pushRelease(path, branch string, mod module) {
Expand Down
4 changes: 2 additions & 2 deletions releasing/releasing/releasing_test.go
Expand Up @@ -30,7 +30,7 @@ func TestList(t *testing.T) {
}

func TestRelease(t *testing.T) {
prepareGit()
createTempDir()
modName := "api"
versionType := "patch"
pwd, err := os.Getwd()
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestRelease(t *testing.T) {
mod.path = tempDir

// Clean
cleanGit()
removeTempDir()
pruneWorktree(pwd)
deleteBranch(pwd, branch)
}

0 comments on commit 68d6b9a

Please sign in to comment.