diff --git a/.github/workflows/ai-lint-fix.yml b/.github/workflows/ai-lint-fix.yml index 76d6762..a370cfa 100644 --- a/.github/workflows/ai-lint-fix.yml +++ b/.github/workflows/ai-lint-fix.yml @@ -52,14 +52,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Get app version in env run: | diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 19aea66..ba36af2 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -93,14 +93,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Start docker containers using compose run: | diff --git a/.github/workflows/ci-binary.yml b/.github/workflows/ci-binary.yml index 718b768..2a856df 100644 --- a/.github/workflows/ci-binary.yml +++ b/.github/workflows/ci-binary.yml @@ -63,14 +63,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Get build information shell: bash @@ -384,14 +380,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Get app version for build run: | diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 9061b7d..fd05343 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -112,15 +112,11 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build if: ${{ github.event.inputs.Push == 'true' && github.event.inputs.Tag == '' }} run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Get tag from app version for build if: ${{ github.event.inputs.Push == 'true' }} diff --git a/.github/workflows/go-coverage-merge.yml b/.github/workflows/go-coverage-merge.yml index ff0ca14..7766074 100644 --- a/.github/workflows/go-coverage-merge.yml +++ b/.github/workflows/go-coverage-merge.yml @@ -40,14 +40,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Start docker containers using compose run: | @@ -141,14 +137,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Start docker containers using compose run: | @@ -186,14 +178,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Run unit test in macOS run: sudo go test -v --run "TestUnixFiles|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface" -cover -coverprofile macos-coverage.out @@ -231,14 +219,10 @@ jobs: with: go-version: 1.25 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Create log file for Windows run: | @@ -296,14 +280,10 @@ jobs: with: go-version: 1.26 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Download coverage report for Linux (with root) uses: actions/download-artifact@v8 diff --git a/.github/workflows/go-lint-check.yml b/.github/workflows/go-lint-check.yml index e6c9414..661dc4f 100644 --- a/.github/workflows/go-lint-check.yml +++ b/.github/workflows/go-lint-check.yml @@ -7,30 +7,10 @@ on: description: 'Branch for checkout' required: true default: 'main' - Update: - description: 'Update go version' - default: false - type: boolean - Version: - description: 'Version for Go' - required: false - default: '1.25' - Modules: - description: 'Update dependencies in modules' - default: false - type: boolean Golangci: description: 'Golangci linters check' default: false type: boolean - Fix: - description: 'Golangci linters auto-fix' - default: false - type: boolean - PR: - description: 'Create Pull Request' - default: false - type: boolean Gocrit: description: 'Go critical linters check' default: false @@ -39,6 +19,14 @@ on: description: 'Go security linters check' default: false type: boolean + Fix: + description: 'Golangci linters auto-fix' + default: false + type: boolean + PR: + description: 'Create Pull Request' + default: false + type: boolean jobs: lint: @@ -47,7 +35,6 @@ jobs: permissions: contents: write pull-requests: write - models: read runs-on: ubuntu-latest @@ -66,64 +53,27 @@ jobs: with: go-version: 1.26 - - name: Install dependencies + - name: Code verify and check build run: | - go fmt ./... go vet ./... - go get ./... - go mod tidy - go mod verify - go build -v ./... + go build -v -o /dev/null ./... - name: Get build parameters to summary shell: bash run: | - echo "### Parameters" >> $GITHUB_STEP_SUMMARY + echo "## Parameters" >> $GITHUB_STEP_SUMMARY echo "- **Branch for checkout**: ${{ github.event.inputs.Branch }}" >> $GITHUB_STEP_SUMMARY - echo "- **Update go version**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY - echo "- **Update dependencies in** `go.mod`: ${{ github.event.inputs.Modules == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY echo "- **Golangci linters check**: ${{ github.event.inputs.Golangci == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY - echo "- **Golangci linters auto-fix in** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY - echo "- **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY echo "- **Go critical linters check**: ${{ github.event.inputs.Gocrit == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY echo "- **Go security linters check**: ${{ github.event.inputs.Gosec == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY + echo "- **Golangci linters auto-fix**: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY + echo "- **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY - name: Get app version in env run: | APP_VERSION=$(go run main.go -v) echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV - - name: Update Go version - if: ${{ github.event.inputs.Update == 'true' && github.event.inputs.Version != '' }} - run: | - go mod edit -go=${{ github.event.inputs.Version }} - # go mod edit -toolchain=go${{ github.event.inputs.Version }} - go mod tidy - - - name: Reinstall Go on new version - if: ${{ github.event.inputs.Update == 'true' && github.event.inputs.Version != '' }} - uses: actions/setup-go@v7 - with: - go-version: ${{ github.event.inputs.Version }} - cache: true - - - name: Update dependencies in modules - if: ${{ github.event.inputs.Modules == 'true' }} - run: go get -u ./... - - - name: Create Pull Request for update go version amd dependencies - if: ${{ github.event.inputs.Modules == 'true' && github.event.inputs.PR == 'true' }} - uses: peter-evans/create-pull-request@v8 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "update go version and package dependencies" - branch: "fix/${{ env.APP_VERSION }}-update" - title: "Updated dependencies" - body: "Updated go version and modules in `go.mod` and `go.sum` files." - add-paths: | - go.mod - go.sum - - name: Install golangci if: ${{ github.event.inputs.golangci == 'true' || github.event.inputs.Fix == 'true' }} run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 @@ -239,13 +189,12 @@ jobs: 👤 **User**: ${{ github.actor }} Parameters: - **Update go version**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }} - **Update dependencies in** `go.mod`: ${{ github.event.inputs.Modules == 'true' && '✅' || '❌' }} + **Branch for checkout**: ${{ github.event.inputs.Branch }} **Golangci linters check**: ${{ github.event.inputs.Golangci == 'true' && '✅' || '❌' }} - **Golangci linters fix in** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }} - **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }} **Go critical linters check**: ${{ github.event.inputs.Gocrit == 'true' && '✅' || '❌' }} **Go security linters check**: ${{ github.event.inputs.Gosec == 'true' && '✅' || '❌' }} + **Golangci linters auto-fix** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }} + **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }} Results: ${{ steps.golangci.outcome == 'failure' && '❌' || '✅' }} **Golangci linters check**: ${{ steps.golangci.outcome }} diff --git a/.github/workflows/go-ver-update.yml b/.github/workflows/go-ver-update.yml new file mode 100644 index 0000000..ce0dd53 --- /dev/null +++ b/.github/workflows/go-ver-update.yml @@ -0,0 +1,85 @@ +name: "[GO] Go version and modules update" + +on: + workflow_dispatch: + inputs: + Version: + description: 'Version for Go' + required: true + default: '1.26' + Modules: + description: 'Update dependencies in modules' + default: false + type: boolean + PR: + description: 'Create Pull Request' + default: false + type: boolean + +jobs: + lint: + name: Linters check + + permissions: + contents: write + pull-requests: write + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository (main branch and last commits) + uses: actions/checkout@v7 + with: + ref: main + fetch-depth: 1 + + - name: Install Go + uses: actions/setup-go@v7 + with: + go-version: 1.25 + + - name: Code verify and check build before updates + run: | + go vet ./... + go build -v -o /dev/null ./... + + - name: Get app version in env + run: | + APP_VERSION=$(go run main.go -v) + echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV + + - name: Update Go version + if: ${{ github.event.inputs.Version != '' }} + run: | + go mod edit -go=${{ github.event.inputs.Version }} + # go mod edit -toolchain=go${{ github.event.inputs.Version }} + go mod tidy + + - name: Reinstall Go on new version + if: ${{ github.event.inputs.Version != '' }} + uses: actions/setup-go@v7 + with: + go-version: ${{ github.event.inputs.Version }} + cache: true + + - name: Update dependencies in modules + if: ${{ github.event.inputs.Modules == 'true' }} + run: go get -u ./... + + - name: Code verify and check build after updates + run: | + go vet ./... + go build -v -o /dev/null ./... + + - name: Create Pull Request for update go version and modules + if: ${{ github.event.inputs.Modules == 'true' && github.event.inputs.PR == 'true' }} + uses: peter-evans/create-pull-request@v8 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "update go version and modules" + branch: "ops/go-${{ github.event.inputs.Version }}" + title: "Updated Go version and modules" + body: "Updated Go version to **${{ github.event.inputs.Version }}** as well as the module dependencies in `go.mod` and `go.sum`." + add-paths: | + go.mod + go.sum \ No newline at end of file diff --git a/Makefile b/Makefile index d77c300..975775a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,6 @@ prep: - @go fmt ./... @go vet ./... - @go get ./... - @go mod tidy - @go mod verify - @go build -o /dev/null -v ./... + @go build -v -o /dev/null ./... clear-cache: go clean -cache -modcache -testcache