Skip to content

Commit

Permalink
Merge pull request #462 from jazzband/gha
Browse files Browse the repository at this point in the history
Migrate to GitHub Actions
  • Loading branch information
jezdez authored Nov 29, 2020
2 parents 775ac3f + 382110f commit 1b3ebb7
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 89 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-model-utils'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
- name: Build package
run: |
python setup.py --version
python setup.py sdist --format=gztar bdist_wheel
twine check dist/*
- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: jazzband
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
repository_url: https://jazzband.co/projects/django-model-utils/upload
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']

services:
postgres:
image: postgres:10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
- name: Tox tests
run: |
tox -v -- --cov --cov-append --cov-report term-missing --cov-report xml
env:
DB_NAME: postgres
DB_USER: postgres
DB_PASSWORD: postgres
DB_HOST: localhost
DB_PORT: 5432

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ docs/_build/
.idea/
.eggs/
.venv/
coverage.xml
7 changes: 0 additions & 7 deletions .hgignore

This file was deleted.

6 changes: 0 additions & 6 deletions .hgtags

This file was deleted.

36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CHANGES
update_fieldsparameter when 'status' is present in it to make sure it is not
forgotten.
- Update test requirements
- Move tests to GitHub Actions: https://github.com/jazzband/django-model-utils/actions

4.0.0 (2019-12-11)
------------------
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ django-model-utils
.. image:: https://jazzband.co/static/img/badge.svg
:target: https://jazzband.co/
:alt: Jazzband
.. image:: https://travis-ci.org/jazzband/django-model-utils.svg?branch=master
:target: https://travis-ci.org/jazzband/django-model-utils
.. image:: https://github.com/jazzband/django-model-utils/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-model-utils/actions
.. image:: https://codecov.io/gh/jazzband/django-model-utils/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jazzband/django-model-utils
.. image:: https://img.shields.io/pypi/v/django-model-utils.svg
Expand Down
16 changes: 5 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import os
from pkg_resources import get_distribution

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -44,20 +45,13 @@

parent_dir = os.path.dirname(os.path.dirname(__file__))

def get_version():
with open(os.path.join(parent_dir, 'model_utils', '__init__.py')) as f:
for line in f:
if line.startswith('__version__ ='):
return line.split('=')[1].strip().strip('"\'')

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = get_version()
# The short X.Y version.
version = release
release = get_distribution('django-model-utils').version
# for example take major/minor
version = '.'.join(release.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 7 additions & 1 deletion model_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from pkg_resources import get_distribution, DistributionNotFound

from .choices import Choices # noqa:F401
from .tracker import FieldTracker, ModelTracker # noqa:F401

__version__ = '4.0.1'
try:
__version__ = get_distribution("django-model-utils").version
except DistributionNotFound: # pragma: no cover
# package is not installed
__version__ = None
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ def long_desc(root_path):
long_description = "\n\n".join(long_desc(HERE))


def get_version(root_path):
with open(os.path.join(root_path, 'model_utils', '__init__.py')) as f:
for line in f:
if line.startswith('__version__ ='):
return line.split('=')[1].strip().strip('"\'')


setup(
name='django-model-utils',
version=get_version(HERE),
use_scm_version={"version_scheme": "post-release"},
setup_requires=["setuptools_scm"],
license="BSD",
description='Django model mixins and utilities',
long_description=long_description,
long_description_content_type='text/x-rst',
author='Carl Meyer',
author_email='[email protected]',
maintainer='JazzBand',
url='https://github.com/jazzband/django-model-utils/',
url='https://github.com/jazzband/django-model-utils',
packages=find_packages(exclude=['tests*']),
install_requires=['Django>=2.0.1'],
classifiers=[
Expand Down
9 changes: 5 additions & 4 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.environ.get("DJANGO_DATABASE_NAME_POSTGRES", "modelutils"),
"USER": os.environ.get("DJANGO_DATABASE_USER_POSTGRES", 'postgres'),
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_POSTGRES", ""),
"HOST": os.environ.get("DJANGO_DATABASE_HOST_POSTGRES", ""),
"NAME": os.environ.get("DB_NAME", "modelutils"),
"USER": os.environ.get("DB_USER", 'postgres'),
"PASSWORD": os.environ.get("DB_PASSWORD", ""),
"HOST": os.environ.get("DB_HOST", ""),
"PORT": os.environ.get("DB_PORT", 5432)
},
}
SECRET_KEY = 'dummy'
Expand Down
25 changes: 12 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
[tox]
envlist =
py{36,37,38,39}-django{22,30,31,master}
py{36,37,38,39}-dj{22,30,31,master}
flake8

[travis]
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.8: py38, flake8
3.9: py39

[testenv]
deps =
freezegun==0.3.12
-rrequirements-test.txt
django22: Django==2.2.*
django30: Django==3.0.*
django31: Django==3.1.*
djangomaster: https://github.com/django/django/archive/master.tar.gz
dj22: Django==2.2.*
dj30: Django==3.0.*
dj31: Django==3.1.*
djmaster: https://github.com/django/django/archive/master.tar.gz
ignore_outcome =
djangotrunk: True
djmaster: True
passenv =
CI
TRAVIS
TRAVIS_*

GITHUB_*
DB_*
usedevelop = True
commands =
pip install -e .
pytest {posargs}

[testenv:py{36,37,38,39}-djangomaster]
[testenv:py{36,37,38,39}-djmaster]
ignore_errors = True

[testenv:flake8]
Expand Down

0 comments on commit 1b3ebb7

Please sign in to comment.