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

Migrate to GitHub Actions. #340

Merged
merged 8 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source = tinymce
branch = True
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-tinymce'
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') }}-${{ hashFiles('**/tox.ini') }}
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-tinymce/upload
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test

on: [push, pull_request]

jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
django-version: ['2.2', '3.0', '3.1', 'dev']

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
env:
DJANGO: ${{ matrix.django-version }}

- 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 @@ -6,3 +6,4 @@
.venv/
__pycache__/
.tox/
coverage.xml
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include *.txt *.py *.rst setup.cfg
include docs/*.rst
exclude *.pyc
recursive-include testtinymce *
recursive-include tests *
recursive-include tinymce *
54 changes: 0 additions & 54 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Verify that everything is installed and configured properly:

#. Setup environment variable ``DJANGO_SETTINGS_MODULE``::

export DJANGO_SETTINGS_MODULE='testtinymce.settings'
export DJANGO_SETTINGS_MODULE='tests.settings'

#. Create project and change into project directory::

Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ The source contains a `test project`_ that includes this flatpages model admin.
#. Checkout django-tinymce:
``git clone https://github.com/jazzband/django-tinymce.git``
#. Go to the test project:
``cd django-tinymce/testtinymce``
``cd django-tinymce/tests``
#. Copy the ``tiny_mce`` directory from the TinyMCE distribution into
``media/js``
#. Run ``python manage.py migrate``
Expand All @@ -228,5 +228,5 @@ The source contains a `test project`_ that includes this flatpages model admin.
#. Connect to `http://localhost:8000/admin/`_ and login with the above-created
user.

.. _`test project`: https://github.com/jazzband/django-tinymce/tree/master/testtinymce
.. _`test project`: https://github.com/jazzband/django-tinymce/tree/master/tests
.. _`http://localhost:8000/admin/`: http://localhost:8000/admin/
3 changes: 0 additions & 3 deletions profile

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ def read_file(filename):
],
platforms=["any"],
url="https://github.com/jazzband/django-tinymce",
test_suite="runtests.runtests",
)
File renamed without changes.
2 changes: 1 addition & 1 deletion testtinymce/manage.py → tests/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

try:
os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, test_dir)
except ImportError:
Expand Down
11 changes: 6 additions & 5 deletions testtinymce/settings.py → tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Django settings for testtinymce project.

from os.path import dirname, join, realpath

ROOT_PATH = dirname(realpath(__file__))
Expand All @@ -8,7 +6,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": join(ROOT_PATH, "testtinymce.sqlite"),
"NAME": join(ROOT_PATH, "tests.sqlite"),
"USER": "",
"PASSWORD": "",
"HOST": "",
Expand Down Expand Up @@ -49,6 +47,7 @@
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
Expand All @@ -58,7 +57,7 @@

SECRET_KEY = "w4o4x^&b4h4zne9&3b1m-_p-=+&n_i_sdf@oz=gd+6h6v1$sd9"

ROOT_URLCONF = "testtinymce.urls"
ROOT_URLCONF = "tests.urls"

INSTALLED_APPS = (
"django.contrib.auth",
Expand All @@ -70,7 +69,7 @@
"django.contrib.admin",
"django.contrib.flatpages",
"tinymce",
"testtinymce.testapp",
"tests.testapp",
)

TINYMCE_SPELLCHECKER = True
Expand All @@ -87,3 +86,5 @@
"alignright alignjustify | bullist numlist outdent indent | "
"removeformat | help",
}

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
File renamed without changes.
2 changes: 1 addition & 1 deletion tinymce/tests/test_models.py → tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tinymce.widgets import AdminTinyMCE

from .models import TestModel
from tests.testapp.models import TestModel


class TestModels(SimpleTestCase):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion testtinymce/testapp/admin.py → tests/testapp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.flatpages.models import FlatPage
from django.urls import reverse

from testtinymce.testapp.models import TestInline, TestPage
from tests.testapp.models import TestInline, TestPage
from tinymce.widgets import TinyMCE


Expand Down
21 changes: 21 additions & 0 deletions tests/testapp/migrations/0002_testmodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.2.17 on 2021-01-28 10:51

from django.db import migrations, models
import tinymce.models


class Migration(migrations.Migration):

dependencies = [
('testapp', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='TestModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('foobar', tinymce.models.HTMLField()),
],
),
]
5 changes: 5 additions & 0 deletions testtinymce/testapp/models.py → tests/testapp/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from django.db import models
from tinymce import models as tinymce_models


class TestModel(models.Model):
foobar = tinymce_models.HTMLField()


class TestPage(models.Model):
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion testtinymce/testapp/views.py

This file was deleted.

Empty file removed tinymce/tests/__init__.py
Empty file.
7 changes: 0 additions & 7 deletions tinymce/tests/models.py

This file was deleted.

4 changes: 2 additions & 2 deletions tinymce/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.http import HttpResponse
from django.shortcuts import render
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt

Expand All @@ -28,7 +28,7 @@ def spell_check(request):
if not enchant:
raise RuntimeError("install pyenchant for spellchecker functionality")

raw = force_text(request.body)
raw = force_str(request.body)
input = json.loads(raw)
id = input["id"]
method = input["method"]
Expand Down
4 changes: 2 additions & 2 deletions tinymce/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.contrib.admin import widgets as admin_widgets
from django.forms.utils import flatatt
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import get_language, gettext as _, to_locale
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_mce_config(self, attrs):
def render(self, name, value, attrs=None, renderer=None):
if value is None:
value = ""
value = force_text(value)
value = force_str(value)
final_attrs = self.build_attrs(self.attrs, attrs)
final_attrs["name"] = name
if final_attrs.get("class", None) is None:
Expand Down
Loading