mirror of https://github.com/zulip/zulip.git
update-prod-static: Rewrite to use the run() scripting tool.
This provides nice `set -x` style logging of which commands are running when.
This commit is contained in:
parent
c8db7b7dd7
commit
5b5d1f3e87
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -14,6 +13,7 @@ import scripts.lib.setup_path_on_import
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from scripts.lib.node_cache import setup_node_modules
|
from scripts.lib.node_cache import setup_node_modules
|
||||||
|
from scripts.lib.zulip_tools import run
|
||||||
|
|
||||||
# check for the venv
|
# check for the venv
|
||||||
from lib import sanity_check
|
from lib import sanity_check
|
||||||
|
@ -30,52 +30,42 @@ prev_deploy = args.prev_deploy
|
||||||
os.chdir(settings.DEPLOY_ROOT)
|
os.chdir(settings.DEPLOY_ROOT)
|
||||||
|
|
||||||
# Redirect child processes' output to a log file (most recent run only).
|
# Redirect child processes' output to a log file (most recent run only).
|
||||||
subprocess.check_call(["mkdir", "-p", "var/log"])
|
run(["mkdir", "-p", "var/log"])
|
||||||
fp = open('var/log/update-prod-static.log', 'w')
|
fp = open('var/log/update-prod-static.log', 'w')
|
||||||
|
|
||||||
# Install node packages
|
# Install node packages
|
||||||
setup_node_modules(production=True, stdout=fp, stderr=fp)
|
setup_node_modules(production=True, stdout=fp, stderr=fp)
|
||||||
|
|
||||||
# Build emoji
|
# Build emoji
|
||||||
subprocess.check_call(['./tools/setup/emoji/build_emoji'],
|
run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Inline CSS in emails
|
# Inline CSS in emails
|
||||||
subprocess.check_call(['./tools/inline-email-css'],
|
run(['./tools/inline-email-css'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Copy over static files from the zulip_bots package
|
# Copy over static files from the zulip_bots package
|
||||||
subprocess.check_call(['./tools/setup/generate_zulip_bots_static_files'],
|
run(['./tools/setup/generate_zulip_bots_static_files'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Generate custom icon webfont
|
# Generate custom icon webfont
|
||||||
subprocess.check_call(['./tools/generate-custom-icon-webfont'],
|
run(['./tools/generate-custom-icon-webfont'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Build pygment data
|
# Build pygment data
|
||||||
subprocess.check_call(['./tools/setup/build_pygments_data'],
|
run(['./tools/setup/build_pygments_data'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Compile Handlebars templates and minify JavaScript.
|
# Compile Handlebars templates and minify JavaScript.
|
||||||
subprocess.check_call(['./tools/minify-js'] +
|
run(['./tools/minify-js'] + (['--prev-deploy', prev_deploy] if prev_deploy else []),
|
||||||
(['--prev-deploy', prev_deploy] if prev_deploy else []),
|
stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Copy the KaTeX files outside node_modules
|
# Copy the KaTeX files outside node_modules
|
||||||
subprocess.check_call(['mkdir', '-p',
|
run(['mkdir', '-p', os.path.join(settings.STATIC_ROOT, 'node_modules/katex/dist/')],
|
||||||
os.path.join(settings.STATIC_ROOT,
|
stdout=fp, stderr=fp)
|
||||||
'node_modules/katex/dist/')],
|
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
subprocess.check_call(['cp', 'node_modules/katex/dist/katex.css',
|
run(['cp', 'node_modules/katex/dist/katex.css',
|
||||||
os.path.join(settings.STATIC_ROOT,
|
os.path.join(settings.STATIC_ROOT, 'node_modules/katex/dist/')],
|
||||||
'node_modules/katex/dist/')],
|
stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
subprocess.check_call(['cp', '-R', 'node_modules/katex/dist/fonts',
|
run(['cp', '-R', 'node_modules/katex/dist/fonts',
|
||||||
os.path.join(settings.STATIC_ROOT,
|
os.path.join(settings.STATIC_ROOT, 'node_modules/katex/dist/fonts')],
|
||||||
'node_modules/katex/dist/fonts')],
|
stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
CSS_FILES = [
|
CSS_FILES = [
|
||||||
'node_modules/perfect-scrollbar/css/perfect-scrollbar.css',
|
'node_modules/perfect-scrollbar/css/perfect-scrollbar.css',
|
||||||
|
@ -85,35 +75,34 @@ CSS_FILES = [
|
||||||
|
|
||||||
# Copy CSS files in node_modules to prod-static/serve
|
# Copy CSS files in node_modules to prod-static/serve
|
||||||
for css_file in CSS_FILES:
|
for css_file in CSS_FILES:
|
||||||
subprocess.check_call(['cp', '--parents', css_file, settings.STATIC_ROOT])
|
run(['cp', '--parents', css_file, settings.STATIC_ROOT])
|
||||||
|
|
||||||
# Collect the files that we're going to serve; this creates prod-static/serve.
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
||||||
subprocess.check_call(['./manage.py', 'collectstatic', '--no-default-ignore',
|
run(['./manage.py', 'collectstatic', '--no-default-ignore',
|
||||||
'--noinput', '-i', 'assets', '-i' 'node_modules'],
|
'--noinput', '-i', 'assets', '-i' 'node_modules'],
|
||||||
stdout=fp, stderr=fp)
|
stdout=fp, stderr=fp)
|
||||||
|
|
||||||
if not settings.PRODUCTION:
|
if not settings.PRODUCTION:
|
||||||
# When building a release tarball, we need to move staticfiles.json
|
# When building a release tarball, we need to move staticfiles.json
|
||||||
subprocess.check_call(['mv', 'prod-static/serve/staticfiles.json', 'staticfiles.json'],
|
run(['mv', 'prod-static/serve/staticfiles.json', 'staticfiles.json'],
|
||||||
stdout=fp, stderr=fp)
|
stdout=fp, stderr=fp)
|
||||||
|
|
||||||
# Compile translation strings to generate `.mo` files.
|
# Compile translation strings to generate `.mo` files.
|
||||||
subprocess.check_call(['./manage.py', 'compilemessages'],
|
run(['./manage.py', 'compilemessages'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Move the source maps out of the serve/ directory and into their
|
# Move the source maps out of the serve/ directory and into their
|
||||||
# proper place.
|
# proper place.
|
||||||
subprocess.check_call(['rm', '-rf', 'prod-static/source-map'],
|
run(['rm', '-rf', 'prod-static/source-map'], stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
subprocess.check_call(['mkdir', '-p', 'prod-static'], # Needed if PRODUCTION
|
# Needed if PRODUCTION
|
||||||
stdout=fp, stderr=fp)
|
run(['mkdir', '-p', 'prod-static'], stdout=fp, stderr=fp)
|
||||||
subprocess.check_call(['mv', os.path.join(settings.STATIC_ROOT, 'source-map'),
|
|
||||||
'prod-static/source-map'],
|
run(['mv', os.path.join(settings.STATIC_ROOT, 'source-map'), 'prod-static/source-map'],
|
||||||
stdout=fp, stderr=fp)
|
stdout=fp, stderr=fp)
|
||||||
|
|
||||||
# Move language_options.json to the production release
|
# Move language_options.json to the production release
|
||||||
subprocess.check_call(['cp', '-aT', 'static/locale',
|
run(['cp', '-aT', 'static/locale', os.path.join(settings.STATIC_ROOT, 'locale')],
|
||||||
os.path.join(settings.STATIC_ROOT, 'locale')],
|
stdout=fp, stderr=fp)
|
||||||
stdout=fp, stderr=fp)
|
|
||||||
|
|
||||||
# Generate /team page markdown for authors
|
# Generate /team page markdown for authors
|
||||||
authors_cmd = ['./tools/update-authors-json']
|
authors_cmd = ['./tools/update-authors-json']
|
||||||
|
@ -121,6 +110,6 @@ if os.environ.get("TRAVIS"):
|
||||||
authors_cmd.append("--use-fixture")
|
authors_cmd.append("--use-fixture")
|
||||||
if args.authors_not_required:
|
if args.authors_not_required:
|
||||||
authors_cmd.append("--not-required")
|
authors_cmd.append("--not-required")
|
||||||
subprocess.check_call(authors_cmd, stdout=fp, stderr=fp)
|
run(authors_cmd, stdout=fp, stderr=fp)
|
||||||
|
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
Loading…
Reference in New Issue