From 6c537f18781b9cbe89f3992e8fe603402a40e7fb Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 14:27:46 +0300 Subject: [PATCH 01/15] feat: some refactoring --- cmd/gobrew/main.go | 3 +-- gobrew.go | 63 ++++++++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/cmd/gobrew/main.go b/cmd/gobrew/main.go index 512a40e..486e5e3 100644 --- a/cmd/gobrew/main.go +++ b/cmd/gobrew/main.go @@ -88,11 +88,10 @@ func main() { gb.ListRemoteVersions(true) case "install": gb.Install(versionArg) - if gb.CurrentVersion() == "" { + if gb.CurrentVersion() == "None" { gb.Use(versionArg) } case "use": - gb.Install(versionArg) gb.Use(versionArg) case "uninstall": gb.Uninstall(versionArg) diff --git a/gobrew.go b/gobrew.go index 03a24ec..6d131a1 100644 --- a/gobrew.go +++ b/gobrew.go @@ -37,7 +37,7 @@ type Command interface { ListRemoteVersions(print bool) map[string][]string CurrentVersion() string Uninstall(version string) - Install(version string) + Install(version string) string Use(version string) Prune() Version(currentVersion string) @@ -91,23 +91,18 @@ func (gb *GoBrew) Interactive(ask bool) { latestVersion := gb.getLatestVersion() latestMajorVersion := ExtractMajorVersion(latestVersion) - modVersion := "" + modVersion := "None" if gb.hasModFile() { modVersion = gb.getModVersion() modVersion = ExtractMajorVersion(modVersion) } - if modVersion == "" { - modVersion = "None" - } - fmt.Println() - if currentVersion == "" { - currentVersion = "None" + if currentVersion == "None" { color.Warnln("GO Installed Version", ".......", currentVersion) } else { - labels := []string{} + var labels []string if modVersion != "None" && currentMajorVersion != modVersion { labels = append(labels, "not same as go.mod") } @@ -117,8 +112,6 @@ func (gb *GoBrew) Interactive(ask bool) { label := "" if len(labels) > 0 { label = "(" + strings.Join(labels, ", ") + ")" - } - if label != "" { label = " " + color.FgRed.Render(label) } color.Successln("GO Installed Version", ".......", currentVersion+label) @@ -141,7 +134,6 @@ func (gb *GoBrew) Interactive(ask bool) { c = AskForConfirmation("Do you want to use latest GO version (" + latestVersion + ")?") } if c { - gb.Install(latestVersion) gb.Use(latestVersion) } return @@ -154,7 +146,6 @@ func (gb *GoBrew) Interactive(ask bool) { c = AskForConfirmation("Do you want to use GO version same as go.mod version (" + modVersion + "@latest)?") } if c { - gb.Install(modVersion + "@latest") gb.Use(modVersion + "@latest") } return @@ -167,7 +158,6 @@ func (gb *GoBrew) Interactive(ask bool) { c = AskForConfirmation("Do you want to update GO to latest version (" + latestVersion + ")?") } if c { - gb.Install(latestVersion) gb.Use(latestVersion) } return @@ -285,7 +275,9 @@ func (gb *GoBrew) ListVersions() { // ListRemoteVersions that are installed by dir ls func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string { - color.Infoln("==> [Info] Fetching remote versions\n") + if print { + color.Infoln("==> [Info] Fetching remote versions") + } tags := gb.getGolangVersions() var versions []string @@ -427,13 +419,13 @@ func (gb *GoBrew) existsVersion(version string) bool { func (gb *GoBrew) CurrentVersion() string { fp, err := filepath.EvalSymlinks(gb.currentBinDir) if err != nil { - return "" + return "None" } version := strings.TrimSuffix(fp, filepath.Join("go", "bin")) version = filepath.Base(version) if version == "." { - return "" + return "None" } return version } @@ -461,42 +453,43 @@ func (gb *GoBrew) cleanDownloadsDir() { } // Install the given version of go -func (gb *GoBrew) Install(version string) { - if version == "" { +func (gb *GoBrew) Install(version string) string { + if version == "" || version == "None" { color.Errorln("[Error] No version provided") os.Exit(1) } version = gb.judgeVersion(version) - gb.mkDirs(version) if gb.existsVersion(version) { color.Infof("==> [Info] Version: %s exists\n", version) - return + return version } + gb.mkDirs(version) color.Infof("==> [Info] Downloading version: %s\n", version) gb.downloadAndExtract(version) gb.cleanDownloadsDir() color.Successf("==> [Success] Downloaded version: %s\n", version) + return version } func (gb *GoBrew) judgeVersion(version string) string { - judgedVersion := "" + judgedVersion := "None" rcBetaOk := false reRcOrBeta := regexp.MustCompile("beta.*|rc.*") - // check if version string ends with x + // check if version string ends with x if strings.HasSuffix(version, "x") { - judgedVersion = version[:len(version)-1] + judgedVersion = strings.TrimSuffix(version, "x") } if strings.HasSuffix(version, ".x") { - judgedVersion = version[:len(version)-2] + judgedVersion = strings.TrimSuffix(version, ".x") } if strings.HasSuffix(version, "@latest") { - judgedVersion = version[:len(version)-7] + judgedVersion = strings.TrimSuffix(version, "@latest") } if strings.HasSuffix(version, "@dev-latest") { - judgedVersion = version[:len(version)-11] + judgedVersion = strings.TrimSuffix(version, "@dev-latest") rcBetaOk = true } @@ -509,8 +502,8 @@ func (gb *GoBrew) judgeVersion(version string) string { } return gb.judgeVersion(modVersion) } + groupedVersions := gb.ListRemoteVersions(false) // donot print if version == "latest" || version == "dev-latest" { - groupedVersions := gb.ListRemoteVersions(false) // donot print groupedVersionKeys := make([]string, 0, len(groupedVersions)) for groupedVersionKey := range groupedVersions { groupedVersionKeys = append(groupedVersionKeys, groupedVersionKey) @@ -522,7 +515,7 @@ func (gb *GoBrew) judgeVersion(version string) string { } } if len(versionsSemantic) == 0 { - return "" + return "None" } // sort semantic versions @@ -533,7 +526,7 @@ func (gb *GoBrew) judgeVersion(version string) string { // get last element if version == "dev-latest" { if len(judgedVersions) == 0 { - return "" + return "None" } return judgedVersions[len(judgedVersions)-1] } @@ -551,8 +544,7 @@ func (gb *GoBrew) judgeVersion(version string) string { return gb.judgeVersion(latest) } - if judgedVersion != "" { - groupedVersions := gb.ListRemoteVersions(false) // donot print + if judgedVersion != "None" { // check if judgedVersion is in the groupedVersions if _, ok := groupedVersions[judgedVersion]; ok { // get last item in the groupedVersions excluding rc and beta @@ -592,8 +584,7 @@ func (gb *GoBrew) getModVersion() string { modFilePath := filepath.Join("go.mod") modFile, err := os.Open(modFilePath) if err != nil { - color.Errorln(err) - os.Exit(1) + return "None" } defer func(modFile *os.File) { _ = modFile.Close() @@ -611,12 +602,12 @@ func (gb *GoBrew) getModVersion() string { color.Errorln(err) os.Exit(1) } - return "" + return "None" } // Use a version func (gb *GoBrew) Use(version string) { - version = gb.judgeVersion(version) + version = gb.Install(version) if gb.CurrentVersion() == version { color.Infof("==> [Info] Version: %s is already your current version \n", version) return From 1c24883ac1fc06e9b07e80ea43a10c557042b31d Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 14:35:27 +0300 Subject: [PATCH 02/15] feat: cross build setup for main package --- cmd/gobrew/main.go | 19 +------------------ cmd/gobrew/main_unix.go | 10 ++++++++++ cmd/gobrew/main_windows.go | 8 ++++++++ 3 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 cmd/gobrew/main_unix.go create mode 100644 cmd/gobrew/main_windows.go diff --git a/cmd/gobrew/main.go b/cmd/gobrew/main.go index 486e5e3..1673663 100644 --- a/cmd/gobrew/main.go +++ b/cmd/gobrew/main.go @@ -4,7 +4,6 @@ import ( "flag" "log" "os" - "runtime" "strconv" "strings" @@ -167,23 +166,7 @@ Examples: gobrew use dev-latest # use go version latest avalable, including rc and beta Installation Path: -` - - if runtime.GOOS == "windows" { - msg = msg + ` - # Add gobrew to your environment variables - PATH="%USERPROFILE%\.gobrew\current\bin;%USERPROFILE%\.gobrew\bin;%PATH%" - GOROOT="%USERPROFILE%\.gobrew\current\go" - -` - } else { - msg = msg + ` - # Add gobrew to your ~/.bashrc or ~/.zshrc - export PATH="$HOME/.gobrew/current/bin:$HOME/.gobrew/bin:$PATH" - export GOROOT="$HOME/.gobrew/current/go" - -` - } +` + usageMsg return msg } diff --git a/cmd/gobrew/main_unix.go b/cmd/gobrew/main_unix.go new file mode 100644 index 0000000..311dbd2 --- /dev/null +++ b/cmd/gobrew/main_unix.go @@ -0,0 +1,10 @@ +//go:build unix + +package main + +const usageMsg = ` + # Add gobrew to your ~/.bashrc or ~/.zshrc + export PATH="$HOME/.gobrew/current/bin:$HOME/.gobrew/bin:$PATH" + export GOROOT="$HOME/.gobrew/current/go" + +` diff --git a/cmd/gobrew/main_windows.go b/cmd/gobrew/main_windows.go new file mode 100644 index 0000000..f0f084c --- /dev/null +++ b/cmd/gobrew/main_windows.go @@ -0,0 +1,8 @@ +package main + +const usageMsg = ` + # Add gobrew to your ~/.bashrc or ~/.zshrc + export PATH="$HOME/.gobrew/current/bin:$HOME/.gobrew/bin:$PATH" + export GOROOT="$HOME/.gobrew/current/go" + +` From bcfeeb65332b21239f39ceee6bed54eaf97b821c Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 14:36:21 +0300 Subject: [PATCH 03/15] feat: do not use -race in tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e9080f..b579737 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,4 +20,4 @@ jobs: with: version: ${{ matrix.go-version }} - name: Test - run: go test -race -v ./... -count=1 + run: go test -v ./... From 6d5dbb1f457673cd69a9bb53ca6af6eeca57aee7 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 14:52:12 +0300 Subject: [PATCH 04/15] fix: use None result in tests --- gobrew_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gobrew_test.go b/gobrew_test.go index 2ba8316..b67a0df 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -208,7 +208,7 @@ func TestInteractive(t *testing.T) { currentVersion := gb.CurrentVersion() latestVersion := gb.getLatestVersion() // modVersion := gb.getModVersion() - assert.Equal(t, "", currentVersion) + assert.Equal(t, "None", currentVersion) assert.NotEqual(t, currentVersion, latestVersion) ask := false @@ -248,7 +248,7 @@ func TestPrune(t *testing.T) { func TestGoBrew_CurrentVersion(t *testing.T) { tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) - assert.Equal(t, true, gb.CurrentVersion() == "") + assert.Equal(t, true, gb.CurrentVersion() == "None") gb.Install("1.19") gb.Use("1.19") assert.Equal(t, true, gb.CurrentVersion() == "1.19") From b278466a8d950ed1ed964738c8b79d7cf66ef1b5 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 14:53:03 +0300 Subject: [PATCH 05/15] fix: simplify ask to false in test --- gobrew_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gobrew_test.go b/gobrew_test.go index b67a0df..3a37895 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -211,8 +211,7 @@ func TestInteractive(t *testing.T) { assert.Equal(t, "None", currentVersion) assert.NotEqual(t, currentVersion, latestVersion) - ask := false - gb.Interactive(ask) + gb.Interactive(false) currentVersion = gb.CurrentVersion() // remove string private from currentVersion (for macOS) due to /private/var symlink issue @@ -226,7 +225,7 @@ func TestInteractive(t *testing.T) { assert.Equal(t, "1.16.5", currentVersion) assert.NotEqual(t, currentVersion, latestVersion) - gb.Interactive(ask) + gb.Interactive(false) currentVersion = gb.CurrentVersion() currentVersion = strings.Replace(currentVersion, "private", "", -1) assert.Equal(t, currentVersion, latestVersion) From 685b87490b7da40ea2ab491278feded8e6a84f69 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 15:10:51 +0300 Subject: [PATCH 06/15] fix: remove go prefix in getGolangVersions --- gobrew.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gobrew.go b/gobrew.go index 6d131a1..103aae2 100644 --- a/gobrew.go +++ b/gobrew.go @@ -171,7 +171,7 @@ func (gb *GoBrew) getLatestVersion() string { r := regexp.MustCompile("beta.*|rc.*") matches := r.FindAllString(getGolangVersions[i], -1) if len(matches) == 0 { - return strings.ReplaceAll(getGolangVersions[i], "go", "") + return getGolangVersions[i] } } return "" @@ -282,7 +282,7 @@ func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string { var versions []string for _, tag := range tags { - versions = append(versions, strings.ReplaceAll(tag, "go", "")) + versions = append(versions, tag) } return gb.getGroupedVersion(versions, print) @@ -765,7 +765,7 @@ func (gb *GoBrew) getGolangVersions() (result []string) { for _, tag := range tags { t := strings.ReplaceAll(tag.Ref, "refs/tags/", "") if strings.HasPrefix(t, "go") { - result = append(result, t) + result = append(result, strings.TrimPrefix(t, "go")) } } From 6959ccb9535b8c65bba31fbac866ad8124f0bbbc Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 15:18:28 +0300 Subject: [PATCH 07/15] feat: parallel tests again --- gobrew_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gobrew_test.go b/gobrew_test.go index 3a37895..c576804 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -11,6 +11,7 @@ import ( ) func TestNewGobrewHomeDirUsesUserHomeDir(t *testing.T) { + t.Parallel() homeDir, err := os.UserHomeDir() if err != nil { @@ -24,6 +25,7 @@ func TestNewGobrewHomeDirUsesUserHomeDir(t *testing.T) { } func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { + t.Parallel() var envName string switch runtime.GOOS { @@ -49,6 +51,7 @@ func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { } func TestNewGobrewHomeDirUsesGoBrewRoot(t *testing.T) { + t.Parallel() oldEnvValue := os.Getenv("GOBREW_ROOT") defer func() { _ = os.Setenv("GOBREW_ROOT", oldEnvValue) @@ -63,6 +66,7 @@ func TestNewGobrewHomeDirUsesGoBrewRoot(t *testing.T) { } func TestJudgeVersion(t *testing.T) { + t.Parallel() tests := []struct { version string wantVersion string @@ -106,6 +110,7 @@ func TestJudgeVersion(t *testing.T) { for _, test := range tests { test := test t.Run(test.version, func(t *testing.T) { + t.Parallel() gb := NewGoBrew() version := gb.judgeVersion(test.version) assert.Equal(t, test.wantVersion, version) @@ -116,6 +121,7 @@ func TestJudgeVersion(t *testing.T) { } func TestListVersions(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) @@ -124,6 +130,7 @@ func TestListVersions(t *testing.T) { } func TestExistVersion(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) @@ -134,6 +141,7 @@ func TestExistVersion(t *testing.T) { } func TestInstallAndExistVersion(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) gb.Install("1.19") @@ -143,6 +151,7 @@ func TestInstallAndExistVersion(t *testing.T) { } func TestUnInstallThenNotExistVersion(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) gb.Uninstall("1.19") @@ -152,6 +161,7 @@ func TestUnInstallThenNotExistVersion(t *testing.T) { } func TestUpgrade(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) @@ -202,6 +212,7 @@ func TestDoNotUpgradeLatestVersion(t *testing.T) { } func TestInteractive(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) @@ -233,6 +244,7 @@ func TestInteractive(t *testing.T) { } func TestPrune(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) gb.Install("1.20") @@ -245,6 +257,7 @@ func TestPrune(t *testing.T) { } func TestGoBrew_CurrentVersion(t *testing.T) { + t.Parallel() tempDir := t.TempDir() gb := NewGoBrewDirectory(tempDir) assert.Equal(t, true, gb.CurrentVersion() == "None") From f2a040fceb716c24a0f7753c48d791418bbdc3bd Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 15:29:34 +0300 Subject: [PATCH 08/15] fix: do not use global variable --- gobrew.go | 7 ++----- gobrew_test.go | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gobrew.go b/gobrew.go index 103aae2..42a5ce3 100644 --- a/gobrew.go +++ b/gobrew.go @@ -55,8 +55,6 @@ type GoBrew struct { downloadsDir string } -var gb GoBrew - // NewGoBrew instance func NewGoBrew() GoBrew { homeDir, err := os.UserHomeDir() @@ -72,6 +70,7 @@ func NewGoBrew() GoBrew { } func NewGoBrewDirectory(homeDir string) GoBrew { + gb := GoBrew{} gb.homeDir = homeDir gb.installDir = filepath.Join(gb.homeDir, goBrewDir) @@ -281,9 +280,7 @@ func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string { tags := gb.getGolangVersions() var versions []string - for _, tag := range tags { - versions = append(versions, tag) - } + versions = append(versions, tags...) return gb.getGroupedVersion(versions, print) } diff --git a/gobrew_test.go b/gobrew_test.go index c576804..ed0ca12 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -173,7 +173,7 @@ func TestUpgrade(t *testing.T) { binaryFile := filepath.Join(binaryDir, baseName) if oldFile, err := os.Create(binaryFile); err == nil { - // on tests we have to close the file to avoid an error on os.Rename + // on tests, we have to close the file to avoid an error on os.Rename _ = oldFile.Close() } From 492c5c7a9ffb99b2ea218483b44ef2813bf3cfd6 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 15:39:11 +0300 Subject: [PATCH 09/15] fix: do not use parallel in test with os env --- gobrew_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/gobrew_test.go b/gobrew_test.go index ed0ca12..a999503 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -25,7 +25,6 @@ func TestNewGobrewHomeDirUsesUserHomeDir(t *testing.T) { } func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { - t.Parallel() var envName string switch runtime.GOOS { @@ -51,7 +50,6 @@ func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { } func TestNewGobrewHomeDirUsesGoBrewRoot(t *testing.T) { - t.Parallel() oldEnvValue := os.Getenv("GOBREW_ROOT") defer func() { _ = os.Setenv("GOBREW_ROOT", oldEnvValue) From 94d3740c4a16e7d0fb1e3e04e44ff95ac8a4c23f Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 16:01:47 +0300 Subject: [PATCH 10/15] fix: build workflows for package --- .github/workflows/build.yml | 2 +- .github/workflows/coveritup.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eeae011..6a77011 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,5 +23,5 @@ jobs: run: go version shell: bash - name: Build - run: go build cmd/gobrew/main.go + run: go build cmd/gobrew shell: bash diff --git a/.github/workflows/coveritup.yml b/.github/workflows/coveritup.yml index f2ffe1c..3ce540e 100644 --- a/.github/workflows/coveritup.yml +++ b/.github/workflows/coveritup.yml @@ -49,7 +49,7 @@ jobs: - name: Build run: | BUILD_START=$SECONDS - go build -ldflags '-s -w' -o main cmd/gobrew/main.go + go build -ldflags '-s -w' -o main cmd/gobrew echo SCORE=$(($SECONDS-BUILD_START)) >> "$GITHUB_ENV" shell: bash From 6f03dc79042c0a3c8114ca3377b35f0e05df4b2d Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 16:05:59 +0300 Subject: [PATCH 11/15] feat: use t.Setenv for setting vars in tests --- gobrew_test.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/gobrew_test.go b/gobrew_test.go index a999503..0427ff3 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -36,13 +36,7 @@ func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { envName = "HOME" } - oldEnvValue := os.Getenv(envName) - defer func() { - _ = os.Setenv(envName, oldEnvValue) - }() - - _ = os.Unsetenv(envName) - + t.Setenv(envName, "") gobrew := NewGoBrew() assert.Equal(t, os.Getenv("HOME"), gobrew.homeDir) @@ -50,12 +44,7 @@ func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { } func TestNewGobrewHomeDirUsesGoBrewRoot(t *testing.T) { - oldEnvValue := os.Getenv("GOBREW_ROOT") - defer func() { - _ = os.Setenv("GOBREW_ROOT", oldEnvValue) - }() - - _ = os.Setenv("GOBREW_ROOT", "some_fancy_value") + t.Setenv("GOBREW_ROOT", "some_fancy_value") gobrew := NewGoBrew() From 02a864480cc546b0c7d39952d9098f2f773c7b81 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 16:11:57 +0300 Subject: [PATCH 12/15] fix: go build command line --- .github/workflows/build.yml | 2 +- .github/workflows/coveritup.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a77011..4305c12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,5 +23,5 @@ jobs: run: go version shell: bash - name: Build - run: go build cmd/gobrew + run: go build ./cmd/gobrew shell: bash diff --git a/.github/workflows/coveritup.yml b/.github/workflows/coveritup.yml index 3ce540e..f967ea4 100644 --- a/.github/workflows/coveritup.yml +++ b/.github/workflows/coveritup.yml @@ -49,7 +49,7 @@ jobs: - name: Build run: | BUILD_START=$SECONDS - go build -ldflags '-s -w' -o main cmd/gobrew + go build -ldflags '-s -w' -o main ./cmd/gobrew echo SCORE=$(($SECONDS-BUILD_START)) >> "$GITHUB_ENV" shell: bash From 00f366c79aec11145cd391d2aeab63eda41b4b41 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 16:13:19 +0300 Subject: [PATCH 13/15] feat: add workflow_dispatch to coverit workflow --- .github/workflows/coveritup.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/coveritup.yml b/.github/workflows/coveritup.yml index f967ea4..3899bc8 100644 --- a/.github/workflows/coveritup.yml +++ b/.github/workflows/coveritup.yml @@ -11,6 +11,7 @@ on: - '**/*.mod' - '**/*.sum' - '**/*.yaml' + workflow_dispatch: name: "Cover It Up" jobs: From 2ec9e920705676091ea7f02b0227207edae6c831 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Fri, 8 Dec 2023 16:18:07 +0300 Subject: [PATCH 14/15] fix: fake commit --- .github/workflows/coveritup.yml | 1 - gobrew_test.go | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/coveritup.yml b/.github/workflows/coveritup.yml index 3899bc8..f967ea4 100644 --- a/.github/workflows/coveritup.yml +++ b/.github/workflows/coveritup.yml @@ -11,7 +11,6 @@ on: - '**/*.mod' - '**/*.sum' - '**/*.yaml' - workflow_dispatch: name: "Cover It Up" jobs: diff --git a/gobrew_test.go b/gobrew_test.go index 0427ff3..1d76c03 100644 --- a/gobrew_test.go +++ b/gobrew_test.go @@ -45,9 +45,7 @@ func TestNewGobrewHomeDirDefaultsToHome(t *testing.T) { func TestNewGobrewHomeDirUsesGoBrewRoot(t *testing.T) { t.Setenv("GOBREW_ROOT", "some_fancy_value") - gobrew := NewGoBrew() - assert.Equal(t, "some_fancy_value", gobrew.homeDir) t.Log("test finished") } From 2a83bea0cff8051e435e704fe21b15681dd886e7 Mon Sep 17 00:00:00 2001 From: Pulkit Kathuria Date: Sat, 9 Dec 2023 13:46:33 +0900 Subject: [PATCH 15/15] should see yml and not yaml --- .github/workflows/build.yml | 1 + .github/workflows/coveritup.yml | 4 ++-- .github/workflows/test.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4305c12..4c2798e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: - '**/*.go' - '**/*.mod' - '**/*.sum' + - '**/*.yml' name: "Build" jobs: diff --git a/.github/workflows/coveritup.yml b/.github/workflows/coveritup.yml index f967ea4..b0d7f04 100644 --- a/.github/workflows/coveritup.yml +++ b/.github/workflows/coveritup.yml @@ -4,13 +4,13 @@ on: - '**/*.go' - '**/*.mod' - '**/*.sum' - - '**/*.yaml' + - '**/*.yml' push: paths: - '**/*.go' - '**/*.mod' - '**/*.sum' - - '**/*.yaml' + - '**/*.yml' name: "Cover It Up" jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b579737..95073e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: - '**/*.go' - '**/*.mod' - '**/*.sum' - - '**/*.yaml' + - '**/*.yml' name: "Go test" jobs: