Skip to content

Commit

Permalink
ci: Add test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 10, 2023
1 parent 4205244 commit 4ab03c4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 38 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'travis_ci_test',
'NAME': 'represent_boundaries',
}
}

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exclude = boundaries.tests

[options.extras_require]
test =
coveralls
testfixtures

[isort]
Expand Down

0 comments on commit 4ab03c4

Please sign in to comment.