Skip to content

Spicy version of the Map UI optimisaiton #426

Spicy version of the Map UI optimisaiton

Spicy version of the Map UI optimisaiton #426

Workflow file for this run

name: Run project tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
environment: testing
services:
postgres:
image: kartoza/postgis:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: local-intelligence
POSTGRES_PORT: 5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
container:
# TODO: Revert to 3.12 once this issue is fixed (for us the error is in pyairtable):
# https://stackoverflow.com/questions/78593700/langchain-community-langchain-packages-giving-error-missing-1-required-keywor
image: python:3.12.3
env:
DATABASE_URL: postgis://postgres:password@postgres:5432/local-intelligence
CACHE_FILE: /tmp/meep
POETRY_VIRTUALENVS_CREATE: "false"
GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
MAPIT_URL: https://mapit.mysociety.org/
MAPIT_API_KEY: "not_a_key"
ELECTORAL_COMMISSION_API_KEY: ${{ secrets.ELECTORAL_COMMISSION_API_KEY }}
ENCRYPTION_SECRET_KEY: ${{ secrets.ENCRYPTION_SECRET_KEY }}
TEST_AIRTABLE_MEMBERLIST_BASE_ID: ${{ secrets.TEST_AIRTABLE_MEMBERLIST_BASE_ID }}
TEST_AIRTABLE_MEMBERLIST_TABLE_NAME: ${{ secrets.TEST_AIRTABLE_MEMBERLIST_TABLE_NAME }}
TEST_AIRTABLE_MEMBERLIST_API_KEY: ${{ secrets.TEST_AIRTABLE_MEMBERLIST_API_KEY }}
TEST_AIRTABLE_CUSTOMDATALAYER_BASE_ID: ${{ secrets.TEST_AIRTABLE_CUSTOMDATALAYER_BASE_ID }}
TEST_AIRTABLE_CUSTOMDATALAYER_TABLE_NAME: ${{ secrets.TEST_AIRTABLE_CUSTOMDATALAYER_TABLE_NAME }}
TEST_AIRTABLE_CUSTOMDATALAYER_API_KEY: ${{ secrets.TEST_AIRTABLE_CUSTOMDATALAYER_API_KEY }}
TEST_ACTIONNETWORK_MEMBERLIST_API_KEY: ${{ secrets.TEST_ACTIONNETWORK_MEMBERLIST_API_KEY }}
TEST_MAILCHIMP_MEMBERLIST_AUDIENCE_ID: ${{ secrets.TEST_MAILCHIMP_MEMBERLIST_AUDIENCE_ID }}
TEST_MAILCHIMP_MEMBERLIST_API_KEY: ${{ secrets.TEST_MAILCHIMP_MEMBERLIST_API_KEY }}
TEST_TICKET_TAILOR_API_KEY: ${{ secrets.TEST_TICKET_TAILOR_API_KEY }}
SECRET_KEY: keyboardcat
steps:
- name: Checkout repo content
uses: actions/checkout@v3
- name: Install linux dependencies
run: |
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | tee /etc/apt/sources.list.d/ngrok.list
apt-get update && apt-get install -y binutils gdal-bin libproj-dev ngrok less
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install python dependencies
run: ~/.local/bin/poetry export --with dev --without-hashes -f requirements.txt --output requirements.txt && pip install -r requirements.txt
- name: Start ngrok tunnelling
run: |
ngrok authtoken ${{ secrets.NGROK_AUTHTOKEN }}
ngrok http 8000 --log=stdout > ngrok.log &
- name: Extract ngrok URL
run: |
BASE_URL=$(cat ngrok.log | grep 'url=' | awk -F= '{print $NF}')
echo "BASE_URL=$BASE_URL" > .env
ALLOWED_HOSTS=$(echo $BASE_URL | sed -e "s/https:\/\///g")
echo "ALLOWED_HOSTS=$ALLOWED_HOSTS" >> .env
- name: Initialize database
run: python manage.py migrate
- name: Initialize cache
run: python manage.py createcachetable
- name: Start server
run: gunicorn local_intelligence_hub.asgi:application -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 > server.log 2>&1 &
- name: Run django tests
run: cat .env && coverage run --source=. --branch manage.py test || (cat server.log && exit 1)
- name: Generate coverage xml
run: coverage xml
- name: Upload coverage.xml
uses: actions/upload-artifact@v4
with:
name: coverage.xml
path: coverage.xml
retention-days: 5