diff --git a/internal/core/config.go b/internal/core/config.go index 50c55de..bc0fde0 100644 --- a/internal/core/config.go +++ b/internal/core/config.go @@ -141,6 +141,7 @@ type CIWorkflowConfig struct { IgnorePaths []string `yaml:"ignorePaths"` RunnerType []string `yaml:"runOn"` Coveralls bool `yaml:"coveralls"` + Postgres bool `yaml:"postgres"` } // LicenseWorkflowConfig appears in type Configuration. @@ -252,6 +253,9 @@ func (c *Configuration) Validate() { // Validate CI workflow configuration. if ghwCfg.CI.Enabled { + if !ghwCfg.CI.Postgres { + logg.Fatal("githubWorkflow.ci.enabled must be set to 'true' when githubWorkflow.ci.postgres is enabled") + } if len(ghwCfg.CI.RunnerType) > 1 && !strings.HasPrefix(ghwCfg.CI.RunnerType[0], "ubuntu") { logg.Fatal("githubWorkflow.ci.runOn must only define a single Ubuntu based runner when githubWorkflow.ci.postgres is enabled") } diff --git a/internal/ghworkflow/workflow_ci.go b/internal/ghworkflow/workflow_ci.go index 86dce7a..c3e8056 100644 --- a/internal/ghworkflow/workflow_ci.go +++ b/internal/ghworkflow/workflow_ci.go @@ -48,7 +48,7 @@ func ciWorkflow(cfg core.Configuration, sr golang.ScanResult) { testJob := buildOrTestBaseJob("Test", cfg) testJob.Needs = []string{"build"} - if sr.UsesPostgres { + if ghwCfg.CI.Postgres || sr.UsesPostgres { testJob.Services = map[string]jobService{"postgres": { Image: "postgres:" + core.DefaultPostgresVersion, Env: map[string]string{"POSTGRES_PASSWORD": "postgres"},