Skip to content

Commit

Permalink
Upgrade go1.19, helm update and add golangci-lint job (#460)
Browse files Browse the repository at this point in the history
* upgrade to go1.19

Signed-off-by: cpanato <[email protected]>

* add golangci-lint

Signed-off-by: cpanato <[email protected]>

* fix lints and Replace github.com/pkg/errors dependency with native error wrapping

Signed-off-by: cpanato <[email protected]>

* update install kind cluster

Signed-off-by: cpanato <[email protected]>

* update tests

Signed-off-by: cpanato <[email protected]>

* use errors.new

Signed-off-by: cpanato <[email protected]>

Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato authored Sep 16, 2022
1 parent e7dd0ad commit 68f3fff
Show file tree
Hide file tree
Showing 24 changed files with 211 additions and 170 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:

- name: checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.1
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
with:
fetch-depth: 0

Expand All @@ -22,7 +22,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.3.0
with:
go-version: '1.18'
go-version-file: './go.mod'
check-latest: true

- uses: azure/setup-helm@b5b231a831f96336bbfeccc1329990f0005c5bb1 # v3.3
Expand All @@ -40,16 +40,17 @@ jobs:
- name: Install syft
uses: anchore/sbom-action/download-syft@b5042e9d19d8b32849779bfe17673ff84aec702d # v0.12.0

- name: Install k8s Kind
uses: helm/kind-action@d08cf6ff1575077dee99962540d77ce91c62387d # v1.3.0
with:
install_only: true

- name: Install tools
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
curl -fsSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.14.0/kind-linux-amd64"
chmod +x kind
sudo mv kind /usr/local/bin/kind
./setup.sh
- name: Test
Expand All @@ -64,10 +65,10 @@ jobs:
git diff --exit-code
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v1.2.0
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v1.6.0
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0

- name: Build
run: |
Expand All @@ -76,3 +77,17 @@ jobs:
echo "Building snapshot..."
./build.sh
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3
with:
go-version-file: './go.mod'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3
with:
version: v1.48.0
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.3.0
with:
go-version: '1.18'
go-version-file: './go.mod'
check-latest: true

- name: Install GoReleaser
Expand All @@ -53,13 +53,13 @@ jobs:
git diff --exit-code
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v1.2.0
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v1.6.0
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0

- name: Login to registry
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v1.14.1
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0
with:
registry: quay.io
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
linters:
enable:
- asciicheck
- deadcode
- depguard
- errcheck
- errorlint
- gofmt
- goimports
- gosec
- gocritic
- importas
- prealloc
- revive
- misspell
- stylecheck
- unconvert
- whitespace
output:
uniq-by-line: false
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
max-issues-per-linter: 0
max-same-issues: 0
run:
issues-exit-code: 1
timeout: 10m
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$kubectl
mv kubectl /usr/local/bin/

# Install Helm
ARG helm_version=v3.9.2
ARG helm_version=v3.9.3
LABEL helm_version=$helm_version
RUN targetArch=$(echo $TARGETPLATFORM | cut -f2 -d '/') \
&& if [ ${targetArch} = "amd64" ]; then \
Expand Down
4 changes: 2 additions & 2 deletions ct/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func install(cmd *cobra.Command, args []string) error {
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
return fmt.Errorf("failed loading configuration: %w", err)
}

extraSetArgs, err := cmd.Flags().GetString("helm-extra-set-args")
Expand All @@ -106,7 +106,7 @@ func install(cmd *cobra.Command, args []string) error {
testing.PrintResults(results)

if err != nil {
return fmt.Errorf("Error installing charts: %s", err)
return fmt.Errorf("failed installing charts: %w", err)
}

fmt.Println("All charts installed successfully")
Expand Down
4 changes: 2 additions & 2 deletions ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func lint(cmd *cobra.Command, args []string) error {
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
return fmt.Errorf("failed loading configuration: %w", err)
}

emptyExtraSetArgs := ""
Expand All @@ -97,7 +97,7 @@ func lint(cmd *cobra.Command, args []string) error {
testing.PrintResults(results)

if err != nil {
return fmt.Errorf("Error linting charts: %s", err)
return fmt.Errorf("failed linting charts: %w", err)
}

fmt.Println("All charts linted successfully")
Expand Down
4 changes: 2 additions & 2 deletions ct/cmd/lintAndInstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func lintAndInstall(cmd *cobra.Command, args []string) error {
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
return fmt.Errorf("failed loading configuration: %w", err)
}

extraSetArgs, err := cmd.Flags().GetString("helm-extra-set-args")
Expand All @@ -63,7 +63,7 @@ func lintAndInstall(cmd *cobra.Command, args []string) error {
testing.PrintResults(results)

if err != nil {
return fmt.Errorf("Error linting and installing charts: %s", err)
return fmt.Errorf("failed linting and installing charts: %w", err)
}

fmt.Println("All charts linted and installed successfully")
Expand Down
3 changes: 2 additions & 1 deletion ct/cmd/listChanged.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func listChanged(cmd *cobra.Command, args []string) error {
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
return fmt.Errorf("failed loading configuration: %w", err)
}

emptyExtraSetArgs := ""
Expand All @@ -63,5 +63,6 @@ func listChanged(cmd *cobra.Command, args []string) error {
for _, dir := range chartDirs {
fmt.Println(dir)
}

return nil
}
2 changes: 1 addition & 1 deletion e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -o pipefail
CLUSTER_NAME=chart-testing
readonly CLUSTER_NAME

K8S_VERSION=v1.21.2
K8S_VERSION=v1.22.9
readonly K8S_VERSION

create_kind_cluster() {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/helm/chart-testing/v3

go 1.18
go 1.19

require (
github.com/MakeNowJust/heredoc v1.0.0
Expand All @@ -9,7 +9,6 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/mattn/go-shellwords v1.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.13.0
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
Loading

0 comments on commit 68f3fff

Please sign in to comment.