diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..16f4324 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,39 @@ +version: "2" + +checks: + argument-count: + enabled: true + config: + threshold: 6 + complex-logic: + enabled: true + config: + threshold: 6 + file-lines: + enabled: true + config: + threshold: 1000 + method-complexity: + enabled: true + config: + threshold: 8 + method-count: + enabled: true + config: + threshold: 20 + method-lines: + enabled: true + config: + threshold: 100 + nested-control-flow: + enabled: true + config: + threshold: 6 + return-statements: + enabled: true + config: + threshold: 6 + similar-code: + enabled: false + identical-code: + enabled: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad303fb..22e6a5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - SRC_DIR: src/github.com/${{ github.repository }} - jobs: Go: name: Go @@ -37,22 +34,18 @@ jobs: go: [ '1.19.x', '1.20.x' ] steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} - - name: Checkout - uses: actions/checkout@v3 - with: - path: ${{env.SRC_DIR}} - - name: Download dependencies - working-directory: ${{env.SRC_DIR}} run: make deps - name: Build binary - working-directory: ${{env.SRC_DIR}} run: make all Perfecto: @@ -91,3 +84,16 @@ jobs: uses: essentialkaos/hadolint-action@v1 with: files: .docker/ruby.docker .docker/ruby-jemalloc.docker .docker/ruby-railsexpress.docker .docker/jruby.docker + + Typos: + name: Typos + runs-on: ubuntu-latest + + needs: Go + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Check spelling + uses: crate-ci/typos@master diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..55aead8 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,2 @@ +[files] +extend-exclude = ["go.sum"] diff --git a/Makefile b/Makefile index 90acf98..d1cb749 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.1.0 using next command: +# This Makefile generated by GoMakeGen 2.2.0 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen @@ -106,6 +106,6 @@ help: ## Show this info | sed 's/ifdef //' \ | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.1.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 5334c2a..fefc37a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@

- GitHub Actions CI Status GoReportCard + Code Climate Maintainability codebeat badge + GitHub Actions CI Status GitHub Actions CodeQL Status

diff --git a/cli/cli.go b/cli/cli.go index 45bb25e..7c28312 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -66,7 +66,7 @@ import ( // App info const ( APP = "RBInstall" - VER = "3.0.1" + VER = "3.0.2" DESC = "Utility for installing prebuilt Ruby versions to RBEnv" ) @@ -151,8 +151,8 @@ var optMap = options.Map{ OPT_INFO: {Type: options.BOOL}, OPT_NO_COLOR: {Type: options.BOOL}, OPT_NO_PROGRESS: {Type: options.BOOL}, - OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, - OPT_VER: {Type: options.BOOL, Alias: "ver"}, + OPT_HELP: {Type: options.BOOL}, + OPT_VER: {Type: options.MIXED}, OPT_VERB_VER: {Type: options.BOOL}, OPT_COMPLETION: {}, @@ -206,7 +206,7 @@ func Run(gitRev string, gomod []byte) { printMan() os.Exit(0) case options.GetB(OPT_VER): - genAbout(gitRev).Print() + genAbout(gitRev).Print(options.GetS(OPT_VER)) os.Exit(0) case options.GetB(OPT_VERB_VER): support.Print(APP, VER, gitRev, gomod) @@ -394,7 +394,10 @@ func validateConfig() { // fetchIndex download index from remote repository func fetchIndex() { - resp, err := req.Request{URL: knf.GetS(STORAGE_URL) + "/" + INDEX_NAME}.Get() + resp, err := req.Request{ + URL: knf.GetS(STORAGE_URL) + "/" + INDEX_NAME, + Query: req.Query{"r": time.Now().UnixMicro()}, + }.Get() if err != nil { printErrorAndExit("Can't fetch repository index: %v", err) @@ -1139,7 +1142,10 @@ func downloadFile(info *index.VersionInfo) (string, error) { defer fd.Close() - resp, err := req.Request{URL: knf.GetS(STORAGE_URL) + "/" + info.Path + "/" + info.File}.Do() + resp, err := req.Request{ + URL: knf.GetS(STORAGE_URL) + "/" + info.Path + "/" + info.File, + Query: req.Query{"hash": info.Hash}, + }.Get() if err != nil { return "", err diff --git a/clone/clone.go b/clone/clone.go index 6ea3e7a..ef9f7a3 100644 --- a/clone/clone.go +++ b/clone/clone.go @@ -199,7 +199,7 @@ func checkArguments(url, dir string) { } if !fsutil.IsExecutable(dir) { - printErrorAndExit("Directory %s is not exectable", dir) + printErrorAndExit("Directory %s is not executable", dir) } } diff --git a/common/rbinstall.knf b/common/rbinstall.knf index 176bad5..54deb04 100644 --- a/common/rbinstall.knf +++ b/common/rbinstall.knf @@ -2,7 +2,7 @@ [main] - # Path to writable temorary directory + # Path to writable temporary directory tmp-dir: /tmp [storage] diff --git a/common/rbinstall.spec b/common/rbinstall.spec index ea6e3dc..9aaf7a4 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -10,7 +10,7 @@ Summary: Utility for installing prebuilt Ruby to rbenv Name: rbinstall -Version: 3.0.1 +Version: 3.0.2 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -24,7 +24,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: rbenv libyaml ca-certificates zlib >= 1.2.11 -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.20 Provides: %{name} = %{version}-%{release} @@ -118,6 +118,10 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Fri May 05 2023 Anton Novojilov - 3.0.2-0 +- [cli] Better caching handling +- Dependencies update + * Mon Mar 27 2023 Anton Novojilov - 3.0.1-0 - [cli|gen|clone] Added verbose version output - Dependencies update diff --git a/gen/gen.go b/gen/gen.go index 6a86ef6..9c72802 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -236,7 +236,7 @@ func checkDir(dataDir string) { } if !fsutil.IsExecutable(dataDir) { - printErrorAndExit("Directory %s is not exectable", dataDir) + printErrorAndExit("Directory %s is not executable", dataDir) } if options.GetS(OPT_OUTPUT) == "" && !fsutil.IsWritable(dataDir) { diff --git a/go.mod b/go.mod index 67c8f56..eeaa5a6 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,14 @@ module github.com/essentialkaos/rbinstall go 1.18 require ( - github.com/essentialkaos/depsy v1.0.0 - github.com/essentialkaos/ek/v12 v12.63.0 - github.com/essentialkaos/npck v1.2.1 + github.com/essentialkaos/depsy v1.1.0 + github.com/essentialkaos/ek/v12 v12.67.0 + github.com/essentialkaos/npck v1.5.0 ) require ( - github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - github.com/klauspost/compress v1.16.3 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/sys v0.6.0 // indirect + github.com/klauspost/compress v1.16.5 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/sys v0.8.0 // indirect ) diff --git a/go.sum b/go.sum index 79833e0..ea25130 100644 --- a/go.sum +++ b/go.sum @@ -1,20 +1,18 @@ -github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/depsy v1.0.0 h1:FikBtTnNhk+xFO/hFr+CfiKs6QnA3wMD6tGL0XTEUkc= -github.com/essentialkaos/depsy v1.0.0/go.mod h1:XVsB2eVUonEzmLKQP3ig2P6v2+WcHVgJ10zm0JLqFMM= -github.com/essentialkaos/ek/v12 v12.63.0 h1:9yaEu5W3bx//9y52ShqYCoFDKOcwEdrnvgSkUYyatgI= -github.com/essentialkaos/ek/v12 v12.63.0/go.mod h1:9MlSuHpewu7OZ9tM9dLFHvoA8dflBIUPCA0Ctt97wRs= +github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= +github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= +github.com/essentialkaos/ek/v12 v12.67.0 h1:ii15t0O+3Mu7uI3Te5X5BIqYXi1V7ovtSIYi5LyiltU= +github.com/essentialkaos/ek/v12 v12.67.0/go.mod h1:sRgw+F7PeeoNsmLLVMKy5ccugwGSljk8/rTXC9dyT+M= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= -github.com/essentialkaos/npck v1.2.1 h1:OXLlRR39sk+3sKOJN5WzXlux295yI46YI/62+j3ytIw= -github.com/essentialkaos/npck v1.2.1/go.mod h1:UeYjyKd/FNcU767VgLYuGkfCu68VW9ZMynukScJOTc0= -github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= -github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/essentialkaos/npck v1.5.0 h1:YkvHywXX1g7mUhGyN97ZAsg4l3kSwGhhFmQBa+e7upA= +github.com/essentialkaos/npck v1.5.0/go.mod h1:hbphr/PCfljbolELHLmRXxNX1nV78JIUMteUP9gg2l4= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=