From 53b61c8546c7bbadc23380de34e818a59a74dba3 Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:11:19 -0800 Subject: [PATCH 1/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/model/command.go b/internal/model/command.go index b661afcc8..f829b0fd1 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -305,6 +305,14 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { _ = log.SendToLogProxy(ctx, log.LogProxyLevelError, msg, nil) logger.PrintfStyled(styles.DimmedItalic, msg) if env.IsGithubAction() { + gitCmd := exec.Command("git", "checkout", "--", ".speakeasy/gen.lock") + gitCmd.Stdin = os.Stdin + gitCmd.Stdout = os.Stdout + gitCmd.Stderr = os.Stderr + + if err = gitCmd.Run(); err != nil { + logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") + } githubactions.AddStepSummary("# Speakeasy Version upgrade failure\n" + msg) } From 10d32860ed72ae5bcf5b619bb8f593eab9558372 Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:11:59 -0800 Subject: [PATCH 2/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/model/command.go b/internal/model/command.go index f829b0fd1..e47429383 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -305,19 +305,21 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { _ = log.SendToLogProxy(ctx, log.LogProxyLevelError, msg, nil) logger.PrintfStyled(styles.DimmedItalic, msg) if env.IsGithubAction() { - gitCmd := exec.Command("git", "checkout", "--", ".speakeasy/gen.lock") - gitCmd.Stdin = os.Stdin - gitCmd.Stdout = os.Stdout - gitCmd.Stderr = os.Stderr - - if err = gitCmd.Run(); err != nil { - logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") - } githubactions.AddStepSummary("# Speakeasy Version upgrade failure\n" + msg) } if lockfileVersion != "" && lockfileVersion != desiredVersion { logger.PrintfStyled(styles.DimmedItalic, "Rerunning with previous successful version: %s\n", lockfileVersion) + if env.IsGithubAction() { + gitCmd := exec.Command("git", "checkout", "--", ".speakeasy/gen.lock") + gitCmd.Stdin = os.Stdin + gitCmd.Stdout = os.Stdout + gitCmd.Stderr = os.Stderr + + if err = gitCmd.Run(); err != nil { + logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") + } + } return runWithVersion(cmd, artifactArch, lockfileVersion) } } From ea5024951a364329257552bf9299e2476803d207 Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:17:59 -0800 Subject: [PATCH 3/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/model/command.go b/internal/model/command.go index e47429383..34ebd7970 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "slices" "strings" @@ -311,13 +312,18 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { if lockfileVersion != "" && lockfileVersion != desiredVersion { logger.PrintfStyled(styles.DimmedItalic, "Rerunning with previous successful version: %s\n", lockfileVersion) if env.IsGithubAction() { - gitCmd := exec.Command("git", "checkout", "--", ".speakeasy/gen.lock") - gitCmd.Stdin = os.Stdin - gitCmd.Stdout = os.Stdout - gitCmd.Stderr = os.Stderr - - if err = gitCmd.Run(); err != nil { - logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") + files, _ := filepath.Glob("*/gen.lock") + + if len(files) == 0 { + args := append([]string{"checkout", "--"}, files...) + gitCmd := exec.Command("git", args...) + gitCmd.Stdin = os.Stdin + gitCmd.Stdout = os.Stdout + gitCmd.Stderr = os.Stderr + + if err = gitCmd.Run(); err != nil { + logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") + } } } return runWithVersion(cmd, artifactArch, lockfileVersion) From a154eca1681ecfd9dd05c45a8b1b8ff2204fb5ef Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:18:15 -0800 Subject: [PATCH 4/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/model/command.go b/internal/model/command.go index 34ebd7970..b0ebfecb1 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -322,7 +322,7 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { gitCmd.Stderr = os.Stderr if err = gitCmd.Run(); err != nil { - logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock to previous state") + logger.PrintfStyled(styles.DimmedItalic, "failed resetting gen.lock files to previous state") } } } From c388440e9a1d8ebb868d818cf4ac1cf6ce8060bf Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:18:45 -0800 Subject: [PATCH 5/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/model/command.go b/internal/model/command.go index b0ebfecb1..b1f8106a8 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -314,7 +314,7 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { if env.IsGithubAction() { files, _ := filepath.Glob("*/gen.lock") - if len(files) == 0 { + if len(files) > 0 { args := append([]string{"checkout", "--"}, files...) gitCmd := exec.Command("git", args...) gitCmd.Stdin = os.Stdin From c2dd5bfd1935a3ade4a764be3ad11b0487b55883 Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 3 Dec 2024 10:19:40 -0800 Subject: [PATCH 6/6] feat: reset gen.lock in github action generation retries --- internal/model/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/model/command.go b/internal/model/command.go index b1f8106a8..48e88e6c2 100644 --- a/internal/model/command.go +++ b/internal/model/command.go @@ -312,7 +312,7 @@ func runWithVersionFromWorkflowFile(cmd *cobra.Command) error { if lockfileVersion != "" && lockfileVersion != desiredVersion { logger.PrintfStyled(styles.DimmedItalic, "Rerunning with previous successful version: %s\n", lockfileVersion) if env.IsGithubAction() { - files, _ := filepath.Glob("*/gen.lock") + files, _ := filepath.Glob("**/gen.lock") if len(files) > 0 { args := append([]string{"checkout", "--"}, files...)