fix: github actions #65
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: Run project tests | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
pull_request: | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
environment: testing | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
container: | |
image: python:3.12 | |
env: | |
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres | |
CACHE_FILE: /tmp/meep | |
POETRY_VIRTUALENVS_CREATE: "false" | |
MAPIT_URL: https://mapit.mysociety.org/ | |
MAPIT_API_KEY: "not_a_key" | |
TEST_AIRTABLE_BASE_ID: ${{ vars.TEST_AIRTABLE_BASE_ID }} | |
TEST_AIRTABLE_TABLE_NAME: ${{ vars.TEST_AIRTABLE_TABLE_NAME }} | |
TEST_AIRTABLE_API_KEY: ${{ secrets.TEST_AIRTABLE_API_KEY }} | |
SECRET_KEY: keyboardcat | |
steps: | |
- name: Checkout repo content | |
uses: actions/checkout@v2 | |
- 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 | |
- name: Install poetry | |
run: curl -sSL https://install.python-poetry.org | python3 - | |
- name: Install python dependencies | |
run: ~/.local/bin/poetry export --with dev -f requirements.txt --output requirements.txt && pip install -r requirements.txt | |
- name: Start server | |
run: gunicorn local_intelligence_hub.asgi:application -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 & | |
- name: Start ngrok tunnelling | |
run: | | |
ngrok authtoken ${{ secrets.NGROK_AUTHTOKEN }} | |
ngrok http 80 --log=stdout > ngrok.log & | |
- name: Extract ngrok URL | |
run: export BASE_URL=$(cat ngrok.log | grep 'url=' | awk -F= '{print $NF}') | |
- name: Run django tests | |
run: | | |
echo "Base URL: $BASE_URL" | |
echo "Airtable Vars: $TEST_AIRTABLE_BASE_ID $TEST_AIRTABLE_TABLE_NAME" | |
script/bootstrap | |
coverage run --source=. --branch manage.py test | |
- name: Generate coverage xml | |
run: coverage xml | |
- name: Upload code coverage | |
run: | | |
less coverage.xml | |
pip install codecov | |
codecov | |