Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated testing for applying migrations in a named schema #146

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Testing Flyway Migrations
name: "Testing Flyway Migrations: Public Schema"
on:
workflow_dispatch:
pull_request:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/ALL-testMigrateTripal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Testing Flyway Migrations: Named Schema Teacup"
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]

jobs:
run-tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
pgsql-version:
- "12"
- "13"
- "14"
- "15"
- "16"
steps:
# Check out the repo
- name: Checkout Repository
uses: actions/checkout@v4
# Here we fully build a docker using the current checked out code
# to ensure we test the current migrations.
- name: Build Docker Image
run: |
docker build --tag gmod/chado:local \
--file docker/Dockerfile \
--build-arg PGSQL_VERSION="${{ matrix.pgsql-version }}" \
--build-arg SCHEMA_NAME="teacup" \
--build-arg APPLY_MIGRATIONS=0 ./
# Just spin up docker the good ol' fashion way
# then run flyway baseline and migrate.
- name: Run Flyway Migrate
run: |
docker run --name=chadodocker -tid gmod/chado:local
sleep 30
docker exec chadodocker flyway migrate
12 changes: 11 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM ubuntu:24.04
ARG CHADO_VERSION='1.31'
ARG PGSQL_VERSION='16'
ARG APPLY_MIGRATIONS='0'
ARG SCHEMA_NAME='public'

RUN apt-get update

Expand Down Expand Up @@ -39,12 +40,21 @@ RUN cp flyway.toml /root/flyway.toml \
&& chmod +x /usr/bin/entrypoint.sh \
&& cp motd /etc/motd

RUN if [ "$SCHEMA_NAME" != "public" ] ; then \
/etc/init.d/postgresql start \
&& sleep 30 \
&& su -c "psql -d chado -c \"ALTER SCHEMA public RENAME TO $SCHEMA_NAME; CREATE SCHEMA public;\"" - postgres \
&& sed -i "s/public/$SCHEMA_NAME/g" /root/flyway.toml \
&& /etc/init.d/postgresql stop; \
fi

RUN /etc/init.d/postgresql start \
&& sleep 30 \
&& flyway baseline \
&& if [ "$APPLY_MIGRATIONS" = "1" ] ; then \
flyway migrate; \
fi
fi \
&& /etc/init.d/postgresql stop

WORKDIR /Chado

Expand Down
Loading