From bc4b11ab9dadfe8b98421b7bb0b9a90d2c2b63dc Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 26 Jun 2024 15:01:36 +0300 Subject: [PATCH 1/3] Improvements --- .github/ISSUE_TEMPLATE.md | 52 ---------------------- .github/ISSUE_TEMPLATE/bug.yml | 64 +++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/question.yml | 26 +++++++++++ .github/ISSUE_TEMPLATE/suggestion.yml | 43 ++++++++++++++++++ .scripts/script.sh | 2 +- Makefile | 4 +- README.md | 10 +++-- cli/cli.go | 11 ++--- go.mod | 2 +- go.sum | 4 +- 11 files changed, 150 insertions(+), 69 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/ISSUE_TEMPLATE/suggestion.yml diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 4f031d4..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,52 +0,0 @@ -_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ πŸ‘ _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._ - -### Bug report - -**System info:** - -* **Verbose version info (`gomakegen -vv`):** -* **Go version (`go version`):** -* **Install tools:** - -**Steps to reproduce:** - -1. [First Step] -2. [Second Step] -3. [and so on...] - -**Expected behavior:** - -[What you expected to happen] - -**Actual behavior:** - -[What actually happened] - -**Additional info:** - -[Include gist of relevant config, logs, etc.] - -Please run those if possible and link them from a [gist](http://gist.github.com). - ---- - -### Feature Request - -Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. - -**Proposal:** - -[Description of the feature] - -**Current behavior:** - -[What currently happens] - -**Desired behavior:** - -[What you would like to happen] - -**Use case:** - -[Why is this important (helps with prioritizing requests)] - diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..c334363 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,64 @@ +name: ❗ Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["issue β€’ bug"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar bug reports. If so, please add a πŸ‘ reaction to the existing issue. + + - type: textarea + attributes: + label: Verbose application info + description: Output of `gomakegen -vv` command + render: shell + validations: + required: true + + - type: dropdown + id: version + attributes: + label: Install tools + description: How did you install this application + options: + - From Sources + - RPM Package + - Prebuilt Binary + default: 0 + validations: + required: true + + - type: textarea + attributes: + label: Steps to reproduce + description: Short guide on how to reproduce this problem on our site + placeholder: | + 1. [First Step] + 2. [Second Step] + 3. [and so on...] + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: What you expected to happen + validations: + required: true + + - type: textarea + attributes: + label: Actual behavior + description: What actually happened + validations: + required: true + + - type: textarea + attributes: + label: Additional info + description: Include gist of relevant config, logs, etc. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..18264e9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,26 @@ +name: ❓ Question +description: Question about application, configuration or code +title: "[Question]: " +labels: ["issue β€’ question"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar question. If so, please add a πŸ‘ reaction to the existing issue. + + - type: textarea + attributes: + label: Question + description: Detailed question + validations: + required: true + + - type: textarea + attributes: + label: Related version application info + description: Output of `gomakegen -vv` command + render: shell diff --git a/.github/ISSUE_TEMPLATE/suggestion.yml b/.github/ISSUE_TEMPLATE/suggestion.yml new file mode 100644 index 0000000..39c69e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggestion.yml @@ -0,0 +1,43 @@ +name: βž• Suggestion +description: Suggest new feature or improvement +title: "[Suggestion]: " +labels: ["issue β€’ suggestion"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar feature requests. If so, please add a πŸ‘ reaction to the existing issue. + > + > Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. + + - type: textarea + attributes: + label: Proposal + description: Description of the feature + validations: + required: true + + - type: textarea + attributes: + label: Current behavior + description: What currently happens + validations: + required: true + + - type: textarea + attributes: + label: Desired behavior + description: What you would like to happen + validations: + required: true + + - type: textarea + attributes: + label: Use case + description: Why is this important (helps with prioritizing requests) + validations: + required: true diff --git a/.scripts/script.sh b/.scripts/script.sh index b764eb7..92b503b 100755 --- a/.scripts/script.sh +++ b/.scripts/script.sh @@ -14,7 +14,7 @@ main() { sum1=$(checksum "Makefile") sum2=$(checksum "Makefile2") - if [[ "" != "" ]] ; then + if [[ "$sum1" != "$sum2" ]] ; then echo "Base Makefile differs from generated Makefile" exit 1 fi diff --git a/Makefile b/Makefile index bcc8eb3..057b5d2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ################################################################################ -# This Makefile generated by GoMakeGen 3.0.4 using next command: +# This Makefile generated by GoMakeGen 3.0.5 using next command: # gomakegen --mod --strip . # # More info: https://kaos.sh/gomakegen @@ -109,6 +109,6 @@ help: ## Show this info | sed 's/ifdef //' \ | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 3.0.4\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.0.5\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index f14d9eb..0d9d6bb 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@

- GitHub Actions CI Status - GitHub Actions CodeQL Status GoReportCard Codebeat badge + Codacy badge +
+ GitHub Actions CI Status + GitHub Actions CodeQL Status

@@ -16,7 +18,7 @@ ### Installation -To build the `gomakegen` from scratch, make sure you have a working Go 1.19+ workspace (_[instructions](https://go.dev/doc/install)_), then: +To build the `gomakegen` from scratch, make sure you have a working Go 1.21+ workspace (_[instructions](https://go.dev/doc/install)_), then: ``` go install github.com/essentialkaos/gomakegen@latest @@ -59,7 +61,7 @@ gomakegen --generate-man | sudo gzip > /usr/share/man/man1/gomakegen.1.gz ### Usage -

+ ### CI Status diff --git a/cli/cli.go b/cli/cli.go index d7b5611..34e01ba 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -47,7 +47,7 @@ import ( // App info const ( APP = "GoMakeGen" - VER = "3.0.4" + VER = "3.0.5" DESC = "Utility for generating makefiles for Go applications" ) @@ -548,8 +548,9 @@ func containsPackage(imports []string, pkgs []string) bool { // getBasePkgPath returns base package path func getBasePkgPath(dir string) string { - gopath := os.Getenv("GOPATH") + gopath, _ := filepath.EvalSymlinks(os.Getenv("GOPATH")) absDir, _ := filepath.Abs(dir) + absDir, _ = filepath.EvalSymlinks(absDir) return strutil.Exclude(absDir, gopath+"/src/") } @@ -561,10 +562,6 @@ func containsStableImports(imports []string) bool { } for _, pkg := range imports { - if strings.HasPrefix(pkg, "pkg.re") { - return true - } - if strings.HasPrefix(pkg, "gopkg.in") { return true } @@ -965,7 +962,7 @@ func (m *Makefile) getFuzzTarget() string { } result := "gen-fuzz: ## Generate archives for fuzz testing\n" - result += "\t@which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build\n" + result += "\t@which go-fuzz-build &>/dev/null || go install github.com/dvyukov/go-fuzz/go-fuzz-build@latest\n" result += getActionText(1, 1, "Generating fuzzing data…") for _, pkg := range m.FuzzPaths { diff --git a/go.mod b/go.mod index efe141a..3f73ced 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/essentialkaos/gomakegen go 1.19 -require github.com/essentialkaos/ek/v12 v12.127.0 +require github.com/essentialkaos/ek/v12 v12.128.0 require ( github.com/essentialkaos/depsy v1.3.0 // indirect diff --git a/go.sum b/go.sum index 07ba145..2cb9b37 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU= github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q= -github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= +github.com/essentialkaos/ek/v12 v12.128.0 h1:vaBvqvYZtkBxmiYSMllYA6MRbNbiOXcxwKEVbZqxxLE= +github.com/essentialkaos/ek/v12 v12.128.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= 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.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= From 7abfae0047bf1b2995705d3d7d4ac6331485b7d6 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 26 Jun 2024 15:13:18 +0300 Subject: [PATCH 2/3] Improve test script --- .scripts/script.sh | 12 +++++++----- cli/cli.go | 8 -------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.scripts/script.sh b/.scripts/script.sh index 92b503b..4e4320e 100755 --- a/.scripts/script.sh +++ b/.scripts/script.sh @@ -5,9 +5,7 @@ main() { local sum1 sum2 - mv Makefile Makefile2 - - ./gomakegen --mod --strip . + ./gomakegen --mod --strip . -o Makefile2 [[ $? -ne 0 ]] && exit 1 @@ -15,11 +13,15 @@ main() { sum2=$(checksum "Makefile2") if [[ "$sum1" != "$sum2" ]] ; then - echo "Base Makefile differs from generated Makefile" + echo "Current Makefile differs from generated Makefile" + diff Makefile Makefile2 + rm -f Makefile2 exit 1 fi - echo "Base Makefile is equals generated Makefile" + echo "Current Makefile is equal to generated Makefile" + + rm -f Makefile2 exit 0 } diff --git a/cli/cli.go b/cli/cli.go index 34e01ba..2230f08 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -1184,14 +1184,6 @@ func (m *Makefile) getGenerationComment() string { result += fmt.Sprintf("--%s ", getOptionName(OPT_RACE)) } - if options.GetS(OPT_OUTPUT) != "Makefile" { - result += fmt.Sprintf( - "--%s %s ", - getOptionName(OPT_OUTPUT), - options.GetS(OPT_OUTPUT), - ) - } - result += ".\n" result += "#\n" result += "# More info: https://kaos.sh/gomakegen\n\n" From f7752926e970ede66c23a3627893a9b41fa180c9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 26 Jun 2024 15:15:15 +0300 Subject: [PATCH 3/3] Remove test script --- .github/workflows/ci.yml | 4 ---- .scripts/script.sh | 35 ----------------------------------- 2 files changed, 39 deletions(-) delete mode 100755 .scripts/script.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 245f815..9f564f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,10 +46,6 @@ jobs: - name: Build binary run: make all - - name: Run tests - working-directory: ${{env.SRC_DIR}} - run: bash .scripts/script.sh - Typos: name: Typos runs-on: ubuntu-latest diff --git a/.scripts/script.sh b/.scripts/script.sh deleted file mode 100755 index 4e4320e..0000000 --- a/.scripts/script.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -################################################################################ - -main() { - local sum1 sum2 - - ./gomakegen --mod --strip . -o Makefile2 - - [[ $? -ne 0 ]] && exit 1 - - sum1=$(checksum "Makefile") - sum2=$(checksum "Makefile2") - - if [[ "$sum1" != "$sum2" ]] ; then - echo "Current Makefile differs from generated Makefile" - diff Makefile Makefile2 - rm -f Makefile2 - exit 1 - fi - - echo "Current Makefile is equal to generated Makefile" - - rm -f Makefile2 - - exit 0 -} - -checksum() { - sha256sum < "$1" | cut -f1 -d" " -} - -################################################################################ - -main "$@"