Skip to content

Commit

Permalink
Updates (#307)
Browse files Browse the repository at this point in the history
* bump golangci-lint to v1.53.x

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

* bump alpine base image to 3.18

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

* update deprecated goreleaser flags

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

* remove action for cache, the setup-go already do that

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

* fix lints

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

---------

Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato authored Jun 27, 2023
1 parent f906f6f commit 9320c4f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 41 deletions.
27 changes: 1 addition & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ jobs:
go-version-file: './go.mod'
check-latest: true

- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0

Expand All @@ -45,14 +36,6 @@ jobs:
- name: Install syft
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3

- name: Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: chainguard-dev/actions/goimports@main

- name: Run Mage
Expand Down Expand Up @@ -90,15 +73,7 @@ jobs:
with:
go-version-file: './go.mod'
check-latest: true
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: v1.51.0
version: v1.53
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
linters:
enable:
- asciicheck
- depguard
- errcheck
- errorlint
- gofmt
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.17
FROM alpine:3.18

RUN apk --no-cache add ca-certificates git

Expand Down
2 changes: 1 addition & 1 deletion cr/cmd/docGen.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var generateDocsCmd = &cobra.Command{
RunE: generateDocs,
}

func generateDocs(cmd *cobra.Command, args []string) error {
func generateDocs(_ *cobra.Command, _ []string) error {
fmt.Println("Generating docs...")

err := doc.GenMarkdownTree(rootCmd.Root(), "doc")
Expand Down
4 changes: 2 additions & 2 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func Test() error {
}

func Build() error {
return sh.RunV("goreleaser", "release", "--rm-dist", "--snapshot", "--skip-sign")
return sh.RunV("goreleaser", "release", "--clean", "--snapshot", "--skip-sign")
}

func CI() error {
Expand All @@ -137,5 +137,5 @@ func Release() error {
return err
}

return sh.RunV("goreleaser", "release", "--rm-dist")
return sh.RunV("goreleaser", "release", "--clean")
}
8 changes: 4 additions & 4 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewClient(owner, repo, token, baseURL, uploadURL string) *Client {
}

// GetRelease queries the GitHub API for a specified release object
func (c *Client) GetRelease(ctx context.Context, tag string) (*Release, error) {
func (c *Client) GetRelease(_ context.Context, tag string) (*Release, error) {
// Check Release whether already exists or not
release, _, err := c.Repositories.GetReleaseByTag(context.TODO(), c.owner, c.repo, tag)
if err != nil {
Expand All @@ -103,7 +103,7 @@ func (c *Client) GetRelease(ctx context.Context, tag string) (*Release, error) {
}

// CreateRelease creates a new release object in the GitHub API
func (c *Client) CreateRelease(ctx context.Context, input *Release) error {
func (c *Client) CreateRelease(_ context.Context, input *Release) error {
req := &github.RepositoryRelease{
Name: &input.Name,
Body: &input.Description,
Expand Down Expand Up @@ -150,7 +150,7 @@ func (c *Client) CreatePullRequest(owner string, repo string, message string, he
}

// UploadAsset uploads specified assets to a given release object
func (c *Client) uploadReleaseAsset(ctx context.Context, releaseID int64, filename string) error {
func (c *Client) uploadReleaseAsset(_ context.Context, releaseID int64, filename string) error {
filename, err := filepath.Abs(filename)
if err != nil {
return errors.Wrap(err, "failed to get abs path")
Expand All @@ -161,7 +161,7 @@ func (c *Client) uploadReleaseAsset(ctx context.Context, releaseID int64, filena
Name: filepath.Base(filename),
}

if err := retry.Retry(3, 3*time.Second, func() error {
if err := retry.Retry(3, 3*time.Second, func() error { //nolint: revive
f, err := os.Open(filename)
if err != nil {
return errors.Wrap(err, "failed to open file")
Expand Down
5 changes: 1 addition & 4 deletions pkg/releaser/releaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ func (r *Releaser) addToIndexFile(indexFile *repo.IndexFile, url string) error {
}

// Add to index
if err := indexFile.MustAdd(c.Metadata, filepath.Base(arch), strings.Join(s, "/"), hash); err != nil {
return err
}
return nil
return indexFile.MustAdd(c.Metadata, filepath.Base(arch), strings.Join(s, "/"), hash)
}

// CreateReleases finds and uploads Helm chart packages to GitHub
Expand Down
4 changes: 2 additions & 2 deletions pkg/releaser/releaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type FakeGit struct {
mock.Mock
}

func (f *FakeGit) AddWorktree(workingDir string, committish string) (string, error) {
func (f *FakeGit) AddWorktree(workingDir string, committish string) (string, error) { //nolint: revive
dir, err := os.MkdirTemp("", "chart-releaser-")
if err != nil {
return "", err
Expand Down Expand Up @@ -92,7 +92,7 @@ func (f *FakeGitHub) CreateRelease(ctx context.Context, input *github.Release) e
return nil
}

func (f *FakeGitHub) GetRelease(ctx context.Context, tag string) (*github.Release, error) {
func (f *FakeGitHub) GetRelease(ctx context.Context, tag string) (*github.Release, error) { //nolint: revive
release := &github.Release{
Name: "testdata/release-packages/test-chart-0.1.0",
Description: "A Helm chart for Kubernetes",
Expand Down

0 comments on commit 9320c4f

Please sign in to comment.