Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial GitHub Actions workflow. #283

Merged
merged 15 commits into from
Nov 26, 2020
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-auditlog'
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: 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: release-${{ hashFiles('**/setup.py') }}
restore-keys: |
release-

- 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-auditlog/upload
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
jezdez marked this conversation as resolved.
Show resolved Hide resolved
max-parallel: 5
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
jezdez marked this conversation as resolved.
Show resolved Hide resolved

services:
postgres:
image: postgres:10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432/tcp
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') }}
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
env:
TEST_DB_HOST: localhost
TEST_DB_USER: postgres
TEST_DB_PASS: postgres
TEST_DB_NAME: postgres
TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }}

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ django-auditlog
===============

[![Jazzband](https://jazzband.co/static/img/badge.svg)](https://jazzband.co/)
[![Build Status](https://travis-ci.org/jazzband/django-auditlog.svg?branch=master)](https://travis-ci.org/jazzband/django-auditlog)
[![Build Status](https://github.com/jazzband/django-auditlog/workflows/Test/badge.svg)](https://github.com/jazzband/django-auditlog/actions)
[![Docs](https://readthedocs.org/projects/django-auditlog/badge/?version=latest)](http://django-auditlog.readthedocs.org/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/jazzband/django-auditlog/branch/master/graph/badge.svg?token=OxtQX5baia)](https://codecov.io/gh/jazzband/django-auditlog)
jezdez marked this conversation as resolved.
Show resolved Hide resolved

**Please remember that this app is still in development.**
**Test this app before deploying it in production environments.**
Expand Down
11 changes: 8 additions & 3 deletions auditlog_tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import django
import json
from django.conf import settings
from django.contrib import auth
from django.contrib.auth.models import User, AnonymousUser
Expand Down Expand Up @@ -257,9 +258,13 @@ def test_model_with_additional_data(self):
self.assertTrue(obj_with_additional_data.history.count() == 1,
msg="There is 1 log entry")
log_entry = obj_with_additional_data.history.get()
self.assertIsNotNone(log_entry.additional_data)
extra_data = log_entry.additional_data
print(type(extra_data), extra_data)
# FIXME: Work-around for the fact that additional_data isn't working
# on Djang 3.1 correct (see https://github.com/jazzband/django-auditlog/issues/266)
jezdez marked this conversation as resolved.
Show resolved Hide resolved
if django.VERSION >= (3, 1):
extra_data = json.loads(log_entry.additional_data)
else:
extra_data = log_entry.additional_data
self.assertIsNotNone(extra_data)
self.assertTrue(extra_data['related_model_text'] == related_model.text,
msg="Related model's text is logged")
self.assertTrue(extra_data['related_model_id'] == related_model.id,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The repository can be found at https://github.com/jazzband/django-auditlog/.
- Django 2.2 or higher

Auditlog is currently tested with Python 3.5 - 3.8 and Django 2.2, 3.0 and 3.1. The latest test report can be found
at https://travis-ci.com/jazzband/django-auditlog.
at https://github.com/jazzband/django-auditlog/actions.

Adding Auditlog to your Django application
------------------------------------------
Expand Down
13 changes: 10 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ envlist =
py38-docs

[testenv]
commands = coverage run --source auditlog runtests.py
commands =
coverage run --source auditlog runtests.py
coverage xml
deps =
django-22: Django>=2.2,<2.3
django-30: Django>=3.0,<3.1
# Test requirements
coverage
codecov
psycopg2-binary
passenv=
TEST_DB_HOST
TEST_DB_USER
TEST_DB_PASS
TEST_DB_NAME
TEST_DB_PORT

basepython =
py38: python3.8
Expand All @@ -26,9 +34,8 @@ changedir = docs/source
deps = -rdocs/requirements.txt
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[travis]
[gh-actions]
python =
2.7: py27
3.5: py35
3.6: py36
3.7: py37
Expand Down