Skip to content

Commit 7d3bb61

Browse files
committed
Run PostGIS in test workflow
To be able to run the tests against a version of PostgreSQL that supports PostGIS. I've also renamed a few of the jobs and steps to make them clearer what they do. Jira-Issue: MAV-6379 Jira-Issue: MAV-6706
1 parent c1ef255 commit 7d3bb61

5 files changed

Lines changed: 43 additions & 39 deletions

File tree

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
name: Create Dockerized Database
2-
run-name: Creating dockerized image from ${{ github.ref_name }}
1+
name: Build and push database image
2+
run-name: Build and push database image for ${{ github.ref_name }}
33

44
on:
55
workflow_dispatch:
66
push:
7-
branches:
8-
- next
7+
branches: [next]
98
workflow_call:
109
inputs:
1110
github_ref:
@@ -17,8 +16,8 @@ permissions:
1716
contents: read
1817

1918
jobs:
20-
setup-development-database:
21-
name: Setup Development Database
19+
build-and-push-database-image:
20+
name: Build and push database image
2221
runs-on: ubuntu-latest
2322
env:
2423
RAILS_ENV: development
@@ -32,34 +31,36 @@ jobs:
3231
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3332
with:
3433
ref: ${{ inputs.github_ref || github.ref_name == 'next' && 'next' || github.ref_name }}
35-
repository: nhsuk/manage-vaccinations-in-schools
34+
repository: nhsdigital/manage-vaccinations-in-schools
3635
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3736
with:
3837
node-version-file: .tool-versions
3938
cache: yarn
40-
- name: Build custom postgres image
41-
run: |
42-
echo -e "FROM postgres:16.11\n\nENV PGDATA=\"/var/lib/postgresql/mydata\"" > db.Dockerfile
43-
docker build -t custom-postgres:latest -f db.Dockerfile .
44-
- name: Start db container
39+
- name: Create Dockerfile
40+
run: >-
41+
echo -e \
42+
"FROM postgis/postgis:17-master\nENV PGDATA=\"/var/lib/postgresql/mydata\"" \
43+
> database.Dockerfile
44+
- name: Build image
45+
run: docker build -t database:latest -f database.Dockerfile .
46+
- name: Start container
4547
run: |
4648
docker run -d \
4749
--name database \
4850
-e "POSTGRES_HOST_AUTH_METHOD=trust" \
4951
-p 5432:5432 \
50-
custom-postgres:latest
51-
- name: Wait for db to be ready
52+
database:latest
53+
- name: Wait for database to be ready
5254
run: |
5355
docker exec database bash -c '
5456
until pg_isready -U postgres; do
5557
echo "Waiting for postgres..."
5658
sleep 2
57-
done
58-
'
59+
done'
5960
- uses: ruby/setup-ruby@60ecfba8750476ff216b59eee3b88218bb5111cc # v1.303.0
6061
with:
6162
bundler-cache: true
62-
- name: Populate database for testing
63+
- name: Set up database for testing
6364
run: |
6465
bin/rails db:setup
6566
bin/rails feature_flags:enable_for_development
@@ -73,17 +74,17 @@ jobs:
7374
id: login-ecr
7475
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2.1.3
7576
# yamllint disable rule:line-length
76-
- name: get github ref short
77-
id: github-ref
77+
- name: Get image tag
78+
id: get-image-tag
7879
run: |
7980
git_ref=$(git rev-parse ${{ inputs.github_ref || github.ref_name == 'next' && 'origin/next' || github.ref_name }})
80-
echo "ref=$git_ref" >> "$GITHUB_OUTPUT"
81-
- name: Commit postgres container with database
81+
echo "value=$git_ref" >> "$GITHUB_OUTPUT"
82+
- name: Commit image
8283
run: >-
8384
docker commit database "${{ steps.login-ecr.outputs.registry
84-
}}/mavis/development/postgres_db:${{ steps.github-ref.outputs.ref }}"
85+
}}/mavis/development/postgres_db:${{ steps.get-image-tag.outputs.value }}"
8586
- name: Push image
8687
run: >-
8788
docker push "${{ steps.login-ecr.outputs.registry }}/mavis/development/postgres_db:${{
88-
steps.github-ref.outputs.ref }}"
89+
steps.get-image-tag.outputs.value }}"
8990
# yamllint enable rule:line-length

.github/workflows/end-to-end-tests-aws.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: AWS deployment E2E tests
1+
name: AWS
22

33
on:
44
workflow_call:
@@ -122,7 +122,7 @@ jobs:
122122
permissions:
123123
id-token: write
124124
contents: read
125-
uses: ./.github/workflows/create_dockerized_db.yml
125+
uses: ./.github/workflows/build-and-push-database-image.yml
126126
with:
127127
github_ref: ${{ needs.check-database-image-presence.outputs.db_git_ref_sha }}
128128
launch-dockerized-devimage:

.github/workflows/end-to-end-tests-local.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Local E2E tests
1+
name: Local
22

33
on: [workflow_call]
44

55
jobs:
66
end-to-end-tests:
77
runs-on: ubuntu-latest
88
services:
9-
postgres:
10-
image: postgres:17.2
9+
postgresql:
10+
image: postgis/postgis:17-master
1111
env:
1212
POSTGRES_PASSWORD: postgres
1313
options: >-

.github/workflows/end-to-end-tests-on-pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: E2E tests on PR
1+
name: End-to-end tests
22

33
on: [pull_request]
44

@@ -11,7 +11,7 @@ permissions: {}
1111
jobs:
1212
aws-e2e-flow:
1313
if: github.event.pull_request.head.repo.full_name == github.repository
14-
name: AWS deployment E2E tests
14+
name: AWS
1515
permissions:
1616
id-token: write
1717
contents: write
@@ -22,7 +22,7 @@ jobs:
2222

2323
local-e2e-flow:
2424
if: github.event.pull_request.head.repo.full_name != github.repository
25-
name: Local E2E tests
25+
name: Local
2626
uses: ./.github/workflows/end-to-end-tests-local.yml
2727

2828
ensure-run-success:

.github/workflows/test.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
name: RSpec
1212
runs-on: ubuntu-latest
1313
services:
14-
postgres:
15-
image: postgres:17.2
14+
postgresql:
15+
image: postgis/postgis:17-master
1616
env:
1717
POSTGRES_PASSWORD: postgres
1818
options: >-
@@ -50,8 +50,8 @@ jobs:
5050
name: Seeds
5151
runs-on: ubuntu-latest
5252
services:
53-
postgres:
54-
image: postgres:17.2
53+
postgresql:
54+
image: postgis/postgis:17-master
5555
env:
5656
POSTGRES_PASSWORD: postgres
5757
options: >-
@@ -60,7 +60,8 @@ jobs:
6060
- 5432:5432
6161
env:
6262
RAILS_ENV: development
63-
DATABASE_URL: postgres://postgres:postgres@localhost:5432/manage_vaccinations_development
63+
DATABASE_URL: >-
64+
postgis://postgres:postgres@localhost:5432/manage_vaccinations_development
6465
steps:
6566
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6667
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
@@ -70,7 +71,7 @@ jobs:
7071
- uses: ruby/setup-ruby@60ecfba8750476ff216b59eee3b88218bb5111cc # v1.303.0
7172
with:
7273
bundler-cache: true
73-
- name: Check seeds run
74+
- name: Run seeds
7475
run: bin/rails db:prepare
7576

7677
jest:
@@ -82,5 +83,7 @@ jobs:
8283
with:
8384
node-version-file: .tool-versions
8485
cache: yarn
85-
- run: yarn install --immutable --immutable-cache --check-cache
86-
- run: yarn test
86+
- name: Install dependencies
87+
run: yarn install --immutable --immutable-cache --check-cache
88+
- name: Run tests
89+
run: yarn test

0 commit comments

Comments
 (0)