From 5f712b960fa687f33e836cd19979b793e15d9fd5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 18 Jul 2019 14:39:36 -0700 Subject: [PATCH] update-authors-json: Write to static, not STATIC_ROOT. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the file isn’t processed by collectstatic and doesn’t end up in the staticfiles.json manifest. Signed-off-by: Anders Kaseorg --- tools/update-authors-json | 8 ++------ tools/update-prod-static | 16 ++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/update-authors-json b/tools/update-authors-json index f38ebc2a52..ff144e91da 100755 --- a/tools/update-authors-json +++ b/tools/update-authors-json @@ -21,10 +21,6 @@ from datetime import date import requests import json -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) -os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings' -from django.conf import settings - FIXTURE_FILE = os.path.join(os.path.dirname(__file__), '../zerver/tests/fixtures/authors.json') duplicate_commits_file = os.path.join(os.path.dirname(__file__), '../zerver/tests/fixtures/duplicate_commits.json') @@ -144,7 +140,7 @@ def run_production() -> None: contributor_data['name'] = contributor_name data['contrib'].append(contributor_data) - write_to_disk(data, settings.CONTRIBUTORS_DATA) + write_to_disk(data, 'static/generated/github-contributors.json') def copy_fixture() -> None: @@ -152,7 +148,7 @@ def copy_fixture() -> None: Copy test fixture file from zerver/tests/fixtures. This is used to avoid constantly fetching data from Github during testing. """ - shutil.copyfile(FIXTURE_FILE, settings.CONTRIBUTORS_DATA) + shutil.copyfile(FIXTURE_FILE, 'static/generated/github-contributors.json') if args.use_fixture: diff --git a/tools/update-prod-static b/tools/update-prod-static index 8d0a304a64..6d633b0f35 100755 --- a/tools/update-prod-static +++ b/tools/update-prod-static @@ -52,6 +52,14 @@ run(['./tools/setup/build_pygments_data'], stdout=fp, stderr=fp) # Create webpack bundle run(['./tools/webpack'], stdout=fp, stderr=fp) +# Generate /team page markdown for authors +authors_cmd = ['./tools/update-authors-json'] +if os.environ.get("TRAVIS"): + authors_cmd.append("--use-fixture") +if args.authors_not_required: + authors_cmd.append("--not-required") +run(authors_cmd, stdout=fp, stderr=fp) + # Collect the files that we're going to serve; this creates prod-static/serve. run(['./manage.py', 'collectstatic', '--no-default-ignore', '--noinput', '-i', 'assets', '-i', 'js', '-i', 'styles', '-i', 'templates'], @@ -67,12 +75,4 @@ run(['./manage.py', 'compilemessages'], stdout=fp, stderr=fp) # Needed if PRODUCTION os.makedirs('prod-static', exist_ok=True) -# Generate /team page markdown for authors -authors_cmd = ['./tools/update-authors-json'] -if os.environ.get("TRAVIS"): - authors_cmd.append("--use-fixture") -if args.authors_not_required: - authors_cmd.append("--not-required") -run(authors_cmd, stdout=fp, stderr=fp) - fp.close()