diff --git a/.github/ISSUE_TEMPLATE/BugReport.yml b/.github/ISSUE_TEMPLATE/BugReport.yml new file mode 100644 index 0000000..c6dbede --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BugReport.yml @@ -0,0 +1,51 @@ +name: Bug Report +description: Report a bug +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to help everyone identify and fix the bug + - type: textarea + id: description + attributes: + label: Describe your issue + placeholder: When I click here this happens + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + placeholder: | + 1. Enhance this function + 2. Refactor this + 3. Refactor that + validations: + required: true + - type: textarea + id: expected + attributes: + label: What was the expected result? + placeholder: I expected this to happen + - type: textarea + id: screenshots + attributes: + label: Put here any screenshots or videos (optional) + - type: textarea + id: deviceinfo + attributes: + label: Your OS and Browser (optional) + placeholder: | + - OS: Windows 10 + - Browser: Chrome 90.0 + - type: dropdown + id: assign + attributes: + label: "Would you like to work on this issue?" + options: + - "Yes" + - type: markdown + attributes: + value: | + Thanks for reporting this issue! We will get back to you as soon as possible. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/NewFeature.yml b/.github/ISSUE_TEMPLATE/NewFeature.yml new file mode 100644 index 0000000..e284c58 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/NewFeature.yml @@ -0,0 +1,36 @@ +name: New feature +description: Suggest or request a new feature +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + Please fill out the sections below to properly describe the new feature you are suggesting. + - type: textarea + id: description + attributes: + label: Describe the feature + placeholder: A feature X that allows to do Y + validations: + required: true + - type: textarea + id: rationale + attributes: + label: It should be implemented because + placeholder: It will allow to do Y that is needed for Z + - type: textarea + id: context + attributes: + label: Additional context + placeholder: | + Add any other context or screenshots about the feature request here. + - type: dropdown + id: assign + attributes: + label: "Would you like to work on this issue?" + options: + - "Yes" + - type: markdown + attributes: + value: | + Thanks for your suggestion! Let's see together if it can be implemented. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/README.md b/.github/ISSUE_TEMPLATE/README.md new file mode 100644 index 0000000..d3c7471 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/README.md @@ -0,0 +1,17 @@ +# Issues template + +I created this template to help you report bugs or suggest new features more easily without having to manually write them. + +If you have any questions, please submit a Pull Request (PR) or open Issues. + +If you can improve my issues template, please open a PR. + + +image +
You can choose one of these three
+ +image +
Bug Report
+ +image +
New Feature
\ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4ede34a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,94 @@ +name: Release + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + branches: [ '**' ] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + quality-and-release: + name: Quality & Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + cache: true + + - name: Tidy + run: go mod tidy + + - name: Run Linter + uses: golangci/golangci-lint-action@v8 + with: + version: v2.11.4 + + - name: Run Tests + run: go test -v ./... + + - name: Build Binaries + if: startsWith(github.ref, 'refs/tags/v') + run: | + mkdir -p dist + platforms=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64") + for platform in "${platforms[@]}"; do + os_arch=(${platform//\// }) + GOOS=${os_arch[0]} + GOARCH=${os_arch[1]} + output_name="iris" + [ "$GOOS" == "windows" ] && output_name="iris.exe" + + echo "Building $GOOS/$GOARCH..." + GOOS=$GOOS GOARCH=$GOARCH go build \ + -ldflags="-s -w -X github.com/versenilvis/iris/root.Version=${{ github.ref_name }}" \ + -trimpath -o "dist/$output_name" main.go + + cd dist + tar -czf "iris_${GOOS}_${GOARCH}.tar.gz" "$output_name" + rm "$output_name" + cd .. + done + + - name: Prepare Release Notes + if: startsWith(github.ref, 'refs/tags/v') + run: | + # Generate standard GitHub release notes + GEN_NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes -f tag_name=${{ github.ref_name }} --jq .body) + + echo "RELEASE_BODY<> $GITHUB_ENV + echo "$GEN_NOTES" >> $GITHUB_ENV + echo "" >> $GITHUB_ENV + echo "## Installation" >> $GITHUB_ENV + echo "\`\`\`bash" >> $GITHUB_ENV + echo "curl -sS https://raw.githubusercontent.com/versenilvis/iris/main/scripts/install.sh | sudo sh" >> $GITHUB_ENV + echo "\`\`\`" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v1 + with: + name: ${{ github.ref_name }} + body: ${{ env.RELEASE_BODY }} + files: dist/*.tar.gz + generate_release_notes: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 0000000..8e21fe0 --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,26 @@ +name: Spelling + +permissions: + contents: read + +on: + push: + branches: + - main + pull_request: + +env: + CLICOLOR: 1 + +jobs: + spelling: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Spell Check Repo + uses: crate-ci/typos@v1.29.4 diff --git a/.golangci.yml b/.golangci.yml index 75d886d..35a51e0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,35 +1,43 @@ -version: 2 +version: "2" run: - timeout: 5m - tests: true + timeout: 5m + tests: true linters: - disable-all: true - enable: - - errcheck - - govet - - staticcheck - - errorlint - - errname - - bodyclose - - sqlclosecheck - - noctx - - ineffassign - - unconvert - - bidichk - -linters-settings: + default: none + enable: + - errcheck + - govet + - staticcheck + - errorlint + - errname + - bodyclose + - sqlclosecheck + - noctx + - ineffassign + - unconvert + - bidichk + settings: errcheck: - check-type-assertions: true - check-blank: true - + check-type-assertions: true + check-blank: false + exclude-functions: + - fmt.Print + - fmt.Println + - fmt.Printf + - fmt.Fprint + - fmt.Fprintln + - fmt.Fprintf govet: - enable-all: true - disable: - - fieldalignment + enable-all: true + disable: + - fieldalignment + exclusions: + rules: + - linters: [errcheck] + source: "^\\s*defer " issues: - exclude-use-default: false - max-issues-per-linter: 0 - max-same-issues: 0 + max-issues-per-linter: 0 + max-same-issues: 0 \ No newline at end of file diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..8078777 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,2 @@ +[default.extend-words] +hel = "hel" diff --git a/go.mod b/go.mod index 0de7f5d..e8646e6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/versenilvis/iris -go 1.26.1 +go 1.24.0 require ( github.com/charmbracelet/lipgloss v1.1.0 @@ -29,7 +29,3 @@ require ( github.com/spf13/pflag v1.0.10 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect ) - -// this is my personal project, I want to point to my local folder to debug and develop -// the github version is the stable one -replace github.com/versenilvis/fuzzy => ../fuzzy diff --git a/go.sum b/go.sum index baf79b0..12854d3 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/versenilvis/fuzzy v0.1.0-rc h1:QfEBVtjSFPklFeLP4cxLLpjDNauOyzcegYvyI2tT7UY= +github.com/versenilvis/fuzzy v0.1.0-rc/go.mod h1:TCgCwxBa4px8NhCXH8SPePCyJsf/qPsl1i+G/HDdjyg= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= diff --git a/ipc/server.go b/ipc/server.go index 10e50b1..d5a7702 100644 --- a/ipc/server.go +++ b/ipc/server.go @@ -24,7 +24,10 @@ func NewServer() (*Server, error) { return nil, err } - localAddr := conn.LocalAddr().(*net.UDPAddr) + localAddr, ok := conn.LocalAddr().(*net.UDPAddr) + if !ok { + return nil, net.InvalidAddrError("not a UDP address") + } s := &Server{ conn: conn, diff --git a/root/wrapper.go b/root/wrapper.go index eeaceb0..f31b01b 100644 --- a/root/wrapper.go +++ b/root/wrapper.go @@ -121,7 +121,7 @@ func runWrapper() { case syscall.SIGWINCH: _ = pty.InheritSize(os.Stdin, ptmx) // handle terminal window resize // this is the core feature of reloading - // it helps IRIS reload itself that you dont need to restart the shell mannually + // it helps IRIS reload itself that you dont need to restart the shell manually // SIGUSR1 is the signal to active reload when you type "just reload" case syscall.SIGUSR1: // trigger iris reload by executing itself again @@ -508,10 +508,10 @@ func runWrapper() { _, _ = ptmx.Write([]byte{0x15}) // ctrl+u to clear line _, _ = ptmx.Write([]byte(selected)) - overlay.Cursor = 0 // this prevents when you tab, it switchs between suggestions non-stop + overlay.Cursor = 0 // this prevents when you tab, it switches between suggestions non-stop shouldOverlayDraw = true // <- rerender after tab to choose, if you set to false, - // when you press tab continuely, it will print all folder from menu suggestions + // when you press tab continually, it will print all folder from menu suggestions // and make the cursor jump to next line userNavigated = false } diff --git a/tests/dev/git_test.go b/tests/dev/git_test.go index 64147ce..2b01912 100644 --- a/tests/dev/git_test.go +++ b/tests/dev/git_test.go @@ -22,10 +22,14 @@ func TestGitSuggestions(t *testing.T) { ctx := context.Background() // Initialize git repo _ = exec.CommandContext(ctx, "git", "init").Run() + + _ = exec.CommandContext(ctx, "git", "config", "user.email", "iris-test@example.com").Run() // this is for ci/cd + _ = exec.CommandContext(ctx, "git", "config", "user.name", "Iris Test").Run() // this is for ci/cd + _ = os.WriteFile(filepath.Join(tmp, "file.go"), []byte("package main"), 0644) _ = exec.CommandContext(ctx, "git", "add", ".").Run() _ = exec.CommandContext(ctx, "git", "commit", "-m", "initial").Run() - + // Create branches _ = exec.CommandContext(ctx, "git", "branch", "feature/login").Run() _ = exec.CommandContext(ctx, "git", "branch", "dev").Run() @@ -87,7 +91,7 @@ func TestGitSuggestions(t *testing.T) { t.Run("git reset options", func(t *testing.T) { // git reset --soft origin/main -> should be accepted (just testing lookup doesn't crash) _ = core.Lookup("git reset --soft origin/main ") - + // git reset HEAD -> show files res := core.Lookup("git reset HEAD ") found := false @@ -145,7 +149,7 @@ func TestGitSuggestions(t *testing.T) { // find current branch out, _ := exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD").Output() current := strings.TrimSpace(string(out)) - + res := core.Lookup("git checkout ") for _, r := range res { if strings.Contains(r.Cmd, current) && !strings.Contains(r.Cmd, "remotes/") { diff --git a/tests/root/update_test.go b/tests/root/update_test.go index 898f7e1..7a32314 100644 --- a/tests/root/update_test.go +++ b/tests/root/update_test.go @@ -37,12 +37,14 @@ func TestUpdateState(t *testing.T) { if err != nil { t.Fatal(err) } - defer os.RemoveAll(tmpDir) + defer func() { _ = os.RemoveAll(tmpDir) }() // Override home dir for testing homeBackup := os.Getenv("HOME") - os.Setenv("HOME", tmpDir) - defer os.Setenv("HOME", homeBackup) + if err := os.Setenv("HOME", tmpDir); err != nil { + t.Fatal(err) + } + defer func() { _ = os.Setenv("HOME", homeBackup) }() // Ensure .iris directory exists _ = os.MkdirAll(filepath.Join(tmpDir, ".iris"), 0755)