Skip to content

Commit

Permalink
Merge pull request #95 from 5monkeys/ci2
Browse files Browse the repository at this point in the history
Merge CI into pre-commit branch
  • Loading branch information
Swamii committed Mar 31, 2022
2 parents 3d0412d + 8a53ae8 commit 4f72639
Show file tree
Hide file tree
Showing 44 changed files with 288 additions and 442 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Expand Up @@ -6,7 +6,6 @@
.gitignore
.next/
.stuff/
.travis.yml
.venv/
Dockerfile
dist/
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,73 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: pre-commit/action@v2.0.3

tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
max-parallel: 5
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade packaging tools
run: python -m pip install --upgrade pip setuptools virtualenv
- name: Install dependencies
run: python -m pip install --upgrade tox
- name: Run tox targets for ${{ matrix.python-version }}
run: |
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}")
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') python -m tox
- uses: actions/upload-artifact@master
with:
name: coverage-files
path: ./.coverage.*

coverage:
name: Reporting Coverage
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')
needs: [tests]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/download-artifact@v3
with:
name: coverage-files
path: .
- name: Combine coverage reports
run: |
python -m pip install coverage
make coverage-lcov
- name: Upload coverage report
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./coverage.info"
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -2,7 +2,7 @@
*.egg
*.egg-info
*.eggs/
.coverage
.coverage*
.idea
.DS_Store
.tox
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Expand Up @@ -10,12 +10,12 @@ repos:
- id: trailing-whitespace
- id: debug-statements
- id: detect-private-key
# - repo: https://github.com/asottile/pyupgrade
# rev: v2.31.0
# hooks:
# - id: pyupgrade
# args:
# - --py36-plus
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args:
- --py36-plus
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
Expand Down
93 changes: 0 additions & 93 deletions .travis.yml

This file was deleted.

7 changes: 6 additions & 1 deletion Makefile
Expand Up @@ -18,9 +18,14 @@ coverage:
coverage combine || true
coverage report

.PHONY: coverage-lcov
coverage-lcov:
coverage combine || true
coverage lcov -o coverage.info

.PHONY: lint
lint:
flake8 djedi
pre-commit run --all-files

.PHONY: install
install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

Django content management as it should be.

[![Build Status](https://travis-ci.org/5monkeys/djedi-cms.svg?branch=master)](https://travis-ci.org/5monkeys/djedi-cms)
[![Build Status](https://github.com/5monkeys/djedi-cms/workflows/CI/badge.svg)](https://github.com/5monkeys/djedi-cms/actions)
[![Coverage Status](https://coveralls.io/repos/5monkeys/djedi-cms/badge.svg?branch=master&service=github)](https://coveralls.io/github/5monkeys/djedi-cms?branch=master)
[![Version](https://img.shields.io/pypi/v/djedi-cms.svg)](https://pypi.python.org/pypi/djedi-cms/)
[![Python Versions](https://img.shields.io/pypi/pyversions/djedi-cms.svg)](https://pypi.python.org/pypi/djedi-cms/)
Expand Down
1 change: 0 additions & 1 deletion djedi-react/.dockerignore
Expand Up @@ -6,7 +6,6 @@
.gitignore
.next/
.stuff/
.travis.yml
Dockerfile
dist/
docker-compose.yml
Expand Down
1 change: 0 additions & 1 deletion djedi/__init__.py
@@ -1,4 +1,3 @@
# coding=utf-8
VERSION = (1, 3, 3, "final", 0)


Expand Down
5 changes: 3 additions & 2 deletions djedi/admin/api.py
Expand Up @@ -2,6 +2,7 @@

from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpResponse, HttpResponseBadRequest
from django.template.response import TemplateResponse
from django.utils.http import urlunquote
from django.views.decorators.cache import never_cache
from django.views.decorators.clickjacking import xframe_options_exempt
Expand All @@ -14,7 +15,6 @@
from cio.utils.uri import URI

from .. import auth
from ..compat import TemplateResponse
from ..plugins.base import DjediPlugin
from .exceptions import InvalidNodeData
from .mixins import DjediContextMixin, JSONResponseMixin
Expand All @@ -27,7 +27,7 @@ def dispatch(self, request, *args, **kwargs):
raise PermissionDenied

try:
return super(APIView, self).dispatch(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
except Http404:
raise
except Exception as e:
Expand Down Expand Up @@ -222,4 +222,5 @@ def render_plugin(self, request, context):
"djedi/plugins/base/editor.html",
],
self.get_context_data(**context),
using="django",
)
11 changes: 7 additions & 4 deletions djedi/admin/cms.py
@@ -1,10 +1,11 @@
from django.conf.urls import include, url
from django.contrib.admin import ModelAdmin
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.generic import View

from ..auth import has_permission
from ..compat import include, patterns, render, url
from .mixins import DjediContextMixin


Expand All @@ -14,12 +15,12 @@ class Admin(ModelAdmin):
verbose_name_plural = verbose_name

def get_urls(self):
return patterns(
return [
url(r"^", include("djedi.admin.urls", namespace="djedi")),
url(
r"", lambda: None, name="djedi_cms_changelist"
), # Placeholder to show change link to CMS in admin
)
]

def has_change_permission(self, request, obj=None):
return has_permission(request)
Expand All @@ -40,6 +41,8 @@ class DjediCMS(DjediContextMixin, View):
@xframe_options_exempt
def get(self, request):
if has_permission(request):
return render(request, "djedi/cms/cms.html", self.get_context_data())
return render(
request, "djedi/cms/cms.html", self.get_context_data(), using="django"
)
else:
raise PermissionDenied
8 changes: 3 additions & 5 deletions djedi/admin/mixins.py
Expand Up @@ -8,7 +8,7 @@
# TODO: Switch simplejson to ujson or other?


class JSONResponseMixin(object):
class JSONResponseMixin:
"""
A mixin that can be used to render a JSON response.
"""
Expand All @@ -29,14 +29,12 @@ def convert_context_to_json(self, context):
return json.dumps(context, indent=4, for_json=True)


class DjediContextMixin(object):
class DjediContextMixin:
def get_context_data(self, **context):
theme = settings.THEME

if "/" not in theme:
theme = "{static}djedi/themes/{theme}/theme.css".format(
static=django_settings.STATIC_URL, theme=theme
)
theme = f"{django_settings.STATIC_URL}djedi/themes/{theme}/theme.css"

context["THEME"] = theme
context["VERSION"] = djedi.__version__
Expand Down
7 changes: 4 additions & 3 deletions djedi/admin/urls.py
@@ -1,10 +1,11 @@
from ..compat import include, patterns, url
from django.conf.urls import include, url

from .api import LoadApi, NodeApi, NodeEditor, PublishApi, RenderApi, RevisionsApi
from .cms import DjediCMS

app_name = "djedi"

urlpatterns = patterns(
urlpatterns = [
url(r"^$", DjediCMS.as_view(), name="cms"),
url(r"^node/(?P<uri>.+)/editor$", NodeEditor.as_view(), name="cms.editor"),
url(r"^node/(?P<uri>.+)/load$", LoadApi.as_view(), name="api.load"),
Expand All @@ -13,4 +14,4 @@
url(r"^node/(?P<uri>.+)$", NodeApi.as_view(), name="api"),
url(r"^plugin/(?P<ext>\w+)$", RenderApi.as_view(), name="api.render"),
url(r"^api/", include("djedi.rest.urls", namespace="rest")),
)
]

0 comments on commit 4f72639

Please sign in to comment.