From ed1f945d817fdeeda4b7c04b970944b9c3fa7242 Mon Sep 17 00:00:00 2001 From: HenryNguyen5 <6404866+HenryNguyen5@users.noreply.github.com> Date: Tue, 7 May 2024 13:21:11 -0400 Subject: [PATCH] Update CI postgres setup (#13123) * Remove deprecated version field * Add pg_dump wrapper for db tests --- .github/actions/setup-postgres/bin/pg_dump | 23 +++++++++++++++++++ .../actions/setup-postgres/docker-compose.yml | 1 - 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 .github/actions/setup-postgres/bin/pg_dump diff --git a/.github/actions/setup-postgres/bin/pg_dump b/.github/actions/setup-postgres/bin/pg_dump new file mode 100755 index 00000000000..d8135ad824c --- /dev/null +++ b/.github/actions/setup-postgres/bin/pg_dump @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# This script acts as a docker replacement around pg_dump so that developers can +# run DB involved tests locally without having postgres installed. +# +# Installation: +# - Make sure that your PATH doesn't already contain a postgres installation +# - Add this script to your PATH +# +# Usage: +# You should be able to setup your test db via: +# - go build -o chainlink.test . # Build the chainlink binary to run test db prep commands from +# - export CL_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable" +# - pushd .github/actions/setup-postgres/ # Navigate to the setup-postgres action so we can spin up a docker postgres +# instance +# - docker compose up # Spin up postgres +# - ./chainlink.test local db preparetest # Run the db migration, which will shell out to our pg_dump wrapper too. +# - popd +# - go test -timeout 30s ./core/services/workflows/... -v # Run tests that use the database + +cd "$(dirname "$0")" || exit + +docker compose exec -T postgres pg_dump "$@" diff --git a/.github/actions/setup-postgres/docker-compose.yml b/.github/actions/setup-postgres/docker-compose.yml index 3acaa1ecd1b..23f8d82b917 100644 --- a/.github/actions/setup-postgres/docker-compose.yml +++ b/.github/actions/setup-postgres/docker-compose.yml @@ -1,5 +1,4 @@ name: gha_postgres -version: "3.8" services: postgres: ports: