Skip to content

Commit efe809c

Browse files
committed
feat(ci): Test migrations in CI
1 parent ab81b85 commit efe809c

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Check migrations and seed
2+
3+
# This job should run whenever a migration is updated
4+
# it should check whether the migration + seed still works as well as
5+
# check whether the pull request message mentions the migration
6+
on:
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
paths:
13+
- '**/migrations/*.php'
14+
- '**/test/Seeder/*.php'
15+
16+
jobs:
17+
migration_seed:
18+
runs-on: ubuntu-latest
19+
# services:
20+
# postgresql:
21+
# image: postgres
22+
# ports:
23+
# - 5432:5432
24+
# hostname: postgresql
25+
# env:
26+
# POSTGRES_USER: gewisdb
27+
# POSTGRES_PASSWORD: gewisdb
28+
# options: >-
29+
# --health-cmd pg_isready
30+
# --health-interval 10s
31+
# --health-timeout 5s
32+
# --health-retries 5
33+
steps:
34+
- name: Echo
35+
run: echo "This job should only run in if migrations or fixtures are updated"
36+
37+
- name: Checkout base branch
38+
uses: actions/checkout@v4
39+
# with:
40+
# ref: ${{ github.event.pull_request.base.ref }}
41+
42+
- name: Copy .env
43+
run: cp .env.dist .env
44+
45+
- name: setup docker buildx
46+
uses: docker/setup-buildx-action@v2
47+
48+
- name: build
49+
run: docker buildx bake --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml
50+
51+
- name: run
52+
run: docker compose --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml up -d --build
53+
54+
- name: migrate
55+
run: make migrate
56+
57+
- name: Checkout head branch
58+
uses: actions/checkout@v4
59+
60+
- name: Copy .env
61+
run: cp .env.dist .env
62+
63+
- name: build
64+
run: docker buildx bake --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml
65+
66+
- name: run
67+
run: docker compose --file docker-compose.github.yml --file docker-compose.override.yml --file docker-compose.yml up -d --build
68+
69+
- name: migrate
70+
run: make migrate
71+
72+
- name: seed
73+
run: make seed
74+
75+
- name: stop
76+
run: docker compose down

docker-compose.github.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
pgadmin:
3+
build:
4+
cache_from: [ type=gha ]
5+
cache_to: [ "type=gha,mode=max" ]
6+
postgresql:
7+
build:
8+
cache_from: [ type=gha ]
9+
cache_to: [ "type=gha,mode=max" ]
10+
nginx:
11+
build:
12+
cache_from: [ type=gha ]
13+
cache_to: [ "type=gha,mode=max" ]
14+
web:
15+
build:
16+
cache_from: [ type=gha ]
17+
cache_to: [ "type=gha,mode=max" ]

0 commit comments

Comments
 (0)