From c70d1b6d92c870002d2135cd732ec0cc79eaf50a Mon Sep 17 00:00:00 2001 From: sillyguodong Date: Tue, 27 Feb 2024 13:02:13 +0800 Subject: [PATCH 1/3] fix: when re-running first job, not trigger all jobs any more --- routers/web/repo/actions/view.go | 4 ++-- routers/web/web.go | 1 - web_src/js/components/RepoActionView.vue | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 49387362b3537..5020eef55eb96 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -262,7 +262,7 @@ func ViewPost(ctx *context_module.Context) { } // Rerun will rerun jobs in the given run -// jobIndex = 0 means rerun all jobs +// jobIndex = -1 means rerun all jobs func Rerun(ctx *context_module.Context) { runIndex := ctx.ParamsInt64("run") jobIndex := ctx.ParamsInt64("job") @@ -297,7 +297,7 @@ func Rerun(ctx *context_module.Context) { return } - if jobIndex != 0 { + if jobIndex != -1 { jobs = []*actions_model.ActionRunJob{job} } diff --git a/routers/web/web.go b/routers/web/web.go index b1fa5cf3550d3..7d03e9be94622 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1370,7 +1370,6 @@ func registerRoutes(m *web.Route) { m.Post("/artifacts", actions.ArtifactsView) m.Get("/artifacts/{artifact_name}", actions.ArtifactsDownloadView) m.Delete("/artifacts/{artifact_name}", actions.ArtifactsDeleteView) - m.Post("/rerun", reqRepoActionsWriter, actions.Rerun) }) }, reqRepoActionsReader, actions.MustEnableActions) diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index 3801848519127..fcd0eae3f3c05 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -373,7 +373,7 @@ export function initRepositoryActionView() { - From d5632f217eb5db953f945866eceed145d4074d45 Mon Sep 17 00:00:00 2001 From: sillyguodong Date: Tue, 27 Feb 2024 13:40:22 +0800 Subject: [PATCH 2/3] fix: do not use -1 --- routers/web/repo/actions/view.go | 11 ++++++++--- routers/web/web.go | 1 + web_src/js/components/RepoActionView.vue | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 5020eef55eb96..09a9abc3fad6f 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -12,6 +12,7 @@ import ( "io" "net/http" "net/url" + "strconv" "strings" "time" @@ -262,10 +263,14 @@ func ViewPost(ctx *context_module.Context) { } // Rerun will rerun jobs in the given run -// jobIndex = -1 means rerun all jobs +// If jobIndex is a blank string, it means rerun all jobs func Rerun(ctx *context_module.Context) { runIndex := ctx.ParamsInt64("run") - jobIndex := ctx.ParamsInt64("job") + jobIndexStr := ctx.Params("job") + var jobIndex int64 + if jobIndexStr != "" { + jobIndex, _ = strconv.ParseInt(jobIndexStr, 10, 64) + } run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex) if err != nil { @@ -297,7 +302,7 @@ func Rerun(ctx *context_module.Context) { return } - if jobIndex != -1 { + if jobIndexStr != "" { jobs = []*actions_model.ActionRunJob{job} } diff --git a/routers/web/web.go b/routers/web/web.go index 7d03e9be94622..b1fa5cf3550d3 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1370,6 +1370,7 @@ func registerRoutes(m *web.Route) { m.Post("/artifacts", actions.ArtifactsView) m.Get("/artifacts/{artifact_name}", actions.ArtifactsDownloadView) m.Delete("/artifacts/{artifact_name}", actions.ArtifactsDeleteView) + m.Post("/rerun", reqRepoActionsWriter, actions.Rerun) }) }, reqRepoActionsReader, actions.MustEnableActions) diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index fcd0eae3f3c05..3801848519127 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -373,7 +373,7 @@ export function initRepositoryActionView() { - From 00743ae301dc31dbc4b9598bf0d5dadabef10476 Mon Sep 17 00:00:00 2001 From: sillyguodong Date: Tue, 27 Feb 2024 13:41:48 +0800 Subject: [PATCH 3/3] fix: comment --- routers/web/repo/actions/view.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 09a9abc3fad6f..f7a3a5dc37d9f 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -263,7 +263,7 @@ func ViewPost(ctx *context_module.Context) { } // Rerun will rerun jobs in the given run -// If jobIndex is a blank string, it means rerun all jobs +// If jobIndexStr is a blank string, it means rerun all jobs func Rerun(ctx *context_module.Context) { runIndex := ctx.ParamsInt64("run") jobIndexStr := ctx.Params("job")