From a68751a2996a710df5850d6bbe76f6afb00f5a6c Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Fri, 26 Jul 2024 15:07:12 +0200 Subject: [PATCH 1/5] fix: lint issues --- .golang-ci.yml | 2 ++ cmd/util.go | 9 --------- internal/tui/collector.go | 4 ++-- internal/tui/type.go | 2 -- pkg/skaffolder/create.go | 2 +- pkg/skaffolder/update.go | 1 - 6 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 cmd/util.go diff --git a/.golang-ci.yml b/.golang-ci.yml index 6d839fe..0b97e19 100644 --- a/.golang-ci.yml +++ b/.golang-ci.yml @@ -46,6 +46,8 @@ linters-settings: - singleCaseSwitch - hugeParam - appendCombine + - sloppyReassign + - whyNoLint funlen: lines: 100 statements: 52 diff --git a/cmd/util.go b/cmd/util.go deleted file mode 100644 index df31d06..0000000 --- a/cmd/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package cmd - -func mapStringToMapInterface(m map[string]string) map[string]interface{} { - res := make(map[string]interface{}) - for k, v := range m { - res[k] = v - } - return res -} diff --git a/internal/tui/collector.go b/internal/tui/collector.go index dcf6959..ccc944b 100644 --- a/internal/tui/collector.go +++ b/internal/tui/collector.go @@ -34,7 +34,7 @@ func (m *Model) Init() tea.Cmd { } func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - var cmds []tea.Cmd = make([]tea.Cmd, len(m.inputs)) + var cmds = make([]tea.Cmd, len(m.inputs)) for i := range m.inputs { m.inputs[i], cmds[i] = m.inputs[i].Update(msg) @@ -84,7 +84,7 @@ func (m *Model) View() string { builder.WriteRune('\n') builder.WriteString(helpStyle.Render(" ↑, ↓: navigate, enter: confirm, ctrl+c: quit, ctrl+s: save")) if m.err != nil { - builder.WriteString(errorStyle.Render(fmt.Sprintf("%s", m.err.Error()))) + builder.WriteString(errorStyle.Render(m.err.Error())) } return builder.String() } diff --git a/internal/tui/type.go b/internal/tui/type.go index 1ca745b..68e41aa 100644 --- a/internal/tui/type.go +++ b/internal/tui/type.go @@ -1,7 +1,6 @@ package tui import ( - "github.com/charmbracelet/bubbles/cursor" "github.com/charmbracelet/bubbles/textinput" ) @@ -9,7 +8,6 @@ type Model struct { header string focusIndex int inputs []textinput.Model - cursorMode cursor.Mode err error exitWithCtrlC bool } diff --git a/pkg/skaffolder/create.go b/pkg/skaffolder/create.go index 27de9c0..391d14f 100644 --- a/pkg/skaffolder/create.go +++ b/pkg/skaffolder/create.go @@ -16,7 +16,7 @@ type SkaCreate struct { Log *log.Entry } -func NewSkaCreate(templateURI string, destinationPath string, variables map[string]string) *SkaCreate { +func NewSkaCreate(templateURI, destinationPath string, variables map[string]string) *SkaCreate { logCtx := log.WithFields(log.Fields{ "pkg": "skaffolder", }) diff --git a/pkg/skaffolder/update.go b/pkg/skaffolder/update.go index 440cdc3..bff0959 100644 --- a/pkg/skaffolder/update.go +++ b/pkg/skaffolder/update.go @@ -69,7 +69,6 @@ func (s *SkaUpdate) Update() error { // check if interactive mode is required if interactiveService.ShouldRun() { - // overrides the variables from remote service with already saved variables interactiveService.SetDefaults(mapInterfaceToString(vars)) From 9619d921ad045e0278e53d72bb271fec3b30b0d4 Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Fri, 26 Jul 2024 15:13:32 +0200 Subject: [PATCH 2/5] chore: fix goland version --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a7b1a02..3758842 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: '1.19' + go-version: '1.22' - name: golangci-lint uses: golangci/golangci-lint-action@v6 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5256bf1..afd8ef0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: test: strategy: matrix: - go-version: [1.19.x] + go-version: [1.22.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/go.mod b/go.mod index 9478229..4ca1422 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gchiesa/ska -go 1.21 +go 1.22 toolchain go1.22.0 From fca29314f2a9f6fb28f42716d254c085fa7f99a3 Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Fri, 26 Jul 2024 15:18:33 +0200 Subject: [PATCH 3/5] chore: fix pipelines --- .github/workflows/commitlint.yml | 15 --------------- .github/workflows/go-ci-lint.yaml | 29 +++++++++++++++++++++++++++++ .github/workflows/go-ci-test.yaml | 20 ++++++++++++++++++++ .github/workflows/lint.yml | 27 --------------------------- .github/workflows/test.yml | 4 +++- commitlint.config.js | 5 ----- 6 files changed, 52 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/go-ci-lint.yaml create mode 100644 .github/workflows/go-ci-test.yaml delete mode 100644 .github/workflows/lint.yml delete mode 100644 commitlint.config.js diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml deleted file mode 100644 index 16f5bdc..0000000 --- a/.github/workflows/commitlint.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Lint Commit Messages -on: - push: - branches: - - master - pull_request: - -jobs: - commitlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: wagoid/commitlint-github-action@v5 \ No newline at end of file diff --git a/.github/workflows/go-ci-lint.yaml b/.github/workflows/go-ci-lint.yaml new file mode 100644 index 0000000..7cff4fe --- /dev/null +++ b/.github/workflows/go-ci-lint.yaml @@ -0,0 +1,29 @@ +--- +name: Go linter +on: + workflow_dispatch: + push: + pull_request: +permissions: + contents: read + pull-requests: read +jobs: + golangci: + name: Golangci-lint + runs-on: ubuntu-latest + env: + GO_VERSION: '~1.22' + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54 + args: --config .golangci.yaml + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-check diff --git a/.github/workflows/go-ci-test.yaml b/.github/workflows/go-ci-test.yaml new file mode 100644 index 0000000..eb986fc --- /dev/null +++ b/.github/workflows/go-ci-test.yaml @@ -0,0 +1,20 @@ +--- +name: Go unit tests +on: + workflow_dispatch: + push: + pull_request: +env: + GO_VERSION: '~1.22' +jobs: + golangci: + name: Go Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + - name: Test + run: make go-test \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 3758842..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: golangci-lint -on: - push: - paths: - - '**.go' - branches: - - master - pull_request: - -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.50.0 - args: -c .golang-ci.yml -v --timeout=5m - env: - GO111MODULES: off \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afd8ef0..dea1350 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,8 @@ name: Test and coverage -on: [push, pull_request] +on: + workflow_dispatch: + jobs: test: diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 5166dcc..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,5 +0,0 @@ -// commitlint.configuration.js -module.exports = { - extends: ['@commitlint/configuration-conventional'], - ignores: [(message) => /^Bumps \[.+]\(.+\) from .+ to .+\.$/m.test(message)], -} From 8dff6770235a69f6fcda5a0a9811cedaaf0473ac Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Fri, 26 Jul 2024 15:23:01 +0200 Subject: [PATCH 4/5] chore: fix workflows and config --- .github/workflows/go-ci-lint.yaml | 2 +- .github/workflows/go-ci-test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-ci-lint.yaml b/.github/workflows/go-ci-lint.yaml index 7cff4fe..3758b08 100644 --- a/.github/workflows/go-ci-lint.yaml +++ b/.github/workflows/go-ci-lint.yaml @@ -24,6 +24,6 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.54 - args: --config .golangci.yaml + args: --config .golang-ci.yml github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check diff --git a/.github/workflows/go-ci-test.yaml b/.github/workflows/go-ci-test.yaml index eb986fc..a0106f7 100644 --- a/.github/workflows/go-ci-test.yaml +++ b/.github/workflows/go-ci-test.yaml @@ -17,4 +17,4 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Test - run: make go-test \ No newline at end of file + run: make test \ No newline at end of file From 0d601394f418c2285cd5acabb7742fd04d730dab Mon Sep 17 00:00:00 2001 From: Giuseppe Chiesa Date: Fri, 26 Jul 2024 15:25:56 +0200 Subject: [PATCH 5/5] chore: fix golang-ci --- .github/workflows/go-ci-lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go-ci-lint.yaml b/.github/workflows/go-ci-lint.yaml index 3758b08..40dcc52 100644 --- a/.github/workflows/go-ci-lint.yaml +++ b/.github/workflows/go-ci-lint.yaml @@ -23,7 +23,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.54 + version: v1.56 args: --config .golang-ci.yml github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check