Skip to content

Commit

Permalink
Merge d6d6c5c into f73f9b2
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Apr 12, 2020
2 parents f73f9b2 + d6d6c5c commit 3690259
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
14 changes: 10 additions & 4 deletions Makefile
Expand Up @@ -11,12 +11,18 @@ flake8:
# ignore "line too long"
@flake8 --exclude=$(FLAKE8_EXCLUDE) --ignore=E501 tcms_github_app/

KIWI_LINT_INCLUDE_PATH="../Kiwi/"

.PHONY: pylint
pylint:
pylint --load-plugins=pylint_django \
-d missing-docstring -d duplicate-code \
-d wildcard-import -d unused-wildcard-import \
*.py tcms_github_app/ test_project/
if [ ! -d "$(KIWI_LINT_INCLUDE_PATH)/kiwi_lint" ]; then \
git clone --depth 1 https://github.com/kiwitcms/Kiwi.git $(KIWI_LINT_INCLUDE_PATH); \
fi

PYTHONPATH=$(KIWI_LINT_INCLUDE_PATH) DJANGO_SETTINGS_MODULE="test_project.settings" \
pylint --load-plugins=pylint_django --load-plugins=kiwi_lint \
-d missing-docstring -d duplicate-code -d module-in-directory-without-init \
*.py tcms_github_app/ test_project/ tcms_settings_dir/

.PHONY: test_for_missing_migrations
test_for_missing_migrations:
Expand Down
41 changes: 21 additions & 20 deletions README.rst
Expand Up @@ -27,14 +27,15 @@ GitHub App integration for Kiwi TCMS
Introduction
------------

This package provides the GitHub App integration for Kiwi TCMS and is
designed to work only for multi-tenant environments.
This package provides the GitHub App integration for
`Kiwi TCMS Enterprise <https://github.com/MrSenko/kiwitcms-enterprise/>`_
and is designed to work only for multi-tenant environments!
You don't need this add-on in order to run Kiwi TCMS without extended
GitHub integration!

Communication from GitHub to this add-on is via webhooks.
Communication from GitHub to this plugin is via webhooks.

Add-on behavior:
Plugin behavior:

- Auto-configure which tenant to use for database operations, either
'public' or a single private tenant to which user has access.
Expand All @@ -44,21 +45,9 @@ Add-on behavior:
- Existing & newly created repositories are added as products in Kiwi TCMS.
Fork repositories are skipped
- Newly created git tags are added as product versions in Kiwi TCMS
- 1-click bug reports to GitHub Issues


Vote for other ideas:

- When TE is updated then post status to pull request. See
`Issue #9 <https://github.com/kiwitcms/github-app/issues/9>`_
- When opening PR then create a new TR. See
`Issue #10 <https://github.com/kiwitcms/github-app/issues/10>`_
- When opening PR then auto-scan with kiwitcms-bot. See
`Issue #11 <https://github.com/kiwitcms/github-app/issues/11>`_
- When new Tag/Release then perform artifact testing. See
`Issue #12 <https://github.com/kiwitcms/github-app/issues/12>`_
- Auto-configure bug tracker for new product/repository. See
`Issue #15 <https://github.com/kiwitcms/github-app/issues/15>`_
See `Issues <https://github.com/kiwitcms/github-app/issues>`_ for other ideas!


Installation
Expand All @@ -80,13 +69,25 @@ everything else will be taken care for by Kiwi TCMS plugin loading code!
GitHub App configuration
------------------------

- User authorization callback URL: https://public.tenant.kiwitcms.org/complete/github-app/
This plugin needs an existing GitHub App application with the following
configuration:

- User authorization callback URL: https://tcms.example.com/complete/github-app/
- Request user authorization (OAuth) during installation - True
- Webhook URL - https://public.tenant.kiwitcms.org/kiwitcms_github_app/webhook/
- Permissions:
- Webhook Active - True
- Webhook URL - https://tcms.example.com/kiwitcms_github_app/webhook/
- Webhook Secret - <the value of KIWI_GITHUB_APP_SECRET>
- SSL verification - Enabled

Then configure how the application interacts with GitHub:

- Repository permissions:

- Contents: Read-only
- Metadata: Read-only

- User permissions:

- Email addresses: Read-only

- Subscribe to events:
Expand Down
14 changes: 11 additions & 3 deletions tcms_github_app/views.py
Expand Up @@ -21,15 +21,23 @@
from tcms_github_app import utils


class ApplicationEdit(View):
class ApplicationEdit(View): # pylint: disable=missing-permission-required
"""
If there is an App installation made on GitHub by the current user
then allow them to edit it.
.. note::
This view only redirects either to the appropriate admin page
for editing or to "/" with an appropriate message indicating what's
wrong. Permission checks are actually performed in
``AppInstallationAdmin.has_change_permission()`` so we don't need
a ``@permission_required`` decorator here!
"""
def get(self, request, *args, **kwargs):
social_user = request.user.social_auth.first()
if not social_user:
github_url = reverse('social:begin', args=['github'])
github_url = reverse('social:begin', args=['github-app'])
messages.add_message(
request,
messages.WARNING,
Expand Down Expand Up @@ -76,7 +84,7 @@ def get(self, request, *args, **kwargs):
return HttpResponseRedirect('/')


class WebHook(View):
class WebHook(View): # pylint: disable=missing-permission-required
"""
Handles `marketplace_purchase` web hook as described at:
https://developer.github.com/marketplace/listing-on-github-marketplace/configuring-the-github-marketplace-webhook/
Expand Down
3 changes: 2 additions & 1 deletion test_project/settings.py
Expand Up @@ -3,6 +3,7 @@
# Licensed under the GPL 3.0: https://www.gnu.org/licenses/gpl-3.0.txt
#
# pylint: disable=invalid-name,protected-access,wrong-import-position
# pylint: disable=wildcard-import, unused-wildcard-import

import os
import sys
Expand Down Expand Up @@ -48,7 +49,7 @@
SECRET_KEY = '7d09f358-6609-11e9-8140-34363b8604e2'


DATABASES['default'].update({
DATABASES['default'].update({ # pylint: disable=objects-update-used
'NAME': 'test_project',
'USER': 'kiwi',
'PASSWORD': 'kiwi',
Expand Down

0 comments on commit 3690259

Please sign in to comment.