From be512a2fbb871e16fb8ed920000a5379cda9efd6 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 17 May 2024 09:51:22 +0100 Subject: [PATCH] ci: fix test-migrations target when main branch is not present locally --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 874ae8ee56abc..7a24a293d16a8 100644 --- a/Makefile +++ b/Makefile @@ -797,8 +797,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) + COMMIT_FROM=$(shell git log -1 --format='%h' HEAD) + echo "COMMIT_FROM=$${COMMIT_FROM}" + COMMIT_TO=$(shell git log -1 --format='%h' origin/main) + echo "COMMIT_TO=$${COMMIT_TO}" + if [[ "$${COMMIT_FROM}" == "$${COMMIT_TO}" ]]; then echo "Nothing to do!"; exit 0; fi 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"