diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..3eccbb9f --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,28 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + pull_request: +permissions: + contents: read + +jobs: + golangci: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: read # for golangci/golangci-lint-action to fetch pull requests + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.19 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + skip-go-installation: true + args: --timeout=5m \ No newline at end of file diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a1febb6e..8757faba 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -12,12 +12,12 @@ jobs: steps: - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 # See: https://goreleaser.com/ci/actions/ - name: Set up Go 1.19 - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.19 id: go diff --git a/cmd/agent/agent.go b/cmd/agent/agent.go index 4cd5007a..a6038821 100644 --- a/cmd/agent/agent.go +++ b/cmd/agent/agent.go @@ -13,7 +13,9 @@ var agentCmd = &cobra.Command{ Aliases: []string{"agent", "a"}, Short: "Actions on agent commands", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) }, PersistentPreRun: func(cmd *cobra.Command, args []string) { diff --git a/cmd/cicd/cicd.go b/cmd/cicd/cicd.go index 0786a8f9..477b47ca 100644 --- a/cmd/cicd/cicd.go +++ b/cmd/cicd/cicd.go @@ -13,7 +13,9 @@ var cicdCmd = &cobra.Command{ Aliases: []string{"cicd", "ci", "cd"}, Short: "Actions on CICD testings", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) }, PersistentPreRun: func(cmd *cobra.Command, args []string) { diff --git a/cmd/profilenlu/profilenlu.go b/cmd/profilenlu/profilenlu.go index f89b2a4a..26230a43 100644 --- a/cmd/profilenlu/profilenlu.go +++ b/cmd/profilenlu/profilenlu.go @@ -13,7 +13,9 @@ var profilenluCmd = &cobra.Command{ Aliases: []string{"test", "t", "tests"}, Short: "Actions on testing", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) }, PersistentPreRun: func(cmd *cobra.Command, args []string) { diff --git a/cmd/root.go b/cmd/root.go index 88375e7d..e1daf68e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,7 +28,9 @@ You can find the documentation at https://github.com/xavidop/dialogflow-cx-cli. Please file all bug reports on Github at https://github.com/xavidop/dialogflow-cx-cli/issues.`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) } }, diff --git a/cmd/stt/stt.go b/cmd/stt/stt.go index 56ca1e56..50aad5ed 100644 --- a/cmd/stt/stt.go +++ b/cmd/stt/stt.go @@ -13,7 +13,9 @@ var sttCmd = &cobra.Command{ Aliases: []string{"stt", "speech-to-text"}, Short: "Actions on speech-to-text commands", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) }, PersistentPreRun: func(cmd *cobra.Command, args []string) { diff --git a/cmd/tts/tts.go b/cmd/tts/tts.go index 49a0e982..a5a3be88 100644 --- a/cmd/tts/tts.go +++ b/cmd/tts/tts.go @@ -13,7 +13,9 @@ var ttsCmd = &cobra.Command{ Aliases: []string{"tts", "text-to-speech"}, Short: "Actions on text-to-speech commands", Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + os.Exit(1) + } os.Exit(0) }, PersistentPreRun: func(cmd *cobra.Command, args []string) { diff --git a/pkg/cx/sessionsclient.go b/pkg/cx/sessionsclient.go index 352d1b01..ae40c64c 100644 --- a/pkg/cx/sessionsclient.go +++ b/pkg/cx/sessionsclient.go @@ -38,7 +38,7 @@ func DetectIntentFromText(sessionClient *cx.SessionsClient, agent *cxpb.Agent, l LanguageCode: localeId, } - response, err := DetectIntent(sessionClient, agent, queryInput) + response, err := DetectIntent(sessionClient, agent, &queryInput) if err != nil { return nil, err } @@ -70,7 +70,7 @@ func DetectIntentFromAudio(sessionClient *cx.SessionsClient, agent *cxpb.Agent, LanguageCode: localeId, } - response, err := DetectIntent(sessionClient, agent, queryInput) + response, err := DetectIntent(sessionClient, agent, &queryInput) if err != nil { return nil, err } @@ -78,12 +78,12 @@ func DetectIntentFromAudio(sessionClient *cx.SessionsClient, agent *cxpb.Agent, return response, nil } -func DetectIntent(sessionClient *cx.SessionsClient, agent *cxpb.Agent, queryinput cxpb.QueryInput) (*cxpb.DetectIntentResponse, error) { +func DetectIntent(sessionClient *cx.SessionsClient, agent *cxpb.Agent, queryinput *cxpb.QueryInput) (*cxpb.DetectIntentResponse, error) { ctx := context.Background() sessionPath := fmt.Sprintf("%s/sessions/%s", agent.GetName(), uuid.NewString()) - request := cxpb.DetectIntentRequest{Session: sessionPath, QueryInput: &queryinput} + request := cxpb.DetectIntentRequest{Session: sessionPath, QueryInput: queryinput} response, err := sessionClient.DetectIntent(ctx, &request) if err != nil {