Skip to content

Commit

Permalink
Merge pull request #45 from opennorth/upgrade
Browse files Browse the repository at this point in the history
Upgrade Python and Django
  • Loading branch information
jpmckinney authored Jun 26, 2024
2 parents c78ef52 + 2823010 commit cb47fa2
Show file tree
Hide file tree
Showing 65 changed files with 698 additions and 478 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
35 changes: 35 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# The pull_request_target workflow trigger is dangerous. Do not add unrelated logic to this workflow.
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
name: Auto-merge
on: pull_request_target
permissions:
pull-requests: write # to approve the PR
contents: write # to merge the PR
jobs:
dependabot:
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- id: dependabot-metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' || steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve ${{ github.event.pull_request.html_url }}
- if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' || steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
precommit:
if: ${{ github.event.pull_request.user.login == 'pre-commit-ci[bot]' }}
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve ${{ github.event.pull_request.html_url }}
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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
# https://docs.djangoproject.com/en/4.2/ref/contrib/gis/install/geolibs/
- run: |
sudo apt update
sudo apt install binutils libproj-dev gdal-bin
- run: pip install .[test] '${{ matrix.django-version }}' psycopg2-binary
- env:
PORT: ${{ job.services.postgres.ports[5432] }}
DJANGO_SETTINGS_MODULE: settings
run: env PYTHONPATH=$PYTHONPATH:$PWD django-admin migrate --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
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint
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
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install --upgrade check-manifest flake8 isort
- run: flake8 .
- run: isort .
- run: check-manifest --ignore-bad-ideas '*.mo'
22 changes: 22 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish to PyPI
on: push
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install --upgrade build
- run: python -m build --sdist --wheel
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
*.egg-info
*_cleaned_*
/build
/dist
/.coverage
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.9.5 (Unreleased)

* Replace n-dashes and m-dashes in boundary set slugs with hyphens.
* Add support for Django 2.2.
* Drop support for Python 2.7 and 3.4.

Expand Down
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
include CHANGELOG.md
recursive-include boundaries/locale *
recursive-include boundaries/static *
recursive-include boundaries/templates *
recursive-include boundaries/tests *.dbf
recursive-include boundaries/tests *.prj
recursive-include boundaries/tests *.py
recursive-include boundaries/tests *.shp
recursive-include boundaries/tests *.shx
recursive-include boundaries/tests *.txt
recursive-include boundaries/tests *.zip
exclude *.py
14 changes: 6 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Represent Boundaries
====================

|PyPI version| |Build Status| |Dependency Status| |Coverage Status|
|PyPI version| |Build Status| |Coverage Status|

Represent Boundaries is a web API to geographic areas, like electoral
districts. It allows you to easily find the areas that cover your users'
Expand Down Expand Up @@ -52,9 +52,9 @@ Testing

::

createdb travis_ci_test
psql travis_ci_test -c 'CREATE EXTENSION postgis;'
django-admin.py migrate --settings settings --noinput
createdb represent_boundaries_test
psql represent_boundaries_test -c 'CREATE EXTENSION postgis;'
env DJANGO_SETTINGS_MODULE=settings django-admin migrate --noinput
python runtests.py

Acknowledgements
Expand All @@ -67,9 +67,7 @@ Released under the MIT license

.. |PyPI version| image:: https://badge.fury.io/py/represent-boundaries.svg
:target: https://badge.fury.io/py/represent-boundaries
.. |Build Status| image:: https://secure.travis-ci.org/opennorth/represent-boundaries.png
:target: https://travis-ci.org/opennorth/represent-boundaries
.. |Dependency Status| image:: https://gemnasium.com/opennorth/represent-boundaries.png
:target: https://gemnasium.com/opennorth/represent-boundaries
.. |Build Status| image:: https://github.com/opennorth/represent-boundaries/actions/workflows/ci.yml/badge.svg
:target: https://github.com/opennorth/represent-boundaries/actions/workflows/ci.yml
.. |Coverage Status| image:: https://coveralls.io/repos/opennorth/represent-boundaries/badge.png?branch=master
:target: https://coveralls.io/r/opennorth/represent-boundaries
18 changes: 7 additions & 11 deletions boundaries/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# coding: utf-8
from __future__ import unicode_literals

import logging
import os
import re
import sys

from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

log = logging.getLogger(__name__)
registry = {}
Expand Down Expand Up @@ -78,15 +75,14 @@ def import_file(path):
# The module object is returned, but this return value is unused by this
# package.

if sys.version_info > (3, 3):
"""
"""
If we're in Python 3, we'll use the PEP 302 import loader.
"""
import importlib.machinery
loader = importlib.machinery.SourceFileLoader(module, path)
obj = loader.load_module()
sys.modules.pop(module)
return obj
import importlib.machinery
loader = importlib.machinery.SourceFileLoader(module, path)
obj = loader.load_module()
sys.modules.pop(module)
return obj

"""
If we're in Python 2, we'll use the `imp` module.
Expand Down
10 changes: 3 additions & 7 deletions boundaries/admin.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin

from boundaries.models import BoundarySet, Boundary
from boundaries.models import Boundary, BoundarySet


@admin.register(BoundarySet)
class BoundarySetAdmin(admin.ModelAdmin):
list_filter = ('authority', 'domain')


admin.site.register(BoundarySet, BoundarySetAdmin)


@admin.register(Boundary)
class BoundaryAdmin(OSMGeoAdmin):
list_display = ('name', 'external_id', 'set')
list_display_links = ('name', 'external_id')
list_filter = ('set',)


admin.site.register(Boundary, BoundaryAdmin)
Loading

0 comments on commit cb47fa2

Please sign in to comment.