Skip to content

Commit

Permalink
Add lint task and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JAORMX committed Nov 21, 2023
1 parent 5b53f94 commit bb3ce53
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ tasks:

build:
cmds:
- go build -o ./bin/ ./...
- go build -o ./bin/ ./...

lint:
cmds:
- golangci-lint run --timeout 5m0s --config .golangci.yml
6 changes: 3 additions & 3 deletions cmd/ghactions/ghactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
)

// GHActionsCmd represents the ghactions command
func GHActionsCmd() *cobra.Command {
// CmdGHActions represents the ghactions command
func CmdGHActions() *cobra.Command {
cmd := &cobra.Command{
Use: "ghactions",
Short: "Replace tags in GitHub Actions workflows",
Expand All @@ -41,7 +41,7 @@ func GHActionsCmd() *cobra.Command {
return cmd
}

func replace(cmd *cobra.Command, args []string) error {
func replace(cmd *cobra.Command, _ []string) error {
dir := cmd.Flag("dir").Value.String()
dryRun, err := cmd.Flags().GetBool("dry-run")
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/ghactions/replacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ func (r *replacer) do(ctx context.Context, cmd *cobra.Command) error {
return err
}

r.processOutput(cmd, bfs, outfiles)
if err := r.processOutput(cmd, bfs, outfiles); err != nil {
return err
}

if r.errOnModified && modified {
return fmt.Errorf("modified files")
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var rootCmd = &cobra.Command{

// Execute runs the root command.
func Execute() {
rootCmd.AddCommand(ghactions.GHActionsCmd())
rootCmd.AddCommand(ghactions.CmdGHActions())
err := rootCmd.ExecuteContext(context.Background())
if err != nil {
os.Exit(1)
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package main

Expand Down
8 changes: 8 additions & 0 deletions pkg/ghactions/ghactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
)

func TestParseActionReference(t *testing.T) {
t.Parallel()

type args struct {
input string
}
Expand Down Expand Up @@ -88,6 +90,8 @@ func TestParseActionReference(t *testing.T) {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

gotact, gotref, err := ghactions.ParseActionReference(tt.args.input)
if tt.wantErr {
require.Error(t, err, "Wanted error, got none")
Expand All @@ -101,6 +105,8 @@ func TestParseActionReference(t *testing.T) {
}

func TestGetChecksum(t *testing.T) {
t.Parallel()

type args struct {
action string
ref string
Expand Down Expand Up @@ -213,6 +219,8 @@ func TestGetChecksum(t *testing.T) {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

ghcli := github.NewClient(nil)
got, err := ghactions.GetChecksum(context.Background(), ghcli, tt.args.action, tt.args.ref)
if tt.wantErr {
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package utils provides utilities for boomerang
package utils

import (
Expand Down

0 comments on commit bb3ce53

Please sign in to comment.