diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..add7354 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI +on: [push, pull_request] +jobs: + build: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] + django-version: ['Django>=3.2,<4', 'Django>=4.2,<5'] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: setup.cfg + - run: pip install .[test] '${{ matrix.django-version }}' psycopg2-binary + - env: + PORT: ${{ job.services.postgres.ports[5432] }} + run: django-admin migrate --settings settings --noinput + - env: + PORT: ${{ job.services.postgres.ports[5432] }} + run: coverage run --source=boundaries runtests.py + - env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: coveralls --service=github + services: + postgres: + image: postgis/postgis:15-3.4 + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432/tcp diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9ae6862..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -sudo: false -language: python -cache: pip -python: - # https://devguide.python.org/#branchstatus - - "3.5" - - "3.6" - - "3.7" - - "3.8" -env: - # https://www.djangoproject.com/download/ - - DJANGO="Django>=1.11,<1.12" - - DJANGO="Django>=2.0,<2.1" - - DJANGO="Django>=2.1,<2.2" - - DJANGO="Django>=2.2,<2.3" - # - DJANGO="Django>=3.0,<3.1" -addons: - postgresql: "9.6" - apt: - packages: - - postgresql-9.6-postgis-2.4 -install: - - pip install $DJANGO - - pip install psycopg2 - - pip install -e .[test] - - pip install coveralls -before_script: - - createdb -U postgres template_postgis - - psql -c 'CREATE EXTENSION postgis' -U postgres template_postgis - - createdb -U postgres travis_ci_test - - psql -c 'CREATE EXTENSION postgis' -U postgres travis_ci_test - - django-admin.py migrate --settings settings --noinput -script: - - coverage run --source=boundaries runtests.py -after_success: - coveralls diff --git a/runtests.py b/runtests.py index f8ef825..2e665c4 100644 --- a/runtests.py +++ b/runtests.py @@ -9,8 +9,10 @@ DATABASES={ 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'NAME': 'travis_ci_test', + 'NAME': 'postgres' if os.getenv('CI', False) else 'represent_boundaries_test', 'USER': 'postgres' if os.getenv('CI', False) else '', + 'PASSWORD': 'postgres' if os.getenv('CI', False) else '', + 'PORT': os.getenv('PORT', 5432), } }, ROOT_URLCONF='boundaries.urls', diff --git a/settings.py b/settings.py index 957b457..2e7ce14 100644 --- a/settings.py +++ b/settings.py @@ -7,7 +7,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'NAME': 'travis_ci_test', + 'NAME': 'represent_boundaries', } } diff --git a/setup.cfg b/setup.cfg index cdd8836..f39fb63 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,6 +24,7 @@ exclude = boundaries.tests [options.extras_require] test = + coveralls testfixtures [isort]