From 95a4ef2ef5518f6ea41e3265731b0b47171ac9cf Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Thu, 12 Dec 2024 10:51:44 +0100 Subject: [PATCH] install postgresql-17 package in test job if necessary This opens a migration path for moving to the new version of `github.com/sapcc/go-bits/easypg`. The DB service on port 54321 can be used before migration, and the installed DB package can be used after migration on port 54320. --- internal/ghworkflow/workflow_ci.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/ghworkflow/workflow_ci.go b/internal/ghworkflow/workflow_ci.go index aa3e344..ecc4da3 100644 --- a/internal/ghworkflow/workflow_ci.go +++ b/internal/ghworkflow/workflow_ci.go @@ -4,6 +4,7 @@ package ghworkflow import ( + "fmt" "strings" "github.com/sapcc/go-makefile-maker/internal/core" @@ -37,7 +38,16 @@ func ciWorkflow(cfg core.Configuration, sr golang.ScanResult) { testJob := buildOrTestBaseJob("Test", cfg) testJob.Needs = []string{"build"} + testCmd := []string{ + "make build/cover.out", + } if ghwCfg.CI.Postgres || sr.UsesPostgres { + testCmd = append([]string{ + "sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y", + "sudo apt-get install --no-install-recommends postgresql-" + core.DefaultPostgresVersion, + fmt.Sprintf("export PATH=/usr/lib/postgresql/%s/bin:$PATH", core.DefaultPostgresVersion), + }, testCmd...) + // TODO remove this service once all users migrated to use github.com/sapcc/go-bits/easypg testJob.Services = map[string]jobService{"postgres": { Image: "postgres:" + core.DefaultPostgresVersion, Env: map[string]string{"POSTGRES_PASSWORD": "postgres"}, @@ -53,7 +63,7 @@ func ciWorkflow(cfg core.Configuration, sr golang.ScanResult) { } testJob.addStep(jobStep{ Name: "Run tests and generate coverage report", - Run: "make build/cover.out", + Run: makeMultilineYAMLString(testCmd), }) if ghwCfg.CI.Coveralls && !ghwCfg.IsSelfHostedRunner { multipleOS := len(ghwCfg.CI.RunnerType) > 1