From 191bc2fab35a277efd0a530121a21ca3648f3c85 Mon Sep 17 00:00:00 2001 From: Yash Khare Date: Wed, 10 Jul 2024 11:48:06 +0530 Subject: [PATCH] feat: in CI flag (#2050) * in ci flag Signed-off-by: Yash --------- Signed-off-by: Yash --- cli/provider/cmd.go | 3 ++- config/config.go | 1 + pkg/service/orchestrator/rerecord.go | 37 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cli/provider/cmd.go b/cli/provider/cmd.go index c1226e808..c1ddb6ade 100644 --- a/cli/provider/cmd.go +++ b/cli/provider/cmd.go @@ -172,7 +172,6 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error { var err error cmd.Flags().SetNormalizeFunc(aliasNormalizeFunc) switch cmd.Name() { - case "update": return nil case "normalize": @@ -216,6 +215,7 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error { cmd.Flags().Uint64P("app-id", "a", c.cfg.AppID, "A unique name for the user's application") cmd.Flags().String("app-name", c.cfg.AppName, "Name of the user's application") cmd.Flags().Bool("generate-github-actions", c.cfg.GenerateGithubActions, "Generate Github Actions workflow file") + cmd.Flags().Bool("in-ci", c.cfg.InCi, "is CI Running or not") err = cmd.Flags().MarkHidden("port") if err != nil { errMsg := "failed to mark port as hidden flag" @@ -322,6 +322,7 @@ func aliasNormalizeFunc(_ *pflag.FlagSet, name string) pflag.NormalizedName { "keployNetwork": "keploy-network", "recordTimer": "record-timer", "urlMethods": "url-methods", + "inCi": "in-ci", } if newName, ok := flagNameMapping[name]; ok { diff --git a/config/config.go b/config/config.go index 2a1727ce3..8c6b5cd73 100644 --- a/config/config.go +++ b/config/config.go @@ -35,6 +35,7 @@ type Config struct { KeployContainer string `json:"keployContainer" yaml:"keployContainer" mapstructure:"keployContainer"` KeployNetwork string `json:"keployNetwork" yaml:"keployNetwork" mapstructure:"keployNetwork"` CommandType string `json:"cmdType" yaml:"cmdType" mapstructure:"cmdType"` + InCi bool `json:"inCi" yaml:"inCi" mapstructure:"inCi"` } type UtGen struct { diff --git a/pkg/service/orchestrator/rerecord.go b/pkg/service/orchestrator/rerecord.go index 131d8a243..c411b39ff 100644 --- a/pkg/service/orchestrator/rerecord.go +++ b/pkg/service/orchestrator/rerecord.go @@ -149,26 +149,27 @@ func (o *Orchestrator) ReRecord(ctx context.Context) error { } stopReason = "Re-recorded all the selected testsets successfully" - o.logger.Info("Re-record was successfull. Do you want to remove the older testsets? (y/n)", zap.Any("testsets", SelectedTests)) - reader := bufio.NewReader(os.Stdin) - input, err := reader.ReadString('\n') - if err != nil { - o.logger.Warn("Failed to read input. The older testsets will be kept.") - return nil - } - - if input == "y\n" || input == "Y\n" { - for _, testSet := range SelectedTests { - err := o.replay.DeleteTestSet(ctx, testSet) - if err != nil { - o.logger.Warn("Failed to delete the testset", zap.String("testset", testSet)) + if !o.config.InCi { + o.logger.Info("Re-record was successfull. Do you want to remove the older testsets? (y/n)", zap.Any("testsets", SelectedTests)) + reader := bufio.NewReader(os.Stdin) + input, err := reader.ReadString('\n') + if err != nil { + o.logger.Warn("Failed to read input. The older testsets will be kept.") + return nil + } + if input == "y\n" || input == "Y\n" { + for _, testSet := range SelectedTests { + err := o.replay.DeleteTestSet(ctx, testSet) + if err != nil { + o.logger.Warn("Failed to delete the testset", zap.String("testset", testSet)) + } } + o.logger.Info("Deleted the older testsets successfully") + } else if input == "n\n" || input == "N\n" { + o.logger.Info("skipping the deletion of older testsets") + } else { + o.logger.Warn("Invalid input. The older testsets will be kept.") } - o.logger.Info("Deleted the older testsets successfully") - } else if input == "n\n" || input == "N\n" { - o.logger.Info("skipping the deletion of older testsets") - } else { - o.logger.Warn("Invalid input. The older testsets will be kept.") } return nil }