Skip to content

Commit

Permalink
Merge pull request #15 from unlimitedlabs/circle_support
Browse files Browse the repository at this point in the history
Adds circle support.
  • Loading branch information
thisisdhaas committed Sep 22, 2015
2 parents 70016da + 1cb1b0c commit 66d2d04
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ backup.sql

# Compressed staticfiles
/orchestra/staticfiles
example_project/staticfiles
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
COVERAGE_ANNOTATION=coverage_annotations
TEST_CMD=manage.py test orchestra beanstalk_dispatch

clean:
find . -name '*.pyo' -delete
find . -name '*.pyc' -delete
find . -name __pycache__ -delete
find . -name '*~' -delete

lint:
flake8 .

test: lint
cd example_project && python3 $(TEST_CMD)

coverage:
cd example_project && \
coverage run --source=../orchestra $(TEST_CMD)

coverage_artifacts:
cd example_project && \
coverage html -d coverage_artifacts

test_coverage:
cd example_project && \
coverage erase && \
rm -rf $(COVERAGE_ANNOTATION) && \
coverage run --source=../orchestra $(TEST_CMD) && \
coverage annotate -d $(COVERAGE_ANNOTATION) && \
coverage report && \
echo 'Annotated source in `example_project/$(COVERAGE_ANNOTATION)` directory'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# orchestra
# Orchestra

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/unlimitedlabs/orchestra?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
14 changes: 14 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test:
override:
- make lint
- make coverage
post:
- make coverage_artifacts && cp -R example_project/coverage_artifacts $CIRCLE_ARTIFACTS/coverage

machine:
python:
version: 3.4.1

dependencies:
override:
- pip install -r requirements.txt
Empty file.
152 changes: 152 additions & 0 deletions example_project/example_project/orchestra_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"""
Settings for the Orchestra app.
Modify these according to your setup, then make sure they are included in your
main settings file by adding::
from .orchestra_settings import setup_orchestra
setup_orchestra(__name__)
to the bottom of `settings.py`.
"""

import os
import sys


def setup_orchestra(settings_module_name):
settings = sys.modules[settings_module_name]
if not hasattr(settings, 'INSTALLED_APPS'):
settings.INSTALLED_APPS = ()
if not hasattr(settings, 'STATICFILES_FINDERS'):
settings.STATICFILES_FINDERS = ()

# General
##########

# URL at which Orchestra is publicly accessible
settings.ORCHESTRA_URL = 'http://127.0.0.1:8000'

# Production environment
environment = os.environ.get('ENVIRONMENT')
settings.PRODUCTION = False
settings.STAGING = False
if environment == 'production':
settings.PRODUCTION = True
elif environment == 'staging':
settings.STAGING = True

# Required Django apps
settings.INSTALLED_APPS += (
'compressor',
'django_object_actions',
'registration',
'orchestra',
'beanstalk_dispatch',
)

settings.STATICFILES_FINDERS += (
'compressor.finders.CompressorFinder',
)

settings.COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),
)

# Allow pre-compression independent of user requests
settings.COMPRESS_OFFLINE = True

# Tasks and Workflows
######################

# Installed orchestra workflows
settings.ORCHESTRA_PATHS = (
)

# The maximum number of tasks an expert can pick up at a time.
# Currently disabled.
settings.ORCHESTRA_MAX_IN_PROGRESS_TASKS = 3

# Notification-specific email for message bundling and searching
settings.ORCHESTRA_NOTIFICATIONS_FROM_EMAIL = (
'Orchestra <noreply@example.org>')

# S3 bucket name to upload images to
settings.EDITOR_IMAGE_BUCKET_NAME = 'CHANGEME'

# Registration
###############

# Orchestra registration urls: must match urls.py
settings.LOGIN_REDIRECT_URL = '/orchestra/app/'
settings.LOGIN_URL = '/orchestra/accounts/login/'

# Orchestra Registration setings
settings.ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
settings.REGISTRATION_AUTO_LOGIN = True # Automatically log the user in.

# API Authentication
#####################

# Orchestra project API client credentials: CHANGE THE SECRET.
settings.ORCHESTRA_PROJECT_API_KEY = 'orchestra-user'
settings.ORCHESTRA_PROJECT_API_SECRET = 'CHANGEME'

# Orchestra project API server authentication via httpsignature.
settings.INSTALLED_APPS += ('rest_framework_httpsignature',)

# A dictionary of allowed project API keys and secrets.
settings.ORCHESTRA_PROJECT_API_CREDENTIALS = {
'orchestra-user': 'CHANGEME'
}

# Django REST framework
settings.INSTALLED_APPS += ('rest_framework',)

# Don't authenticate users without a view explicitly calling for it
settings.REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (),
}

# Machine Step Scheduling
##########################

# Scheduler for machine steps
settings.MACHINE_STEP_SCHEDULER = (
'orchestra.utils.machine_step_scheduler',
'SynchronousMachineStepScheduler')

# Beanstalk dispatcher
# Add keys to use AsynchronousMachineStepScheduler
settings.BEANSTALK_DISPATCH_SQS_KEY = ''
settings.BEANSTALK_DISPATCH_SQS_SECRET = ''
settings.WORK_QUEUE = ''
if os.environ.get('BEANSTALK_WORKER') == 'True':
settings.BEANSTALK_DISPATCH_TABLE = {
'machine_task_executor': ('orchestra.machine_tasks', 'execute')}

# 3rd Party Integrations
#########################

# AWS Credentials
settings.AWS_S3_KEY = '' # FILL IN
settings.AWS_S3_SECRET = '' # FILL IN

# REQUIRED: Google API related service email and path to a secret key.
settings.GOOGLE_SERVICE_EMAIL = ''
settings.GOOGLE_P12_PATH = ''

# Google Drive root folder id for Media Extraction.
settings.GOOGLE_PROJECT_ROOT_ID = ''

# Feature flags for toggling optional slack integration
settings.SLACK_INTERNAL = True
settings.SLACK_EXPERTS = False

# Settings for slack notifications. Notifications are shared internally
# upon task status change; the experts team organizes project
# communication.
settings.SLACK_EXPERTS_BASE_URL = ''
settings.SLACK_INTERNAL_API_KEY = ''
settings.SLACK_EXPERTS_API_KEY = ''
settings.SLACK_INTERNAL_NOTIFICATION_CHANNEL = '#orchestra-tasks'
107 changes: 107 additions & 0 deletions example_project/example_project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""
Django settings for example_project project.
Generated by 'django-admin startproject' using Django 1.8.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Add local orchestra to the system path: only for testing
sys.path.append(os.path.join(BASE_DIR, '../'))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'CHANGEMEOMG'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'example_project.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'example_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'circle_test',
'USER': 'ubuntu',
'PASSWORD': '',
'HOST': '',
'PORT': '5432',
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

from .orchestra_settings import setup_orchestra
setup_orchestra(__name__)
33 changes: 33 additions & 0 deletions example_project/example_project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
example_project URL Configuration.
Registers all of the orchestra URLs so orchestra is usable when
`example_project` gets run. Additional URLs for other apps should be installed
here as well.
"""
from django.conf.urls import include, url
from django.contrib.auth import views as auth_views

urlpatterns = [

# Registration Views
# Eventually these will be auto-registered with the Orchestra URLs, but for
# now we need to add them separately.
url(r'^orchestra/accounts/',
include(
'registration.backends.default.urls')),

# Logout then login is not available as a standard django
# registration route.
url(r'^orchestra/accounts/logout_then_login/$',
auth_views.logout_then_login,
name='logout_then_login'),

# Orchestra URLs
url(r'^orchestra/',
include('orchestra.urls', namespace='orchestra')),

# Beanstalk Dispatch URLs
url(r'^beanstalk_dispatch/',
include('beanstalk_dispatch.urls')),
]
16 changes: 16 additions & 0 deletions example_project/example_project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for example_project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")

application = get_wsgi_application()
10 changes: 10 additions & 0 deletions example_project/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

0 comments on commit 66d2d04

Please sign in to comment.