From 5a0428ede3e8f242860d121ab3ee8712a1fe2f14 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 9 Mar 2023 14:46:23 +0100 Subject: [PATCH] do not run initDB within integration tests --- cmd/actions.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/actions.go b/cmd/actions.go index f7aa6d92f2..7a3bb7f226 100644 --- a/cmd/actions.go +++ b/cmd/actions.go @@ -9,7 +9,6 @@ import ( "log" actions_model "code.gitea.io/gitea/models/actions" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" @@ -30,18 +29,20 @@ var CmdActions = cli.Command{ }, } +func maybeInitDB(stdCtx context.Context) error { + if setting.Database.Type == "" { + if err := initDB(stdCtx); err != nil { + return err + } + } + return nil +} + func runActions(ctx *cli.Context) error { - setting.InitProviderFromExistingFile() - setting.LoadCommonSettings() - setting.LoadDBSetting() + stdCtx := context.Background() - stdCtx, cancel := installSignals() - defer cancel() - - if err := db.InitEngine(stdCtx); err != nil { - fmt.Println(err) - fmt.Println("Check if you are using the right config file. You can use a --config directive to specify one.") - return nil + if err := maybeInitDB(stdCtx); err != nil { + log.Fatalf("maybeInitDB %v", err) } if ctx.Bool("registration-token-admin") {