Merge pull request #462 from jazzband/gha

Migrate to GitHub Actions
This commit is contained in:
Jannis Leidel 2020-11-29 15:37:15 +01:00 committed by GitHub
commit 1b3ebb7fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 146 additions and 89 deletions

40
.github/workflows/release.yml vendored Normal file
View file

@ -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
.github/workflows/test.yml vendored Normal file
View file

@ -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
.gitignore vendored
View file

@ -10,3 +10,4 @@ docs/_build/
.idea/
.eggs/
.venv/
coverage.xml

View file

@ -1,7 +0,0 @@
^dist/
^django_model_utils\.egg-info/
^HGREV$
^\.coverage$
^\.tox/
^Django.*\.egg$
^htmlcov/

View file

@ -1,6 +0,0 @@
b5efc435bb7e21b0d7ba422d28d174ccca3b3322 0.2.0
71b54b8b44fa2456beebd51c474ba55ad625486a 0.3.1
1e6f730f8c3a648c9fb70844a68fcfa663608600 0.4.0
004dbee634cb661c52acac034063989e521c4bb8 0.5.0
bd164041e5fabd64de19c38fefe9af9237a2a59e 1.0.0
92792fb14a51b580e5cc8991e815f3b3b57a6204 1.1.0

View file

@ -1,36 +0,0 @@
version: ~> 1.0
dist: bionic
os: linux
language: python
cache: pip
python:
- 3.6
- 3.7
- 3.8
- 3.9
arch:
- amd64
- ppc64le
jobs:
include:
- python: 3.8
env: TOXENV=flake8
install: pip install tox-travis codecov
# positional args ({posargs}) to pass into tox.ini
script: tox -- --cov --cov-append
addons:
postgresql: '10'
services:
- postgresql
after_success: codecov
deploy:
provider: pypi
username: jazzband
server: https://jazzband.co/projects/django-model-utils/upload
distributions: sdist bdist_wheel
password:
secure: JxUmEdYS8qT+7xhVyzmVD4Gkwqdz5XKxoUhKP795CWIXoJjtlGszyo6w0XfnFs0epXtd1NuCRXdhea+EqWKFDlQ3Yg7m6Y/yTQV6nMHxCPSvicROho7pAiJmfc/x+rSsPt5ag8av6+S07tOqvMnWBBefYbpHRoel78RXkm9l7Mc=
on:
tags: true
repo: jazzband/django-model-utils
python: 3.6

View file

@ -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)
------------------

View file

@ -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

View file

@ -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
@ -44,20 +45,13 @@ copyright = '2015, Carl Meyer'
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.

View file

@ -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

View file

@ -15,23 +15,18 @@ HERE = os.path.abspath(os.path.dirname(__file__))
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='carl@oddbird.net',
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=[

View file

@ -7,10 +7,11 @@ INSTALLED_APPS = (
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'

25
tox.ini
View file

@ -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]