Skip to content

Commit

Permalink
Update to Go 1.21 for builds
Browse files Browse the repository at this point in the history
Noteis:
1. This moves golangci scanning to a GitHub action. This will
   enable inline pointers to issues in the PR where linting fails.
2. Go 1.21 is specified in the go.mod because Kubernetes libs
   require it.
3. The lint issues were removed. Some were fixed while others
   were handled by skipping linting or using _ as an argument.
   Many of these can be refactored later for better cleanup.

Signed-off-by: Matt Farina <matt.farina@suse.com>
  • Loading branch information
mattfarina committed Jan 8, 2024
1 parent 6d96283 commit 847369c
Show file tree
Hide file tree
Showing 31 changed files with 101 additions and 49 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/build-test.yml
Expand Up @@ -17,19 +17,9 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # pin@4.1.0
with:
go-version: '1.20'
- name: Install golangci-lint
run: |
curl -sSLO https://github.com/golangci/golangci-lint/releases/download/v$GOLANGCI_LINT_VERSION/golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz
shasum -a 256 golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz | grep "^$GOLANGCI_LINT_SHA256 " > /dev/null
tar -xf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz
sudo mv golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64/golangci-lint /usr/local/bin/golangci-lint
rm -rf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64*
env:
GOLANGCI_LINT_VERSION: '1.51.2'
GOLANGCI_LINT_SHA256: '4de479eb9d9bc29da51aec1834e7c255b333723d38dbd56781c68e5dddc6a90b'
- name: Test style
run: make test-style
go-version: '1.21'
- name: Test source headers are present
run: make test-source-headers
- name: Run unit tests
run: make test-coverage
- name: Test build
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/golangci-lint.yml
@@ -0,0 +1,22 @@
name: golangci-lint

on:
push:
pull_request:

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v4.1.1

- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # pin@4.1.0
with:
go-version: "1.21"
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc #pin@3.7.0
with:
version: v1.55
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # pin@4.1.0
with:
go-version: '1.20'
go-version: '1.21'

- name: Run unit tests
run: make test-coverage
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # pin@4.1.0
with:
go-version: '1.20'
go-version: '1.21'

- name: Run unit tests
run: make test-coverage
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -114,7 +114,11 @@ test-coverage:

.PHONY: test-style
test-style:
GO111MODULE=on golangci-lint run
golangci-lint run ./...
@scripts/validate-license.sh

.PHONY: test-source-headers
test-source-headers:
@scripts/validate-license.sh

.PHONY: test-acceptance
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/completion.go
Expand Up @@ -210,6 +210,6 @@ func runCompletionPowershell(out io.Writer, cmd *cobra.Command) error {
}

// Function to disable file completion
func noCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
func noCompletions(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveNoFileComp
}
2 changes: 1 addition & 1 deletion cmd/helm/docs.go
Expand Up @@ -77,7 +77,7 @@ func newDocsCmd(out io.Writer) *cobra.Command {
return cmd
}

func (o *docsOptions) run(out io.Writer) error {
func (o *docsOptions) run(_ io.Writer) error {
switch o.docTypeString {
case "markdown", "mdown", "md":
if o.generateHeaders {
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/flags.go
Expand Up @@ -195,7 +195,7 @@ func (p *postRendererArgsSlice) GetSlice() []string {
return p.options.args
}

func compVersionFlag(chartRef string, toComplete string) ([]string, cobra.ShellCompDirective) {
func compVersionFlag(chartRef string, _ string) ([]string, cobra.ShellCompDirective) {
chartInfo := strings.Split(chartRef, "/")
if len(chartInfo) != 2 {
return nil, cobra.ShellCompDirectiveNoFileComp
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/history.go
Expand Up @@ -184,7 +184,7 @@ func min(x, y int) int {
return y
}

func compListRevisions(toComplete string, cfg *action.Configuration, releaseName string) ([]string, cobra.ShellCompDirective) {
func compListRevisions(_ string, cfg *action.Configuration, releaseName string) ([]string, cobra.ShellCompDirective) {
client := action.NewHistory(cfg)

var revisions []string
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/plugin_list.go
Expand Up @@ -75,7 +75,7 @@ func filterPlugins(plugins []*plugin.Plugin, ignoredPluginNames []string) []*plu
}

// Provide dynamic auto-completion for plugin names
func compListPlugins(toComplete string, ignoredPluginNames []string) []string {
func compListPlugins(_ string, ignoredPluginNames []string) []string {
var pNames []string
plugins, err := plugin.FindPlugins(settings.PluginsDirectory)
if err == nil && len(plugins) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/repo_index.go
Expand Up @@ -76,7 +76,7 @@ func newRepoIndexCmd(out io.Writer) *cobra.Command {
return cmd
}

func (i *repoIndexOptions) run(out io.Writer) error {
func (i *repoIndexOptions) run(_ io.Writer) error {
path, err := filepath.Abs(i.dir)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/repo_list.go
Expand Up @@ -123,7 +123,7 @@ func filterRepos(repos []*repo.Entry, ignoredRepoNames []string) []*repo.Entry {
}

// Provide dynamic auto-completion for repo names
func compListRepos(prefix string, ignoredRepoNames []string) []string {
func compListRepos(_ string, ignoredRepoNames []string) []string {
var rNames []string

f, err := repo.LoadFile(settings.RepositoryConfig)
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/search/search_test.go
Expand Up @@ -101,7 +101,7 @@ var indexfileEntries = map[string]repo.ChartVersions{
},
}

func loadTestIndex(t *testing.T, all bool) *Index {
func loadTestIndex(_ *testing.T, all bool) *Index {
i := NewIndex()
i.AddRepo("testing", &repo.IndexFile{Entries: indexfileEntries}, all)
i.AddRepo("ztesting", &repo.IndexFile{Entries: map[string]repo.ChartVersions{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,6 +1,6 @@
module helm.sh/helm/v3

go 1.20
go 1.21

require (
github.com/BurntSushi/toml v1.3.2
Expand Down

0 comments on commit 847369c

Please sign in to comment.