Skip to content

Commit

Permalink
test: add migration and rollback test to GA
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Feb 13, 2024
1 parent ba4f1f6 commit 7f5c40c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 5 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/test-db-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test database migration and rollback

on:
push:
branches:
- 'main'
paths:
- 'services/api/database/**'
- '.github/workflows/test-db-migrations.yml'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'
paths:
- 'services/api/database/**'
- '.github/workflows/test-db-migrations.yml'

jobs:
makeup:
runs-on: ubuntu-latest
steps:
-
name: Checkout PR
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
fetch-depth: "0"
ref: ${{ github.event.pull_request.head.sha }}
-
name: Checkout Branch or Tag
uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}
with:
fetch-depth: "0"
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build necessary images
run: |
make build
-
name: Bring up a docker compose lagoon
run: |
make up
-
name: Show initial migration logs
run: |
docker compose -p lagoon logs api-init
-
name: Initiate rollback
run: |
docker compose -p lagoon exec api sh -c './node_modules/.bin/knex migrate:rollback --all --cwd /app/services/api/database'
-
name: Reperform initial migration
run: |
docker compose -p lagoon exec api sh -c './node_modules/.bin/knex migrate:latest --cwd /app/services/api/database'
-
name: Remove testing setup
run: |
make down
8 changes: 3 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ services:
- CONSOLE_LOGGING_LEVEL=trace
api-init:
image: ${IMAGE_REPO:-lagoon}/api
command: ./node_modules/.bin/knex migrate:latest --cwd /app/services/api/database
command: >
sh -c "./node_modules/.bin/knex migrate:list --cwd /app/services/api/database
&& ./node_modules/.bin/knex migrate:latest --cwd /app/services/api/database"
volumes:
- ./services/api/database:/app/services/api/database
- ./node-packages:/app/node-packages:delegated
Expand Down Expand Up @@ -195,10 +197,6 @@ services:
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minio123
local-registry:
image: ${IMAGE_REPO:-lagoon}/local-registry
ports:
- '5000:5000'
drush-alias:
image: uselagoon/drush-alias:latest
ports:
Expand Down

0 comments on commit 7f5c40c

Please sign in to comment.