From 27cd3b22122d72ee61b0f2320223dc9946dc4115 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Fri, 17 Feb 2023 09:16:00 +1100 Subject: [PATCH 1/3] CI: Add test to ensure schema migrations are complete --- .github/workflows/haskell.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 8e3fd7581..8819ccfba 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -40,7 +40,7 @@ jobs: - name: Install Postgres support (macOS) if: matrix.os == 'macos-latest' run: | - brew install postgresql@14 libpq openssl@1.1 + brew install postgresql@14 libpq openssl@1.1 pkg-config brew services start postgresql sudo mkdir -p /var/run/postgresql/ sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432 @@ -71,7 +71,7 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update - sudo apt-get -y install libsodium23 libsodium-dev libsystemd0 libsystemd-dev + sudo apt-get -y install libsodium23 libsodium-dev libsystemd0 libsystemd-dev git sudo apt-get -y remove --purge software-properties-common sudo apt-get -y autoremove @@ -107,7 +107,7 @@ jobs: - uses: actions/cache@v3 name: Cache cabal store with: - path: | + path: | ${{ steps.setup-haskell.outputs.cabal-store }} dist-newstyle key: cache-cabal-store-v1-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} @@ -144,3 +144,23 @@ jobs: - name: Run tests run: cabal test all -j1 + + - name: Check that Schema Migrations are complete + run: | + PGPASSFILE=config/pgpass-mainnet cabal run cardano-db-tool -- run-migrations --mdir schema/ --ldir /tmp/ + echo "A" + git --version + echo "B" + git status schema + echo "C" + git status schema | grep schema/migration > /tmp/schema.diff + echo "D" + echo "*************************************************************" + cat /tmp/schema.diff + echo "*************************************************************" + line_count="$(wc -l < /tmp/schema.diff)" + if test ${line_count} -ne 0 ; then + echo "Schema diff" + cat /tmp/schema.diff + exit 1 + fi From 9ddfc65f2ec055a993cde3be3eb80b8cadf3bf3e Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 1 Mar 2023 15:34:32 +1100 Subject: [PATCH 2/3] fixup --- .github/workflows/haskell.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 8819ccfba..0b6819dac 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -153,8 +153,12 @@ jobs: echo "B" git status schema echo "C" - git status schema | grep schema/migration > /tmp/schema.diff + git status schema echo "D" + git status schema | grep schema/migration + echo "E" + git status schema | grep schema/migration > /tmp/schema.diff + echo "F" echo "*************************************************************" cat /tmp/schema.diff echo "*************************************************************" From 93838fa9ea26f713a676db25137835b25926fd15 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 1 Mar 2023 16:08:35 +1100 Subject: [PATCH 3/3] fixup --- .github/workflows/haskell.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 0b6819dac..e2df961a4 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -153,12 +153,10 @@ jobs: echo "B" git status schema echo "C" - git status schema - echo "D" git status schema | grep schema/migration - echo "E" + echo "D" git status schema | grep schema/migration > /tmp/schema.diff - echo "F" + echo "E" echo "*************************************************************" cat /tmp/schema.diff echo "*************************************************************"