Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
b1fb27d
Create LICENSE.md
eatyourpeas Nov 21, 2022
ebbe7d7
add logo
eatyourpeas Nov 21, 2022
dd5d39e
remove print statement
eatyourpeas Nov 22, 2022
1749265
update readme
eatyourpeas Nov 22, 2022
19e9845
add access to green spaces
eatyourpeas Nov 22, 2022
0f74f22
update access to green spaces
eatyourpeas Nov 24, 2022
05fb172
readme update
eatyourpeas Nov 24, 2022
304c632
fix readme image
eatyourpeas Nov 24, 2022
bae73fb
dockerize
eatyourpeas Mar 14, 2023
94b6a32
fix see to docker compose
eatyourpeas Mar 14, 2023
e9f233e
fix see for english deprivation scores
eatyourpeas Mar 16, 2023
38f7ce9
add welsh data csv
eatyourpeas Mar 16, 2023
89f7c81
welsh data included
eatyourpeas Mar 17, 2023
86b71b8
Welsh data working
eatyourpeas Mar 17, 2023
f284456
seed to include welsh and english scores
eatyourpeas Mar 18, 2023
0e08666
remove migrations
eatyourpeas Mar 18, 2023
c6ef077
Add or update the Azure App Service build and deployment workflow config
eatyourpeas Mar 18, 2023
11b8630
common requirements
eatyourpeas Mar 18, 2023
911905e
seed fix
eatyourpeas Mar 18, 2023
1ee4de2
put back postgres
eatyourpeas Mar 19, 2023
1690130
psycog2 replace
eatyourpeas Mar 19, 2023
1649d86
settings change
eatyourpeas Mar 19, 2023
afa8907
progress bar
eatyourpeas Mar 19, 2023
c445225
datazone names
eatyourpeas Mar 19, 2023
44041a1
csrf settings
eatyourpeas Mar 19, 2023
c16dc6a
update readme
eatyourpeas Mar 19, 2023
5c5ad07
add error handling
eatyourpeas Mar 19, 2023
35c4384
update readme
eatyourpeas Mar 19, 2023
014e9fe
add citation
eatyourpeas Mar 19, 2023
dbb9a33
add django-filters
eatyourpeas Mar 19, 2023
55ecd34
readme typo
eatyourpeas Mar 19, 2023
ccef3fb
is_postcode_valid fix
eatyourpeas Mar 20, 2023
fb1fb7f
filters
eatyourpeas Mar 20, 2023
5b11294
fix filters
eatyourpeas Mar 21, 2023
ea90c6f
Added `drf-spectacular` to requirements
anchit-chandran Mar 23, 2023
0fb5e16
Add `drf-spectacular` settings
anchit-chandran Mar 23, 2023
46d673d
add swagger url paths
anchit-chandran Mar 23, 2023
2684a70
download `openapi.json` file
anchit-chandran Mar 23, 2023
74967c0
`openapi` file is `.yml`
anchit-chandran Mar 23, 2023
77bb974
Manually convert `.yml` to `.json`
anchit-chandran Mar 23, 2023
7a12e67
add `postcode` parameter to /boundaries endpoint
anchit-chandran Mar 23, 2023
d83a43e
added `postcode `openapiparameter
anchit-chandran Mar 23, 2023
b544562
add `postcode` openapiparameter
anchit-chandran Mar 23, 2023
b40c742
adds api description and explicit serializer for `LSOAViewSet`
anchit-chandran Mar 24, 2023
ac75cec
update description
anchit-chandran Mar 24, 2023
c09e159
constrain to get requests
eatyourpeas Mar 25, 2023
952e5fc
Merge pull request #3 from anchit-chandran/main
eatyourpeas Mar 25, 2023
1e901f0
add quantile endpoint
eatyourpeas Mar 26, 2023
a1c3195
update readme
eatyourpeas Mar 26, 2023
f958c4e
fix ireland route
eatyourpeas Mar 26, 2023
7591133
remove hardcoded DEBUG=True and set to environment
pacharanero Mar 28, 2023
0172b67
Merge branch 'main' of github.com:rcpch/rcpch-census-platform
pacharanero Mar 28, 2023
c8aba33
remove depth from serializers
eatyourpeas Mar 29, 2023
df7fa42
fixes and improvements to Dockerfile, docker-compose, and scripts
pacharanero Mar 30, 2023
019517b
Merge remote-tracking branch 'origin/main' into live
pacharanero Mar 30, 2023
570473e
removes /api/v1/ from all URLs
pacharanero Mar 30, 2023
15800dc
removes (renamed) dockerfile
pacharanero Mar 30, 2023
ffcb2d9
pyenv info in README
pacharanero Mar 30, 2023
59e1926
adds an error to catch empty postcode
pacharanero Mar 30, 2023
7e6b0e2
removes auth and sets default rendering of response to JSON (not HTML)
pacharanero Mar 30, 2023
18be602
dockerfile updates
anchit-chandran Mar 30, 2023
2ec02d5
tidy imports
pacharanero Mar 30, 2023
582feac
JSON API view at root URL
pacharanero Mar 30, 2023
2289321
Merge branch 'fix-api-path-and-auth' into live
pacharanero Mar 30, 2023
7de908e
Add or update the Azure App Service build and deployment workflow config
pacharanero Mar 30, 2023
2c3d7e7
remove 'main' branch and deployment workflow file
pacharanero Mar 30, 2023
2f231a4
fix DJANGO_SECRET_KEY to RCPCH_CENSUS_ENGINE_SECRET_KEY
pacharanero Mar 30, 2023
34cfbfc
fix to schema endpoint naming
pacharanero Mar 30, 2023
e950972
remove all authentication/permissions
pacharanero Mar 30, 2023
2f84371
updates `docker-compose`files to work without permission issues on WS…
anchit-chandran Mar 30, 2023
f3223f7
Merge branch 'live' of https://github.com/rcpch/rcpch-census-platform…
anchit-chandran Mar 30, 2023
b9bc4d6
changed the pyenv name to better reflect the current name of the project
pacharanero Mar 30, 2023
524b5a4
newly generated openapi.json and openapi.yml
pacharanero Mar 30, 2023
076e129
tweaks to README
pacharanero Mar 30, 2023
8fad546
Merge branch 'live' of github.com:rcpch/rcpch-census-platform into live
pacharanero Mar 30, 2023
849b07a
adds 2 examples requests /boundaries endpoint
anchit-chandran Mar 30, 2023
d31a7ee
Merge branch 'live' of https://github.com/rcpch/rcpch-census-platform…
anchit-chandran Mar 30, 2023
1670e8c
adds example response to LSOASerializer
anchit-chandran Mar 30, 2023
3325452
adds response example EnglishIndexMultipleDeprivationSerializer
anchit-chandran Mar 30, 2023
921a313
removes `Response( )` to make multiple index views work
anchit-chandran Mar 31, 2023
ff38b48
removes permissions throughout `views.py`
anchit-chandran Mar 31, 2023
6f197f2
adds standard docstrings and serializer examples where possible
anchit-chandran Mar 31, 2023
1873a5a
test commit for GH Actions
anchit-chandran Apr 3, 2023
2092e8d
Remove redundant call to postcodes.io validate
mbarton Jul 8, 2024
120d78f
Remove helper entirely
mbarton Jul 8, 2024
c21c42e
Merge pull request #23 from rcpch/mbarton/remove-double-postcode-vali…
mbarton Jul 9, 2024
5cb7fa2
Incorrect postcode "SW11AA" for endpoint example
anchit-chandran Feb 19, 2025
a914c73
Update live_rcpch-census-engine.yml
anchit-chandran Feb 19, 2025
7dfd4ff
Merge pull request #25 from rcpch/artefacts-version-bump-cicd
anchit-chandran Feb 20, 2025
1f129bc
gracefully handle invalid postcode
anchit-chandran Feb 20, 2025
a793894
similar graceful error handling
anchit-chandran Feb 20, 2025
bb17e8e
Wrong action version bumped
anchit-chandran Feb 20, 2025
d01d3fc
refactor to use new postcodes interface
anchit-chandran Feb 20, 2025
5570a47
don't want to leave in unused functions
anchit-chandran Feb 20, 2025
1af855d
add population density and model
eatyourpeas Apr 30, 2025
4c249bd
typos to model and tidy dockerisation
eatyourpeas Apr 30, 2025
8194b90
seed function for population density
eatyourpeas Apr 30, 2025
bcc2f75
working swagger, where's the data?
eatyourpeas Apr 30, 2025
5b114de
fix seed and fix model
eatyourpeas Apr 30, 2025
374e65f
serializer refactor nest lsoa and local authority
eatyourpeas May 3, 2025
e1c7cbe
loads better, population density still not right
eatyourpeas May 3, 2025
0a2ee6a
complete seeding with correct totals, add totals checker in manage.py
eatyourpeas May 4, 2025
ba2a4dd
remove comments
eatyourpeas May 4, 2025
aad3e01
Merge pull request #29 from rcpch:population-densities
eatyourpeas May 4, 2025
40a14f9
adds rcpch postcodes io
eatyourpeas May 4, 2025
b936aa8
Merge pull request #27 from rcpch/anchit/bug-fix-lsoa-doesnt-exist
mbarton Jun 17, 2025
bb8993b
Merge branch 'live' into postcodes-swagger
mbarton Jun 17, 2025
94613de
Put back API key I removed in the merge
mbarton Jun 17, 2025
f54882e
Too much https
mbarton Jun 17, 2025
c43438f
Merge pull request #30 from rcpch/postcodes-swagger
mbarton Jun 17, 2025
d3bb2bd
Add prout
mbarton Sep 10, 2025
651a43e
Merge pull request #31 from rcpch/mbarton/prout
mbarton Sep 10, 2025
46cc9b4
Update README.md
mbarton Sep 10, 2025
bc57e22
Merge pull request #32 from rcpch/mbarton-patch-1
mbarton Sep 10, 2025
cfffe09
Update README.md
mbarton Sep 10, 2025
f6f29e5
Merge pull request #33 from rcpch/mbarton-patch-2
mbarton Sep 10, 2025
8acf5bf
2025 England IMD and 2021 LSOAs, 2024 LADs now in.
eatyourpeas Dec 9, 2025
f3b8aa2
totals now complete with documentation to readme
eatyourpeas Dec 9, 2025
fb4675b
remove progress bar and tqdm as does not work in docker compose adequ…
eatyourpeas Dec 9, 2025
d5326c3
guards to skip when data already seeded
eatyourpeas Dec 9, 2025
680429a
refactor imd endpoints to accept year - untested
eatyourpeas Dec 9, 2025
9382eb6
implement pytest properly, update api to accept year as optional para…
eatyourpeas Dec 9, 2025
66662bd
31 English tests ✅
eatyourpeas Dec 9, 2025
529cf03
creates a new script to scrape the northern ireland nisra site with 1…
eatyourpeas Dec 9, 2025
b21e1eb
sets up mocking of postcodes io responses, adds testing to the ci wit…
eatyourpeas Dec 9, 2025
9ac30a1
fix: filter empty strings from CSRF_TRUSTED_ORIGINS for Django 4.0+ c…
eatyourpeas Dec 9, 2025
f9b36ae
fix: install development requirements in CI for pytest
eatyourpeas Dec 9, 2025
0a027d6
updates lsoa_for_postcode to return 2021 lsoas vs 2011 lsoas dependin…
eatyourpeas Dec 21, 2025
5ecfd3f
adds year to English IMD serializer response. Clarifies lsoa_for_post…
eatyourpeas Dec 21, 2025
7fa0838
lsoa retrieve accepts lsoa_code and year optionally
eatyourpeas Dec 21, 2025
cb10f2f
refactor: update LSOA serializer to use ModelSerializer and enhance L…
eatyourpeas Dec 21, 2025
165dce0
feat: add GreenSpace filter and viewset to handle green space data fo…
eatyourpeas Dec 21, 2025
6f27b22
remove retrieve for local authorities, can only list against year, ca…
eatyourpeas Dec 21, 2025
46b87c1
refactor: update NorthernIrelandIndexMultipleDeprivationSerializer an…
eatyourpeas Dec 21, 2025
210ebfe
feat: update SOAViewSet to require either soa_code or soa_name for re…
eatyourpeas Dec 21, 2025
409e027
refactor: remove DataZoneFilter and update DataZoneViewSet to enforce…
eatyourpeas Dec 21, 2025
a57378e
feat: enhance ScottishMultipleDeprivationViewSet to support retrieval…
eatyourpeas Dec 21, 2025
9a15990
feat: update PopulationDensityViewSet to filter by LSOA year and enha…
eatyourpeas Dec 21, 2025
5a10032
feat: update WelshMultipleDeprivationViewSet to enhance retrieval log…
eatyourpeas Dec 21, 2025
a286cf4
feat: enhance get_mock_postcode_response to support year-specific LSO…
eatyourpeas Dec 21, 2025
4e1196d
change mocking flag default to true. update documentation
eatyourpeas Dec 21, 2025
70cbf2f
adds test for postcode with two lsoas
eatyourpeas Dec 21, 2025
295419e
mocked data
eatyourpeas Dec 21, 2025
3b7a600
Merge pull request #35 from rcpch:2025-imd
eatyourpeas Dec 21, 2025
dbb0327
fix: update lookup fields in viewsets to use related fields and impro…
eatyourpeas Dec 21, 2025
8ef1d9a
addd logging
eatyourpeas Dec 21, 2025
d2d6d6c
Merge pull request #37 from rcpch:schema
eatyourpeas Dec 21, 2025
f7d806b
functioning postgis, add geojson files
eatyourpeas Dec 22, 2025
bf1eda0
seeds all the boundary files for LSOA and LAD
eatyourpeas Dec 22, 2025
0a5763b
add lad test
eatyourpeas Dec 22, 2025
aee067c
[feat] adds pg_tileserv container seeds data from ons
eatyourpeas Dec 25, 2025
7f8f317
Remove geojson and shape_files from repo; keep local copies; add to .…
eatyourpeas Dec 25, 2025
325cbab
rename soa2011_optimised
eatyourpeas Dec 25, 2025
55a31f2
download the ni soas using wget to save storing in the repository
eatyourpeas Dec 25, 2025
7616112
further seed optimization for tiles
eatyourpeas Dec 25, 2025
eb6bde9
adds a drf endpoint to serve maps to cdn, adds purge function to purg…
eatyourpeas Dec 25, 2025
788161b
adds a warm cache
eatyourpeas Dec 25, 2025
23879d7
fix tests, add deploy docs
eatyourpeas Dec 25, 2025
84a1a4d
Merge branch 'live' into shapes
eatyourpeas Dec 25, 2025
dd88781
convert to postgis for tests
eatyourpeas Dec 25, 2025
cd457ff
remove rf triggering permission denied
eatyourpeas Dec 25, 2025
cdefa94
syntax fix
eatyourpeas Dec 25, 2025
d7df0b2
oops - duplicate lines in last merge conflict fix
eatyourpeas Dec 25, 2025
f367e9f
remove duplicate routes, also from merge conflict
eatyourpeas Dec 25, 2025
f0d4ccc
remove old postgres references
eatyourpeas Dec 25, 2025
265026c
runner used 3.12 bookworm which has higher version of gdal
eatyourpeas Dec 25, 2025
8f3327e
downgrade gdal just for test runner
eatyourpeas Dec 25, 2025
a31832b
fix requirements and gdal deps
eatyourpeas Dec 25, 2025
7907ed9
adds a github pages workflow
eatyourpeas Dec 25, 2025
153e17a
initial issue with missing lsoas at 0_4 zoom led to replacing uk wide…
eatyourpeas Dec 26, 2025
5fe021b
adds deployment documentation
eatyourpeas Dec 27, 2025
57c0997
Serve tiles via pg_tileserv; add ACA deploy + Pages
eatyourpeas Dec 31, 2025
4e04378
remove drf map endpoint
eatyourpeas Jan 3, 2026
65f1918
Bump CPU size to fit Azure limits
mbarton Jan 6, 2026
085f60f
update shapes action
eatyourpeas Jan 6, 2026
b8c0d53
remove nginx in production, do not runserver in production
eatyourpeas Jan 6, 2026
831f16b
oops total memory does not add up now that nginx has been removed
eatyourpeas Jan 6, 2026
1528320
adds pgdata path to db container
eatyourpeas Jan 6, 2026
abaaae1
add subdirectory to pgdata to overcome chmod issue
eatyourpeas Jan 6, 2026
3fdf9c2
bypassing chmod...
eatyourpeas Jan 6, 2026
cc330c7
creates a workflow to deploy a seeded postgis database to ghcr on cre…
eatyourpeas Jan 7, 2026
9a35629
adds a new dockerfile for the db publication and updates the action t…
eatyourpeas Jan 7, 2026
72f57a3
refactor dockerfile into the action - cleaner
eatyourpeas Jan 7, 2026
5ff072d
remove the docker build left in error
eatyourpeas Jan 7, 2026
1ee106a
fixes the broken chaining in the the python seeding calls
eatyourpeas Jan 7, 2026
71d2c30
fix port connections and add logging
eatyourpeas Jan 7, 2026
819a18a
migrate the tables before seeding Simon
eatyourpeas Jan 7, 2026
46d3eff
wrong second seed command. we are nearly there
eatyourpeas Jan 7, 2026
7489bbc
finally fixes seed not to oversimplify scottish data zones
eatyourpeas Jan 8, 2026
7ed8349
remove the cdn purge step for the moment
eatyourpeas Jan 8, 2026
28b778f
batch load LADs 2024
eatyourpeas Jan 9, 2026
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
109 changes: 109 additions & 0 deletions .github/workflows/deploy_containerapps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Deploy to Azure Container Apps (shapes)

on:
push:
branches:
- live
workflow_dispatch:

permissions:
contents: read
id-token: write

concurrency:
group: deploy-aca-shapes
cancel-in-progress: true

env:
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
# Update if your Container App name differs.
AZURE_CONTAINERAPP_NAME: rcpch-census-platform-v2

# ACR resource name (NOT login server). Example: myregistry
# Store as a GitHub Secret (or Variable) named ACR_NAME.
ACR_NAME: ${{ secrets.ACR_NAME }}

# ACR login server. Example: myregistry.azurecr.io
# Store as a GitHub Secret (or Variable) named ACR_LOGIN_SERVER.
ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }}

# Image names
WEB_IMAGE_NAME: rcpch-census-web
PROXY_IMAGE_NAME: rcpch-census-proxy

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Azure login (OIDC)
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Login to ACR (OIDC)
shell: bash
run: |
if [ -z "${ACR_NAME}" ]; then
echo "Missing secrets.ACR_NAME (ACR resource name)." >&2
exit 1
fi
az acr login --name "${ACR_NAME}"

- name: Build and push web image
shell: bash
run: |
docker build -f Dockerfile.postgis -t "${ACR_LOGIN_SERVER}/${WEB_IMAGE_NAME}:${GITHUB_SHA}" .
docker push "${ACR_LOGIN_SERVER}/${WEB_IMAGE_NAME}:${GITHUB_SHA}"

# NOTE: This workflow no longer configures registry username/password on the Container App.
# For runtime pulls from ACR, configure the Container App to use managed identity + AcrPull
# (do once in Azure). This avoids long-lived registry passwords.

- name: Render Container App YAML
shell: bash
env:
ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }}
ENV_STORAGE_NAME: ${{ secrets.ACA_ENV_STORAGE_NAME }}
DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }}
DJANGO_CSRF_TRUSTED_ORIGINS: ${{ secrets.DJANGO_CSRF_TRUSTED_ORIGINS }}
run: |
python - <<'PY'
from pathlib import Path
import os

template_path = Path('infra/azure/containerapp.template.yml')
out_path = Path('infra/azure/containerapp.rendered.yml')

content = template_path.read_text(encoding='utf-8')
replacements = {
'__ACR_LOGIN_SERVER__': os.environ['ACR_LOGIN_SERVER'],
'__IMAGE_TAG__': os.environ['GITHUB_SHA'],
'__ENV_STORAGE_NAME__': os.environ['ENV_STORAGE_NAME'],
'__DJANGO_ALLOWED_HOSTS__': os.environ['DJANGO_ALLOWED_HOSTS'],
'__DJANGO_CSRF_TRUSTED_ORIGINS__': os.environ['DJANGO_CSRF_TRUSTED_ORIGINS'],
}

for k, v in replacements.items():
content = content.replace(k, v)

out_path.write_text(content, encoding='utf-8')
print(f"Wrote {out_path}")
PY

- name: Deploy Container App revision
shell: bash
run: |
az containerapp update \
-n "${AZURE_CONTAINERAPP_NAME}" \
-g "${AZURE_RESOURCE_GROUP}" \
--yaml infra/azure/containerapp.rendered.yml

- name: Show FQDN
shell: bash
run: |
az containerapp show -n "${AZURE_CONTAINERAPP_NAME}" -g "${AZURE_RESOURCE_GROUP}" --query properties.configuration.ingress.fqdn -o tsv
41 changes: 41 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy site/ to GitHub Pages

on:
push:
branches:
- live
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
# Safety: only deploy Pages from the default branch.
if: github.ref == 'refs/heads/live'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Pages
uses: actions/configure-pages@v5

- name: Upload Pages artifact (site/)
uses: actions/upload-pages-artifact@v3
with:
path: site

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
78 changes: 78 additions & 0 deletions .github/workflows/publish_postgisdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Publish Seeded PostGIS DB

on:
release:
types: [published]

permissions:
contents: read
packages: write

env:
IMAGE_NAME: rcpch-census-postgis
REGISTRY: ghcr.io
ORG: rcpch
WEB_IMAGE_NAME: rcpch-census-web

jobs:
build-seed-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build base PostGIS image
run: |
docker pull postgis/postgis:15-3.4
docker tag postgis/postgis:15-3.4 $REGISTRY/$ORG/$IMAGE_NAME:base

- name: Build DRF app image
run: |
docker build -t $REGISTRY/$ORG/$WEB_IMAGE_NAME:seed -f Dockerfile.postgis .

- name: Start PostGIS container
run: |
docker run -d --name seed-db -p 5432:5432 -e POSTGRES_USER=rcpchCensususer -e POSTGRES_PASSWORD=seedpw -e POSTGRES_DB=rcpchCensusdb $REGISTRY/$ORG/$IMAGE_NAME:base

- name: Run Django seed command
env:
# Add any secrets needed for your Django app here
DJANGO_SECRET_KEY: dummy
run: |
set -o pipefail
docker run --rm \
--network host \
-e RCPCH_CENSUS_ENGINE_POSTGRES_DB_USER=rcpchCensususer \
-e RCPCH_CENSUS_ENGINE_POSTGRES_DB_PASSWORD=seedpw \
-e RCPCH_CENSUS_ENGINE_POSTGRES_DB_NAME=rcpchCensusdb \
-e RCPCH_CENSUS_ENGINE_POSTGRES_DB_HOST=127.0.0.1 \
-e RCPCH_CENSUS_ENGINE_POSTGRES_DB_PORT=5432 \
-e DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY \
-e PYTHONUNBUFFERED=1 \
$REGISTRY/$ORG/$WEB_IMAGE_NAME:seed \
sh -c "/app/s/wait-for-db.sh && python -u manage.py migrate --noinput && python -u manage.py seed --mode=__all__ && python -u manage.py seed --mode=import_bfc_boundaries" | tee seed-run.log

- name: Upload seed run logs
uses: actions/upload-artifact@v4
with:
name: seed-run-log
path: seed-run.log

- name: Commit seeded image
run: |
docker commit seed-db $REGISTRY/$ORG/$IMAGE_NAME:${{ github.ref_name }}

- name: Push seeded image to GHCR
run: |
docker push $REGISTRY/$ORG/$IMAGE_NAME:${{ github.ref_name }}

- name: Cleanup
if: always()
run: |
docker rm -f seed-db || true
docker rmi $REGISTRY/$ORG/$IMAGE_NAME:base || true
docker rmi $REGISTRY/$ORG/$WEB_IMAGE_NAME:seed || true
76 changes: 33 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Runs tests on Pull Requests
# Requires seeding the database with IMD data before running tests

name: Run Tests

on:
pull_request:
branches:
- live
- development
branches: [live, development]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
# This tells GitHub to run all 'steps' inside this container
container:
image: python:3.12-bookworm

services:
postgres:
image: postgres:latest
postgis:
image: postgis/postgis:15-3.4
env:
POSTGRES_USER: rcpchCensususer
POSTGRES_PASSWORD: password
Expand All @@ -29,56 +27,48 @@ jobs:
--health-timeout 5s
--health-retries 5

# Define global env for all steps
env:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other projects I've made this step a simple copy of the env template in the hope it helps us remember to keep the template up to date

RCPCH_CENSUS_ENGINE_POSTGRES_DB_USER: rcpchCensususer
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PASSWORD: password
RCPCH_CENSUS_ENGINE_POSTGRES_DB_NAME: rcpchCensusdb
RCPCH_CENSUS_ENGINE_POSTGRES_DB_HOST: postgis # Connect to service name
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PORT: 5432
RCPCH_CENSUS_ENGINE_SECRET_KEY: test-secret-key
DEBUG: "True"
DJANGO_ALLOWED_HOSTS: localhost
POSTCODES_IO_API_URL: https://api.postcodes.io

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install system packages
run: |
apt-get update && apt-get install -y --no-install-recommends \
gdal-bin libgdal-dev libgeos-dev binutils libproj-dev postgresql-client

- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Force Python GDAL bindings to match the system version
export GDAL_VERSION=$(gdal-config --version)
pip install "GDAL==$GDAL_VERSION.*"

pip install -r requirements.txt
pip install -r requirements/development-requirements.txt

- name: Enable PostGIS extension
run: |
export PGPASSWORD=password
for i in {1..15}; do
psql -h postgis -U rcpchCensususer -d rcpchCensusdb -c "CREATE EXTENSION IF NOT EXISTS postgis;" && break || sleep 2
done

- name: Run migrations
env:
RCPCH_CENSUS_ENGINE_POSTGRES_DB_USER: rcpchCensususer
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PASSWORD: password
RCPCH_CENSUS_ENGINE_POSTGRES_DB_NAME: rcpchCensusdb
RCPCH_CENSUS_ENGINE_POSTGRES_DB_HOST: localhost
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PORT: 5432
RCPCH_CENSUS_ENGINE_SECRET_KEY: test-secret-key
DEBUG: "True"
DJANGO_ALLOWED_HOSTS: localhost
POSTCODES_IO_API_URL: https://api.postcodes.io
run: python manage.py migrate

- name: Seed database
env:
RCPCH_CENSUS_ENGINE_POSTGRES_DB_USER: rcpchCensususer
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PASSWORD: password
RCPCH_CENSUS_ENGINE_POSTGRES_DB_NAME: rcpchCensusdb
RCPCH_CENSUS_ENGINE_POSTGRES_DB_HOST: localhost
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PORT: 5432
RCPCH_CENSUS_ENGINE_SECRET_KEY: test-secret-key
DEBUG: "True"
DJANGO_ALLOWED_HOSTS: localhost
POSTCODES_IO_API_URL: https://api.postcodes.io
run: python manage.py seed --mode='ci_test'

- name: Run tests
env:
RCPCH_CENSUS_ENGINE_POSTGRES_DB_USER: rcpchCensususer
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PASSWORD: password
RCPCH_CENSUS_ENGINE_POSTGRES_DB_NAME: rcpchCensusdb
RCPCH_CENSUS_ENGINE_POSTGRES_DB_HOST: localhost
RCPCH_CENSUS_ENGINE_POSTGRES_DB_PORT: 5432
RCPCH_CENSUS_ENGINE_SECRET_KEY: test-secret-key
DEBUG: "True"
DJANGO_ALLOWED_HOSTS: localhost
POSTCODES_IO_API_URL: https://api.postcodes.io
run: python -m pytest tests/ -v --tb=short
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ staticfiles/
.vscode/
.vscode/*

# Docker and docker compose
.pip_cache
.data
# Docker and docker compose
.pip_cache
.data

build_info.json
build_info.json
# Ignore large generated/staging geojson and shapefiles
deprivation_scores/geojson/
deprivation_scores/shape_files/
27 changes: 0 additions & 27 deletions Dockerfile

This file was deleted.

Loading