From a04c76ce40c61bf47af100559797383df4f12e54 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 24 Apr 2024 08:31:01 +0100 Subject: [PATCH] ci: release: test migrations before building (#13051) --- .github/workflows/release.yaml | 4 ++++ Makefile | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 74c4f6e796..99ffb29b32 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -130,6 +130,10 @@ jobs: AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }} AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }} + - name: Test migrations from current ref to main + run: | + make test-migrations + - name: Build binaries run: | set -euo pipefail diff --git a/Makefile b/Makefile index 5c74420357..5eeba4bb06 100644 --- a/Makefile +++ b/Makefile @@ -785,10 +785,11 @@ test-postgres: test-postgres-docker test-migrations: test-postgres-docker echo "--- test migrations" + set -euo pipefail COMMIT_FROM=$(shell git rev-parse --short HEAD) COMMIT_TO=$(shell git rev-parse --short main) - DB_NAME=$(shell go run scripts/migrate-ci/main.go) - go run ./scripts/migrate-test/main.go --from="$$COMMIT_FROM" --to="$$COMMIT_TO" --postgres-url="postgresql://postgres:postgres@localhost:5432/$$DB_NAME?sslmode=disable" + echo "DROP DATABASE IF EXISTS migrate_test_$${COMMIT_FROM}; CREATE DATABASE migrate_test_$${COMMIT_FROM};" | psql 'postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable' + go run ./scripts/migrate-test/main.go --from="$$COMMIT_FROM" --to="$$COMMIT_TO" --postgres-url="postgresql://postgres:postgres@localhost:5432/migrate_test_$${COMMIT_FROM}?sslmode=disable" # NOTE: we set --memory to the same size as a GitHub runner. test-postgres-docker: