diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..739c41e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,89 @@ +name: Building and Testing + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: 'ubuntu-latest' + strategy: + matrix: + python_version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + django_version: + - '4.0' + - '4.1' + - '4.2' + + services: + postgres: + # https://github.com/postgis/docker-postgis/blob/master/15-3.4/alpine/Dockerfile + image: postgis/postgis:15-3.4-alpine + env: + POSTGRES_DB: ddf + POSTGRES_USER: ddf_user + POSTGRES_PASSWORD: ddf_pass + ports: + # Random free port + - 5432/tcp + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: 'Install OS dependencies (Ubuntu)' + if: runner.os == 'Linux' + run: | + # https://docs.djangoproject.com/en/4.2/ref/contrib/gis/install/geolibs/ + # GDAL_LIBRARY_PATH: /usr/lib/libgdal.so.* + # GEOS_LIBRARY_PATH: /usr/lib/libgeos_c.so.* + # ln -s /usr/lib/libgdal.so.32 /usr/lib/libgdal.so \ + # ln -s /usr/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so + # ln -s /usr/lib/libproj.so.25 /usr/lib/libproj.so \ + sudo apt-get update \ + && sudo apt-get install -y binutils libproj-dev gdal-bin + + - name: 'Set up Python ${{ matrix.python_version }}' + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python_version }} + + - name: 'Checkout DDF code' + uses: actions/checkout@v3 + + - name: 'Install Python dependencies' + run: | + pip install -r requirements.txt + pip install -r requirements-dev.txt + pip install pytest-django + pip install django~=${{ matrix.django_version }} + pip install jsonfield==3.1.0 + pip install django-polymorphic==3.1.0 + + - name: 'Testing with SQLite' + run: pytest --create-db --reuse-db --no-migrations --ds=settings_sqlite --maxfail=2 + + - name: 'Coverage with SQLite' + run: pytest --create-db --reuse-db --no-migrations -v --cov=django_dynamic_fixture + + - name: 'Testing with Postgres' + env: + POSTGRES_HOST: localhost + POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} + POSTGRES_DB: ddf + POSTGRES_USER: ddf_user + POSTGRES_PASSWORD: ddf_pass + run: | + pip install psycopg2 + pytest --create-db --reuse-db --no-migrations --ds=settings_postgres --maxfail=2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7087e31..0000000 --- a/.travis.yml +++ /dev/null @@ -1,123 +0,0 @@ -dist: bionic -sudo: true - -language: python - -# Avoid Travis run the same build for `push` and `PR` -branches: - only: - - "master" - -services: - - postgresql - -# https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS -addons: - postgresql: "10" - apt: - packages: - - libgdal-dev - - postgresql-10 - - postgresql-10-postgis-2.4 - -matrix: - include: - - python: 3.8 - env: - - DJANGO=4.0 - - DATABASE=sqlite - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.8 - env: - - DJANGO=4.1 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.8 - env: - - DJANGO=4.2 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.9 - env: - - DJANGO=4.0 - - DATABASE=sqlite - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.9 - env: - - DJANGO=4.1 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.9 - env: - - DJANGO=4.2 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.10 - env: - - DJANGO=4.0 - - DATABASE=sqlite - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.10 - env: - - DJANGO=4.1 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.10 - env: - - DJANGO=4.2 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.11 - env: - - DJANGO=4.0 - - DATABASE=sqlite - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.11 - env: - - DJANGO=4.1 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - - python: 3.11 - env: - - DJANGO=4.2 - - DATABASE=postgres - - JSONFIELD=3.1.0 - - POLYMORPHIC=3.0.0 - -before_script: - - export PYTHONPATH=$PYTHONPATH:$(pwd) - # check gis - - gdal-config --version - - gdal-config --cflags - - psql -U postgres -c "create extension postgis" - # set up postgresql - - psql -U postgres -c "create role cacheops login superuser" - # postgis django backend requires these to exist - - psql -U postgres -c "create database cacheops" - - psql -U postgres -c "create database cacheops_slave" - # create db and user - - psql -c "CREATE DATABASE ddf;" -U postgres - - psql -c "CREATE USER ddf_user WITH PASSWORD 'ddf_pass';" -U postgres - - psql -c "ALTER USER ddf_user CREATEDB;" -U postgres - - psql -c "ALTER USER ddf_user WITH SUPERUSER;" -U postgres - -install: - - pip install -r requirements.txt - - pip install psycopg2 pytest pytest-django - - pip install Django~=${DJANGO}.0 - - pip install jsonfield~=${JSONFIELD} - - pip install django-polymorphic~=${POLYMORPHIC} - -script: - - pytest --create-db --reuse-db --no-migrations --ds=settings_${DATABASE} diff --git a/Makefile b/Makefile index 7358ec1..cddb70d 100644 --- a/Makefile +++ b/Makefile @@ -139,3 +139,13 @@ tag: reset_tag: git tag -d ${VERSION} git push origin :refs/tags/${VERSION} + + +# GitHub Action + +act: + #brew install act + time act --container-architecture linux/amd64 --matrix python_version:3.11 --matrix django_version:4.2 + +actall: + time act --container-architecture linux/amd64 diff --git a/README.md b/README.md index 605c5c2..183ea60 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ Django Dynamic Fixture ====================== -[![Build Status](https://travis-ci.org/paulocheque/django-dynamic-fixture.svg?branch=master)](https://travis-ci.org/paulocheque/django-dynamic-fixture) [![Docs Status](https://readthedocs.org/projects/django-dynamic-fixture/badge/?version=latest)](http://django-dynamic-fixture.readthedocs.org/en/latest/index.html) [![PyPI version](https://badge.fury.io/py/django-dynamic-fixture.svg)](https://badge.fury.io/py/django-dynamic-fixture) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-dynamic-fixture) diff --git a/settings_postgres.py b/settings_postgres.py index 2bee2ea..a76671e 100644 --- a/settings_postgres.py +++ b/settings_postgres.py @@ -1,3 +1,4 @@ +import os from settings_ddf import * DDF_TEST_GEODJANGO = True @@ -10,13 +11,13 @@ # Postgis supports all Django features # createdb ddf 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'NAME': 'ddf', - 'USER': 'ddf_user', # please, change this if you want to run tests in your machine - 'PASSWORD': 'ddf_pass', - 'HOST': 'localhost', - 'PORT': 5432, + 'HOST': os.getenv('POSTGRES_HOST', 'localhost'), + 'PORT': os.getenv('POSTGRES_PORT', 5432), + 'NAME': os.getenv('POSTGRES_DB', 'ddf'), + 'USER': os.getenv('POSTGRES_USER', 'ddf_user'), # please, change this if you want to run tests in your machine + 'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'ddf_pass'), } } if DDF_TEST_GEODJANGO: - INSTALLED_APPS += ('django.contrib.gis',) \ No newline at end of file + INSTALLED_APPS += ('django.contrib.gis',)