Skip to content

Commit

Permalink
version 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed May 19, 2021
2 parents 0817b65 + eeff748 commit e3c58db
Show file tree
Hide file tree
Showing 42 changed files with 582 additions and 235 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Test and deploy

# define when to run the action
on:
- push
- pull_request

env:
GITHUB_WORKFLOW: true

jobs:
test:
name: Test
runs-on: ubuntu-20.04

# test matrix
strategy:
fail-fast: false
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- 3.9
django:
- 2.2
- 3.0
- 3.1
database:
- sqlite
- mysql
- postgres

# additional service containers to run
services:
# postgres service
postgres:
# docker hub image
image: postgres:13-alpine
# configure the instance
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# set health checks to wait until service has started
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=5
# mysql service
mysql:
# docker hub image
image: mysql:8
# configure the instance
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: test
ports:
- 3306:3306
# set health checks to wait until service has started
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
# check out revision to test
- uses: actions/checkout@v2

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

# upgrade pip
- name: Update pip
run: python -m pip install --upgrade pip

# install environment specific dependencies
- name: Install coverage
run: pip install coverage>=5.3
- name: Install Django 2.2
if: matrix.django == 2.2
run: pip install "Django>=2.2,<3.0"
- name: Install Django 3.0
if: matrix.django == 3.0
run: pip install "Django>=3.0,<3.1"
- name: Install Django 3.1
if: matrix.django == 3.1
run: pip install "Django>=3.1,<3.2"
- name: Install MySQL libs
if: matrix.database == 'mysql'
run: pip install mysqlclient>=2.0.1 django-mysql>=3.9.0
- name: Install postgres libs
if: matrix.database == 'postgres'
run: pip install psycopg2>=2.8.6
- name: Install django-jsonfield-backport
if: matrix.django == 2.2 || matrix.django == 3.0
run: pip install "django-jsonfield-backport>=1.0.2,<2.0"

# install our package
- name: Install package
run: pip install -e .

# execute the tests
- name: Run tests
run: coverage run runtests/manage.py test -v3 --noinput actstream testapp testapp_nested
env:
DATABASE_ENGINE: ${{ matrix.database }}
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:focal

ENV PYTHONUNBUFFERED 1
ENV LC_ALL=C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive

# the base image is also built using this Dockerfile, so we have to reset this
USER root

RUN apt-get -y update && apt-get -y --no-install-recommends install \
build-essential \
gcc \
gettext \
python3-dev \
python3-venv \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /usr/share/doc/* /usr/share/locale/* /usr/share/man/* && \
mkdir -p /app && \
(useradd -m app || true)

COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:1.23.2 /usr/local/bin/docker-compose /usr/bin/docker-compose

WORKDIR /app

ADD runtests/requirements.txt /app/

USER app

ENV PATH /home/app/venv/bin:${PATH}

RUN python3 -m venv ~/venv && \
pip install -r /app/requirements.txt

ENV DJANGO_SETTINGS_MODULE settings

# *WARNING*: DO NOT "ADD . /app" because it would include the current settings in the base image, which is uploaded by
# CI to docker hub; Since the settings currently include secrets, this would leak our credentials!

EXPOSE 8000

ENTRYPOINT ["/app/manage.py"]
9 changes: 2 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Django Activity Stream
======================

.. image:: https://travis-ci.org/justquick/django-activity-stream.svg?branch=master
:target: https://travis-ci.org/justquick/django-activity-stream
.. image:: https://github.com/justquick/django-activity-stream/workflows/Test%20and%20deploy/badge.svg
:target: https://github.com/justquick/django-activity-stream/actions?query=workflow%3A%22Test+and+deploy%22

.. image:: https://badges.gitter.im/django-activity-stream/Lobby.svg
:alt: Join the chat at https://gitter.im/django-activity-stream/Lobby
Expand Down Expand Up @@ -54,8 +54,3 @@ Contributors
This project exists thanks to all the people who contribute!

.. image:: https://opencollective.com/django-activity-stream/contributors.svg?width=890&button=false

Sponsors
========

`Get supported django-activity-stream with the Tidelift Subscription <https://tidelift.com/subscription/pkg/pypi-django-activity-stream?utm_source=pypi-django-activity-stream&utm_medium=referral&utm_campaign=readme>`_
2 changes: 1 addition & 1 deletion actstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
except:
pass

__version__ = '0.9.0'
__version__ = '0.10.0'
__author__ = 'Asif Saif Uddin, Justin Quick <[email protected]>'
default_app_config = 'actstream.apps.ActstreamConfig'
12 changes: 2 additions & 10 deletions actstream/actions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from django.utils.six import text_type
from django.utils.timezone import now
from django.contrib.contenttypes.models import ContentType

from actstream import settings
from actstream.signals import action
from actstream.registry import check

try:
from django.utils import timezone

now = timezone.now
except ImportError:
import datetime
now = datetime.datetime.now


def follow(user, obj, send_action=True, actor_only=True, flag='', **kwargs):
"""
Expand Down Expand Up @@ -125,7 +117,7 @@ def action_handler(verb, **kwargs):
newaction = apps.get_model('actstream', 'action')(
actor_content_type=ContentType.objects.get_for_model(actor),
actor_object_id=actor.pk,
verb=text_type(verb),
verb=str(verb),
public=bool(kwargs.pop('public', True)),
description=kwargs.pop('description', None),
timestamp=kwargs.pop('timestamp', now())
Expand Down
30 changes: 23 additions & 7 deletions actstream/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from collections import OrderedDict

import django
from django.apps import apps
from django.apps import AppConfig
from django.conf import settings

from actstream import settings
from actstream import settings as actstream_settings
from actstream.signals import action


Expand All @@ -12,9 +17,20 @@ def ready(self):
action.connect(action_handler, dispatch_uid='actstream.models')
action_class = self.get_model('action')

if settings.USE_JSONFIELD:
from actstream.jsonfield import DataField, register_app
DataField(blank=True, null=True).contribute_to_class(
action_class, 'data'
)
register_app(self)
if actstream_settings.USE_JSONFIELD:
if not hasattr(action_class, 'data'):
from actstream.jsonfield import DataField
DataField(blank=True, null=True).contribute_to_class(
action_class, 'data'
)

# dynamically load django_jsonfield_backport to INSTALLED_APPS
if django.VERSION < (3, 1) and 'django_jsonfield_backport' not in settings.INSTALLED_APPS:
settings.INSTALLED_APPS += ('django_jsonfield_backport', )
# reset loaded apps
apps.app_configs = OrderedDict()
# reset initialization status
apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
apps.clear_cache()
# re-initialize all apps
apps.populate(settings.INSTALLED_APPS)
Loading

0 comments on commit e3c58db

Please sign in to comment.