Workflow file for this run
This file contains 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
name: Django startup check | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
jobs: | |
django_startup_check: | |
runs-on: ubuntu-latest | |
environment: testing | |
services: | |
db: | |
image: kartoza/postgis:13 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: postgres | |
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@db:5432/postgres | |
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 }} | |
SKIP_AIRTABLE_TESTS: "True" | |
TEST_ACTIONNETWORK_MEMBERLIST_API_KEY: ${{ secrets.TEST_ACTIONNETWORK_MEMBERLIST_API_KEY }} | |
TEST_GOOGLE_SHEETS_CREDENTIALS: ${{ secrets.TEST_GOOGLE_SHEETS_CREDENTIALS }} | |
TEST_GOOGLE_SHEETS_SPREADSHEET_ID: ${{ secrets.TEST_GOOGLE_SHEETS_SPREADSHEET_ID }} | |
TEST_GOOGLE_SHEETS_SHEET_NAME: ${{ secrets.TEST_GOOGLE_SHEETS_SHEET_NAME }} | |
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 | |
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} | |
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} | |
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 postgresql-client | |
- name: Generate requirements.txt from pyproject.toml | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
~/.local/bin/poetry self add poetry-plugin-export | |
~/.local/bin/poetry export --with dev --without-hashes -f requirements.txt --output requirements.txt | |
- name: Cache python packages | |
id: cache-venv | |
uses: actions/cache@v4 | |
with: | |
path: ./.venv/ | |
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-venv- | |
- name: Install python dependencies if not cached | |
if: steps.cache-venv.outputs.cache-hit != 'true' | |
run: python -m venv ./.venv && . ./.venv/bin/activate && pip install -r requirements.txt | |
- name: Initialize database | |
run: . ./.venv/bin/activate && python manage.py migrate | |
- name: Initialize cache | |
run: . ./.venv/bin/activate && python manage.py createcachetable | |
- name: Start server | |
run: . ./.venv/bin/activate && gunicorn local_intelligence_hub.asgi:application -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 > server.log 2>&1 & |