Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 195f63d

Browse files
committed
Extract current extension version to a single location
1 parent 07aa741 commit 195f63d

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

.github/workflows/go-e2e.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
docker_image_prefix:
1717
description: 'Docker image prefix'
1818
required: true
19-
default: 'ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2'
19+
default: 'ghcr.io/timescale/dev_promscale_extension:<branch>-ts2'
2020

2121
env:
2222
golang-version: 1.18.1
@@ -46,7 +46,8 @@ jobs:
4646
run: |
4747
branch_name=$(echo ${{github.head_ref || github.ref_name}} | sed 's#/#-#')
4848
possible_branch_tag=$(echo ${branch_name}-ts2)
49-
stable_branch_tag=$(echo 0.5.0-ts2)
49+
extension_version=$(cat EXTENSION_VERSION | tr -d '[:space:]')
50+
stable_branch_tag=$(echo ${extension_version}-ts2)
5051
image_base="ghcr.io/timescale/dev_promscale_extension"
5152
docker_image_12=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag}-pg12 ${image_base}:${stable_branch_tag}-pg12)
5253
docker_image_13=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag}-pg13 ${image_base}:${stable_branch_tag}-pg13)

.github/workflows/integration.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
run: |
3939
branch_name=$(echo ${{github.head_ref || github.ref_name}} | sed 's#/#-#')
4040
possible_branch_tag=$(echo ${branch_name}-ts2-pg${{matrix.pg}})
41-
stable_branch_tag=$(echo 0.5.0-ts2-pg${{matrix.pg}})
41+
extension_version=$(cat EXTENSION_VERSION | tr -d '[:space:]')
42+
stable_branch_tag=$(echo ${extension_version}-ts2-pg${{matrix.pg}})
4243
image_base="ghcr.io/timescale/dev_promscale_extension"
4344
docker_image=$(./scripts/fallback-docker.sh ${image_base}:${possible_branch_tag} ${image_base}:${stable_branch_tag})
4445
echo "::set-output name=docker_image::${docker_image}"

EXTENSION_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.5.0

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ pkg/tests/testdata/traces-dataset.sz:
2626

2727
.PHONY: e2e
2828
e2e: CURRENT_BRANCH?=$(shell git branch --show-current | sed 's#/#-#')
29-
e2e: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg14 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg14 $(GHCR_DOCKER_BASE):0.5.0-ts2-pg14)
29+
e2e: EXTENSION_VERSION=$(shell cat EXTENSION_VERSION | tr -d '[:space:]')
30+
e2e: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg14 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg14 $(GHCR_DOCKER_BASE):$(EXTENSION_VERSION)-ts2-pg14)
3031
e2e: pkg/tests/testdata/traces-dataset.sz generate
3132
go test -v ./pkg/tests/end_to_end_tests/ -timescale-docker-image=$(DOCKER_IMAGE)
3233
go test -v ./pkg/tests/end_to_end_tests/ -use-timescaledb=false -timescale-docker-image=$(DOCKER_IMAGE)
3334
go test -v ./pkg/tests/end_to_end_tests/ -use-multinode -timescale-docker-image=$(DOCKER_IMAGE)
3435

3536
.PHONY: upgrade-test
3637
upgrade-test: CURRENT_BRANCH?=$(shell git branch --show-current | sed 's#/#-#')
37-
upgrade-test: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg13 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg13 $(GHCR_DOCKER_BASE):0.5.0-ts2-pg13)
38+
upgrade-test: EXTENSION_VERSION=$(shell cat EXTENSION_VERSION | tr -d '[:space:]')
39+
upgrade-test: DOCKER_IMAGE?=$(shell ./scripts/fallback-docker.sh $(LOCAL_DOCKER_BASE):head-ts2-pg13 $(GHCR_DOCKER_BASE):$(CURRENT_BRANCH)-ts2-pg13 $(GHCR_DOCKER_BASE):$(EXTENSION_VERSION)-ts2-pg13)
3840
upgrade-test:
3941
go test -v ./pkg/tests/upgrade_tests/ -timescale-docker-image=$(DOCKER_IMAGE)
4042

pkg/internal/testhelpers/containers_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"flag"
1010
"fmt"
11+
constants "github.com/timescale/promscale/pkg/tests"
1112
"io/ioutil"
1213
"os"
1314
"path/filepath"
@@ -46,8 +47,7 @@ func TestWithDB(t *testing.T) {
4647
if testing.Short() {
4748
t.Skip("skipping integration test")
4849
}
49-
// TODO (james): Replace hardcoded value
50-
extensionState := NewTestOptions(timescaleBit, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
50+
extensionState := NewTestOptions(timescaleBit, constants.PromscaleExtensionContainer)
5151
WithDB(t, *testDatabase, Superuser, false, extensionState, func(db *pgxpool.Pool, t testing.TB, connectURL string) {
5252
var res int
5353
err := db.QueryRow(context.Background(), "SELECT 1").Scan(&res)
@@ -63,8 +63,7 @@ func TestWithDB(t *testing.T) {
6363
func runMain(m *testing.M) int {
6464
flag.Parse()
6565
ctx := context.Background()
66-
// TODO (james): Replace hardcoded value
67-
extensionState := NewTestOptions(timescaleBit, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
66+
extensionState := NewTestOptions(timescaleBit, constants.PromscaleExtensionContainer)
6867
if !testing.Short() && *useDocker {
6968
_, closer, err := StartPGContainer(ctx, nil, extensionState, "", false)
7069
if err != nil {

pkg/tests/constants.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package constants
2+
3+
import (
4+
"os"
5+
"strings"
6+
)
7+
8+
var (
9+
PromscaleExtensionVersion string
10+
PromscaleExtensionContainer string
11+
)
12+
13+
func init() {
14+
content, err := os.ReadFile("../../../EXTENSION_VERSION")
15+
if err != nil {
16+
panic(err)
17+
}
18+
19+
PromscaleExtensionVersion = strings.TrimSpace(string(content))
20+
PromscaleExtensionContainer = "ghcr.io/timescale/dev_promscale_extension:" + PromscaleExtensionVersion + "-ts2-pg14"
21+
}

pkg/tests/end_to_end_tests/main_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"flag"
1010
"fmt"
11+
constants "github.com/timescale/promscale/pkg/tests"
1112
"io"
1213
"os"
1314
"path/filepath"
@@ -31,12 +32,11 @@ import (
3132
)
3233

3334
var (
34-
testDatabase = flag.String("database", "tmp_db_timescale_migrate_test", "database to run integration tests on")
35-
updateGoldenFiles = flag.Bool("update", false, "update the golden files of this test")
36-
useDocker = flag.Bool("use-docker", true, "start database using a docker container")
37-
useTimescaleDB = flag.Bool("use-timescaledb", true, "use TimescaleDB")
38-
// TODO (james): Replace hardcoded value
39-
timescaleDockerImage = flag.String("timescale-docker-image", "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14", "TimescaleDB docker image to run tests against")
35+
testDatabase = flag.String("database", "tmp_db_timescale_migrate_test", "database to run integration tests on")
36+
updateGoldenFiles = flag.Bool("update", false, "update the golden files of this test")
37+
useDocker = flag.Bool("use-docker", true, "start database using a docker container")
38+
useTimescaleDB = flag.Bool("use-timescaledb", true, "use TimescaleDB")
39+
timescaleDockerImage = flag.String("timescale-docker-image", constants.PromscaleExtensionContainer, "TimescaleDB docker image to run tests against")
4040
useMultinode = flag.Bool("use-multinode", false, "use TimescaleDB Multinode")
4141
useTimescaleDBNightly = flag.Bool("use-timescaledb-nightly", false, "use TimescaleDB nightly images")
4242
printLogs = flag.Bool("print-logs", false, "print TimescaleDB logs")

pkg/tests/upgrade_tests/upgrade_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"flag"
1111
"fmt"
12+
constants "github.com/timescale/promscale/pkg/tests"
1213
"io"
1314
"io/ioutil"
1415
"net"
@@ -43,7 +44,7 @@ var (
4344
testDatabase = flag.String("database", "tmp_db_timescale_upgrade_test", "database to run integration tests on")
4445
printLogs = flag.Bool("print-logs", false, "print TimescaleDB logs")
4546
// use "local/dev_promscale_extension:head-ts2-pg13" for local testing
46-
dockerImage = flag.String("timescale-docker-image", "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14", "TimescaleDB docker image for latest version to run tests against")
47+
dockerImage = flag.String("timescale-docker-image", constants.PromscaleExtensionContainer, "TimescaleDB docker image for latest version to run tests against")
4748
baseExtensionState testhelpers.TestOptions
4849
)
4950

@@ -789,8 +790,7 @@ func startDB(t *testing.T, ctx context.Context) (*pgx.Conn, testcontainers.Conta
789790
t.Fatal(err)
790791
}
791792

792-
// TODO (james): Replace hardcoded value
793-
extensionState := testhelpers.NewTestOptions(testhelpers.Timescale, "ghcr.io/timescale/dev_promscale_extension:0.5.0-ts2-pg14")
793+
extensionState := testhelpers.NewTestOptions(testhelpers.Timescale, constants.PromscaleExtensionContainer)
794794

795795
dbContainer, closer, err := testhelpers.StartDatabaseImage(ctx, t, "timescaledev/promscale-extension:testing-extension-upgrade", tmpDir, dataDir, *printLogs, extensionState)
796796
if err != nil {

0 commit comments

Comments
 (0)