Support running Studio with optimized assets

This commit is contained in:
Andy Armstrong
2015-06-25 18:03:01 -04:00
parent 072ae99d12
commit 85814f0bbf
11 changed files with 590 additions and 60 deletions

View File

@@ -36,7 +36,7 @@ from .aws import * # pylint: disable=wildcard-import, unused-wildcard-import
INSTALLED_APPS += ('django_extensions',)
# Redirect to the test_root folder within the repo
TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" # pylint: disable=no-value-for-parameter
TEST_ROOT = REPO_ROOT / "test_root" # pylint: disable=no-value-for-parameter
GITHUB_REPO_ROOT = (TEST_ROOT / "data").abspath()
LOG_DIR = (TEST_ROOT / "log").abspath()
@@ -64,7 +64,7 @@ STATICFILES_FINDERS = (
'staticfiles.finders.FileSystemFinder',
)
STATICFILES_DIRS = (
(TEST_ROOT / "staticfiles").abspath(),
(TEST_ROOT / "staticfiles" / "cms").abspath(),
)
# Silence noisy logs

View File

@@ -0,0 +1,40 @@
"""
Settings to run Studio in devstack using optimized static assets.
This configuration changes Studio to use the optimized static assets generated for testing,
rather than picking up the files directly from the source tree.
The following Paver command can be used to run Studio in optimized mode:
paver devstack studio --optimized
You can also generate the assets explicitly and then run Studio:
paver update_assets cms --settings=test_static_optimized
paver devstack studio --settings=devstack_optimized --fast
Note that changes to JavaScript assets will not be picked up automatically
as they are for non-optimized devstack. Instead, update_assets must be
invoked each time that changes have been made.
"""
########################## Devstack settings ###################################
from .devstack import * # pylint: disable=wildcard-import, unused-wildcard-import
TEST_ROOT = REPO_ROOT / "test_root" # pylint: disable=no-value-for-parameter
############################ STATIC FILES #############################
# Enable debug so that static assets are served by Django
DEBUG = True
# Serve static files at /static directly from the staticfiles directory under test root.
# Note: optimized files for testing are generated with settings from test_static_optimized
STATIC_URL = "/static/"
STATICFILES_FINDERS = (
'staticfiles.finders.FileSystemFinder',
)
STATICFILES_DIRS = (
(TEST_ROOT / "staticfiles" / "cms").abspath(),
)

View File

@@ -10,36 +10,26 @@ support both generating static assets to a directory and also serving static
from the same directory.
"""
import os
from path import path # pylint: disable=no-name-in-module
# Start with the common settings
from .common import * # pylint: disable=wildcard-import, unused-wildcard-import
# Pylint gets confused by path.py instances, which report themselves as class
# objects. As a result, pylint applies the wrong regex in validating names,
# and throws spurious errors. Therefore, we disable invalid-name checking.
# pylint: disable=invalid-name
# Use an in-memory database since this settings file is only used for updating assets
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
},
}
######################### Static file overrides ####################################
########################## Prod-like settings ###################################
# These should be as close as possible to the settings we use in production.
# As in prod, we read in environment and auth variables from JSON files.
# Unlike in prod, we use the JSON files stored in this repo.
# This is a convenience for ensuring (a) that we can consistently find the files
# and (b) that the files are the same in Jenkins as in local dev.
os.environ['SERVICE_VARIANT'] = 'bok_choy'
os.environ['CONFIG_ROOT'] = path(__file__).abspath().dirname() # pylint: disable=no-value-for-parameter
from .aws import * # pylint: disable=wildcard-import, unused-wildcard-import
######################### Testing overrides ####################################
# Redirects to the test_root folder within the repo
TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" # pylint: disable=no-value-for-parameter
# Redirect to the test_root folder within the repo
TEST_ROOT = REPO_ROOT / "test_root" # pylint: disable=no-value-for-parameter
LOG_DIR = (TEST_ROOT / "log").abspath()
# Stores the static files under test root so that they don't overwrite existing static assets
STATIC_ROOT = (TEST_ROOT / "staticfiles").abspath()
# Store the static files under test root so that they don't overwrite existing static assets
STATIC_ROOT = (TEST_ROOT / "staticfiles" / "cms").abspath()
# Disables uglify when tests are running (used by build.js).
# Disable uglify when tests are running (used by build.js).
# 1. Uglify is by far the slowest part of the build process
# 2. Having full source code makes debugging tests easier for developers
os.environ['REQUIRE_BUILD_PROFILE_OPTIMIZE'] = 'none'