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