Skip to content

Add test action

Add test action #11

Workflow file for this run

name: Python tests
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
services:
postgis:
image: postgis/postgis:15-3.3
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- '5432:5432'
volumes:
- '/var/run/postgresql:/var/run/postgresql'
strategy:
matrix:
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Install System Dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential git curl
pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install
poetry run pip install tox
- name: Set up database
run: |
psql -c 'CREATE ROLE django SUPERUSER LOGIN CREATEDB;' -U postgres -h localhost
psql -c 'CREATE ROLE travis SUPERUSER LOGIN CREATEDB;' -U postgres -h localhost
psql -c 'CREATE DATABASE test_pg_database;' -U postgres -h localhost
psql -c 'CREATE EXTENSION postgis;' -U postgres -d test_pg_database -h localhost
psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d test_pg_database -h localhost
- name: Run Tests
run: |
TOXENV=django poetry run tox
TOXENV=nodjango poetry run tox