From 119835c64dd13a4e2611cea91007b218f3d1207f Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 17:17:28 -0300 Subject: [PATCH 1/6] Check if cheatsheets are up to date on CI --- .github/workflows/ci.yml | 3 + docs/keybindings/Keybindings_de.md | 2 +- docs/keybindings/Keybindings_en.md | 2 +- docs/keybindings/Keybindings_nl.md | 2 +- docs/keybindings/Keybindings_pl.md | 2 +- docs/keybindings/Keybindings_tr.md | 2 +- .../cheatsheet/generate.go | 13 ++- pkg/cheatsheet/validate.go | 87 +++++++++++++++++++ pkg/utils/utils.go | 31 +++++++ scripts/cheatsheet/main.go | 27 ++++++ 10 files changed, 162 insertions(+), 9 deletions(-) rename scripts/generate_cheatsheet.go => pkg/cheatsheet/generate.go (93%) create mode 100644 pkg/cheatsheet/validate.go create mode 100644 scripts/cheatsheet/main.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index deab1a1e..035f4b2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test restore-keys: | ${{runner.os}}-go- + - name: Check Cheatsheet + run: | + go run scripts/cheatsheet/main.go check - name: Test code run: | bash ./test.sh diff --git a/docs/keybindings/Keybindings_de.md b/docs/keybindings/Keybindings_de.md index 3258e52a..458cf793 100644 --- a/docs/keybindings/Keybindings_de.md +++ b/docs/keybindings/Keybindings_de.md @@ -1,4 +1,4 @@ -_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/cheatsheet/main.go generate` from the project root._ # Lazydocker menĂ¼ diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index db306cda..dd0925e2 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -1,4 +1,4 @@ -_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/cheatsheet/main.go generate` from the project root._ # Lazydocker menu diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 6f86660b..00dc7f88 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -1,4 +1,4 @@ -_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/cheatsheet/main.go generate` from the project root._ # Lazydocker menu diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 921b3db8..174beb15 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -1,4 +1,4 @@ -_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/cheatsheet/main.go generate` from the project root._ # Lazydocker menu diff --git a/docs/keybindings/Keybindings_tr.md b/docs/keybindings/Keybindings_tr.md index 4c16e232..bb83faee 100644 --- a/docs/keybindings/Keybindings_tr.md +++ b/docs/keybindings/Keybindings_tr.md @@ -1,4 +1,4 @@ -_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/generate_cheatsheet.go` from the project root._ +_This file is auto-generated. To update, make the changes in the pkg/i18n directory and then run `go run scripts/cheatsheet/main.go generate` from the project root._ # Lazydocker menĂ¼ diff --git a/scripts/generate_cheatsheet.go b/pkg/cheatsheet/generate.go similarity index 93% rename from scripts/generate_cheatsheet.go rename to pkg/cheatsheet/generate.go index 67b51f07..19dff300 100644 --- a/scripts/generate_cheatsheet.go +++ b/pkg/cheatsheet/generate.go @@ -6,7 +6,7 @@ // To generate cheatsheet in english run: // LANG=en go run scripts/generate_cheatsheet.go -package main +package cheatsheet import ( "fmt" @@ -20,7 +20,7 @@ import ( ) const ( - generateCheatsheetCmd = "go run scripts/generate_cheatsheet.go" + generateCheatsheetCmd = "go run scripts/cheatsheet/main.go generate" ) type bindingSection struct { @@ -28,7 +28,11 @@ type bindingSection struct { bindings []*gui.Binding } -func main() { +func Generate() { + generateAtDir(GetKeybindingsDir()) +} + +func generateAtDir(dir string) { mConfig, err := config.NewAppConfig("lazydocker", "", "", "", "", true, nil, "") if err != nil { panic(err) @@ -37,7 +41,8 @@ func main() { for lang := range i18n.GetTranslationSets() { os.Setenv("LC_ALL", lang) mApp, _ := app.NewApp(mConfig) - file, err := os.Create("./docs/keybindings/Keybindings_" + lang + ".md") + + file, err := os.Create(dir + "/Keybindings_" + lang + ".md") if err != nil { panic(err) } diff --git a/pkg/cheatsheet/validate.go b/pkg/cheatsheet/validate.go new file mode 100644 index 00000000..1ad33681 --- /dev/null +++ b/pkg/cheatsheet/validate.go @@ -0,0 +1,87 @@ +package cheatsheet + +import ( + "fmt" + "io/fs" + "log" + "os" + "path/filepath" + "regexp" + + "github.com/jesseduffield/lazydocker/pkg/utils" + "github.com/pmezard/go-difflib/difflib" +) + +func Check() { + dir := GetKeybindingsDir() + tmpDir := filepath.Join(os.TempDir(), "lazydocker_cheatsheet") + + err := os.RemoveAll(tmpDir) + if err != nil { + log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err) + } + defer os.RemoveAll(tmpDir) + + if err = os.Mkdir(tmpDir, 0o700); err != nil { + log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err) + } + + generateAtDir(tmpDir) + + actualContent := obtainContent(dir) + expectedContent := obtainContent(tmpDir) + + if expectedContent == "" { + log.Fatal("empty expected content") + } + + if actualContent != expectedContent { + if err := difflib.WriteUnifiedDiff(os.Stdout, difflib.UnifiedDiff{ + A: difflib.SplitLines(expectedContent), + B: difflib.SplitLines(actualContent), + FromFile: "Expected", + FromDate: "", + ToFile: "Actual", + ToDate: "", + Context: 1, + }); err != nil { + log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err) + } + fmt.Printf( + "\nCheatsheets are out of date. Please run `%s` at the project root and commit the changes. "+ + "If you run the script and no keybindings files are updated as a result, try rebasing onto master"+ + "and trying again.\n", + generateCheatsheetCmd, + ) + os.Exit(1) + } + + fmt.Println("\nCheatsheets are up to date") +} + +func GetKeybindingsDir() string { + return utils.GetLazydockerRootDirectory() + "/docs/keybindings" +} + +func obtainContent(dir string) string { + re := regexp.MustCompile(`Keybindings_\w+\.md$`) + + content := "" + err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if re.MatchString(path) { + bytes, err := os.ReadFile(path) + if err != nil { + log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err) + } + content += fmt.Sprintf("\n%s\n\n", filepath.Base(path)) + content += string(bytes) + } + + return nil + }) + if err != nil { + log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err) + } + + return content +} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index fe1ae3de..baf5cf5c 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -5,7 +5,10 @@ import ( "fmt" "html/template" "io" + "log" "math" + "os" + "path/filepath" "reflect" "regexp" "sort" @@ -408,3 +411,31 @@ func IsValidHexValue(v string) bool { return true } + +// GetLazydockerRootDirectory finds lazydocker root directory. +// +// It's used for our cheatsheet script and integration tests. Not to be confused with finding the +// root directory of _any_ random repo. +func GetLazydockerRootDirectory() string { + path, err := os.Getwd() + if err != nil { + panic(err) + } + + for { + _, err := os.Stat(filepath.Join(path, ".git")) + if err == nil { + return path + } + + if !os.IsNotExist(err) { + panic(err) + } + + path = filepath.Dir(path) + + if path == "/" { + log.Fatal("must run in lazydocker folder or child folder") + } + } +} diff --git a/scripts/cheatsheet/main.go b/scripts/cheatsheet/main.go new file mode 100644 index 00000000..53f72eda --- /dev/null +++ b/scripts/cheatsheet/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "log" + "os" + + "github.com/jesseduffield/lazydocker/pkg/cheatsheet" +) + +func main() { + if len(os.Args) < 2 { + log.Fatal("Please provide a command: one of 'generate', 'check'") + } + + command := os.Args[1] + + switch command { + case "generate": + cheatsheet.Generate() + fmt.Printf("\nGenerated cheatsheets in %s\n", cheatsheet.GetKeybindingsDir()) + case "check": + cheatsheet.Check() + default: + log.Fatal("\nUnknown command. Expected one of 'generate', 'check'") + } +} From c56256358ab4b3b1ad822468212f5ad88c15ee19 Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 17:29:25 -0300 Subject: [PATCH 2/6] Clean up --- pkg/cheatsheet/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index 19dff300..8c25da30 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -4,7 +4,7 @@ // The content of this generated file is a keybindings cheatsheet. // // To generate cheatsheet in english run: -// LANG=en go run scripts/generate_cheatsheet.go +// LANG=en go run scripts/cheatsheet/main.go generate package cheatsheet From 337e57afbb32057a96c978b7f6d74ff1aa213b28 Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 18:29:17 -0300 Subject: [PATCH 3/6] Bump lazycore --- go.mod | 5 +-- go.sum | 6 +-- pkg/cheatsheet/validate.go | 4 +- .../golang-collections/collections/LICENSE | 20 --------- .../collections/stack/stack.go | 44 ------------------- .../jesseduffield/lazycore/pkg/utils/utils.go | 35 +++++++++++++++ vendor/modules.txt | 3 +- 7 files changed, 42 insertions(+), 75 deletions(-) delete mode 100644 vendor/github.com/golang-collections/collections/LICENSE delete mode 100644 vendor/github.com/golang-collections/collections/stack/stack.go diff --git a/go.mod b/go.mod index b8a9dcd7..84730748 100644 --- a/go.mod +++ b/go.mod @@ -9,18 +9,18 @@ require ( github.com/docker/docker v20.10.15+incompatible github.com/fatih/color v1.7.0 github.com/go-errors/errors v1.4.2 - github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/gookit/color v1.5.0 github.com/imdario/mergo v0.3.8 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/asciigraph v0.0.0-20190605104717-6d88e39309ee github.com/jesseduffield/gocui v0.3.1-0.20220417002912-bce22fd599f6 github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 - github.com/jesseduffield/lazycore v0.0.0-20221009164442-17c8b878c316 + github.com/jesseduffield/lazycore v0.0.0-20221010211550-2c30efd18b93 github.com/jesseduffield/yaml v0.0.0-20190702115811-b900b7e08b56 github.com/mattn/go-runewidth v0.0.13 github.com/mcuadros/go-lookup v0.0.0-20171110082742-5650f26be767 github.com/mgutz/str v1.2.0 + github.com/pmezard/go-difflib v1.0.0 github.com/samber/lo v1.31.0 github.com/sirupsen/logrus v1.4.2 github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad @@ -48,7 +48,6 @@ require ( github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect diff --git a/go.sum b/go.sum index 7daa24f7..05c3753c 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,6 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4= -github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -54,8 +52,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20220417002912-bce22fd599f6 h1:Fmay0Lz21 github.com/jesseduffield/gocui v0.3.1-0.20220417002912-bce22fd599f6/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo= -github.com/jesseduffield/lazycore v0.0.0-20221009164442-17c8b878c316 h1:UzTg0utG+cLS94Qjb/ZFDzfMeZDFXErSbNgJOyj70EA= -github.com/jesseduffield/lazycore v0.0.0-20221009164442-17c8b878c316/go.mod h1:qxN4mHOAyeIDLP7IK7defgPClM/z1Kze8VVQiaEjzsQ= +github.com/jesseduffield/lazycore v0.0.0-20221010211550-2c30efd18b93 h1:zY7ymCjXC7fZeJVXDpiicYx6c2YFgvsdZSOdch2f7gU= +github.com/jesseduffield/lazycore v0.0.0-20221010211550-2c30efd18b93/go.mod h1:qxN4mHOAyeIDLP7IK7defgPClM/z1Kze8VVQiaEjzsQ= github.com/jesseduffield/yaml v0.0.0-20190702115811-b900b7e08b56 h1:33wSxJWU/f2TAozHYtJ8zqBxEnEVYM+22moLoiAkxvg= github.com/jesseduffield/yaml v0.0.0-20190702115811-b900b7e08b56/go.mod h1:FZJBwOhE+RXz8EVZfY+xnbCw2cVOwxlK3/aIi581z/s= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= diff --git a/pkg/cheatsheet/validate.go b/pkg/cheatsheet/validate.go index 1ad33681..033c7def 100644 --- a/pkg/cheatsheet/validate.go +++ b/pkg/cheatsheet/validate.go @@ -8,7 +8,7 @@ import ( "path/filepath" "regexp" - "github.com/jesseduffield/lazydocker/pkg/utils" + "github.com/jesseduffield/lazycore/pkg/utils" "github.com/pmezard/go-difflib/difflib" ) @@ -60,7 +60,7 @@ func Check() { } func GetKeybindingsDir() string { - return utils.GetLazydockerRootDirectory() + "/docs/keybindings" + return utils.GetLazyRootDirectory() + "/docs/keybindings" } func obtainContent(dir string) string { diff --git a/vendor/github.com/golang-collections/collections/LICENSE b/vendor/github.com/golang-collections/collections/LICENSE deleted file mode 100644 index 863a984d..00000000 --- a/vendor/github.com/golang-collections/collections/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2012 Caleb Doxsey - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/golang-collections/collections/stack/stack.go b/vendor/github.com/golang-collections/collections/stack/stack.go deleted file mode 100644 index 11f472a9..00000000 --- a/vendor/github.com/golang-collections/collections/stack/stack.go +++ /dev/null @@ -1,44 +0,0 @@ -package stack - -type ( - Stack struct { - top *node - length int - } - node struct { - value interface{} - prev *node - } -) -// Create a new stack -func New() *Stack { - return &Stack{nil,0} -} -// Return the number of items in the stack -func (this *Stack) Len() int { - return this.length -} -// View the top item on the stack -func (this *Stack) Peek() interface{} { - if this.length == 0 { - return nil - } - return this.top.value -} -// Pop the top item of the stack and return it -func (this *Stack) Pop() interface{} { - if this.length == 0 { - return nil - } - - n := this.top - this.top = n.prev - this.length-- - return n.value -} -// Push a value onto the top of the stack -func (this *Stack) Push(value interface{}) { - n := &node{value,this.top} - this.top = n - this.length++ -} \ No newline at end of file diff --git a/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go b/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go index 9fa93376..9d0c2cc6 100644 --- a/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go +++ b/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go @@ -1,5 +1,11 @@ package utils +import ( + "log" + "os" + "path/filepath" +) + // Min returns the minimum of two integers func Min(x, y int) int { if x < y { @@ -8,9 +14,38 @@ func Min(x, y int) int { return y } +// Max returns the maximum of two integers func Max(x, y int) int { if x > y { return x } return y } + +// GetLazyRootDirectory finds a lazy project root directory. +// +// It's used for cheatsheet scripts and integration tests. Not to be confused with finding the +// root directory of _any_ random repo. +func GetLazyRootDirectory() string { + path, err := os.Getwd() + if err != nil { + panic(err) + } + + for { + _, err := os.Stat(filepath.Join(path, ".git")) + if err == nil { + return path + } + + if !os.IsNotExist(err) { + panic(err) + } + + path = filepath.Dir(path) + + if path == "/" { + log.Fatal("must run in lazy project folder or child folder") + } + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index a8818516..400209c5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -102,7 +102,6 @@ github.com/go-errors/errors github.com/gogo/protobuf/proto # github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 ## explicit -github.com/golang-collections/collections/stack # github.com/gookit/color v1.5.0 ## explicit; go 1.13 github.com/gookit/color @@ -121,7 +120,7 @@ github.com/jesseduffield/gocui # github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 ## explicit; go 1.18 github.com/jesseduffield/kill -# github.com/jesseduffield/lazycore v0.0.0-20221009164442-17c8b878c316 +# github.com/jesseduffield/lazycore v0.0.0-20221010211550-2c30efd18b93 ## explicit; go 1.18 github.com/jesseduffield/lazycore/pkg/boxlayout github.com/jesseduffield/lazycore/pkg/utils From 1cb9506554499da22606a2e9a15aa383cfec299d Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 18:42:14 -0300 Subject: [PATCH 4/6] Update CI jobs: Add check-codebase --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ vendor/modules.txt | 2 -- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 035f4b2e..74929e8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,34 @@ jobs: - name: Build darwin binary run: | GOOS=darwin go build + check-codebase: + runs-on: ubuntu-latest + env: + GOFLAGS: -mod=vendor + GOARCH: amd64 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: 1.18.x + - name: Cache build + uses: actions/cache@v1 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-build + restore-keys: | + ${{runner.os}}-go- + - name: Check Cheatsheet + run: | + go run scripts/cheatsheet/main.go check + - name: Check Vendor Directory + # ensure our vendor directory matches up with our go modules + run: | + go mod vendor && git diff --exit-code || (echo "Unexpected change to vendor directory. Run 'go mod vendor' locally and commit the changes" && exit 1) lint: runs-on: ubuntu-latest env: diff --git a/vendor/modules.txt b/vendor/modules.txt index 400209c5..47f06975 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -100,8 +100,6 @@ github.com/go-errors/errors # github.com/gogo/protobuf v1.3.1 ## explicit github.com/gogo/protobuf/proto -# github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 -## explicit # github.com/gookit/color v1.5.0 ## explicit; go 1.13 github.com/gookit/color From dd11b0ee1060cc372946218956bfdb1034e0f3f1 Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 18:43:18 -0300 Subject: [PATCH 5/6] Update CI jobs: Remove Check Cheatsheet from ci job --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74929e8b..7ffbda56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,9 +35,6 @@ jobs: key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test restore-keys: | ${{runner.os}}-go- - - name: Check Cheatsheet - run: | - go run scripts/cheatsheet/main.go check - name: Test code run: | bash ./test.sh From 574e0b6f906b50b1c196f0b97b81a4018e097b9c Mon Sep 17 00:00:00 2001 From: Gustavo Andrioli Date: Mon, 10 Oct 2022 21:22:55 -0300 Subject: [PATCH 6/6] Remove GetLazydockerRootDirectory function --- pkg/utils/utils.go | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index baf5cf5c..fe1ae3de 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -5,10 +5,7 @@ import ( "fmt" "html/template" "io" - "log" "math" - "os" - "path/filepath" "reflect" "regexp" "sort" @@ -411,31 +408,3 @@ func IsValidHexValue(v string) bool { return true } - -// GetLazydockerRootDirectory finds lazydocker root directory. -// -// It's used for our cheatsheet script and integration tests. Not to be confused with finding the -// root directory of _any_ random repo. -func GetLazydockerRootDirectory() string { - path, err := os.Getwd() - if err != nil { - panic(err) - } - - for { - _, err := os.Stat(filepath.Join(path, ".git")) - if err == nil { - return path - } - - if !os.IsNotExist(err) { - panic(err) - } - - path = filepath.Dir(path) - - if path == "/" { - log.Fatal("must run in lazydocker folder or child folder") - } - } -}