Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve static pages from app.yaml #6974

Merged
merged 22 commits into from
Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0bc53bb
create render template method
jameesjohn Jun 19, 2019
df266a2
address review comments
jameesjohn Jun 21, 2019
8b63d34
Merge branch 'develop' of https://github.com/oppia/oppia into static-…
jameesjohn Jun 21, 2019
9106197
address review comments
jameesjohn Jun 21, 2019
6d2cdb9
fix error due to merge
jameesjohn Jun 21, 2019
77fc41d
address review comments
jameesjohn Jun 22, 2019
e3f24b7
serve statics files from app.yaml
jameesjohn Jun 23, 2019
fff201a
address review comments
jameesjohn Jun 24, 2019
9baa459
more on review comments and test issue
jameesjohn Jun 24, 2019
3458a6b
Merge branch 'develop' of https://github.com/oppia/oppia into static-…
jameesjohn Jun 29, 2019
6df30d8
add hases to files in app.yaml
jameesjohn Jun 29, 2019
a209b4e
Merge branch 'develop' of https://github.com/oppia/oppia into static-…
jameesjohn Jul 2, 2019
7ccbf19
create dev app.yaml and prod app.yaml as well as write tests for the …
jameesjohn Jul 3, 2019
04bd338
address review comments and revert package-lock.json
jameesjohn Jul 3, 2019
f27d23b
address review comments
jameesjohn Jul 4, 2019
c6617b5
revert change in constants
jameesjohn Jul 4, 2019
81922b9
remove app.yaml
jameesjohn Jul 4, 2019
9104bca
work on failing e2e tests
jameesjohn Jul 5, 2019
abddd81
fix lint issues
jameesjohn Jul 5, 2019
33c6f79
revert package-lock.json
jameesjohn Jul 5, 2019
d99be7c
Merge branch 'develop' of https://github.com/oppia/oppia into static-…
jameesjohn Jul 6, 2019
bd7eca5
remove other variants of splash page
jameesjohn Jul 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review comments
  • Loading branch information
jameesjohn committed Jul 4, 2019
commit f27d23b495dd6ec6954b3518704ce47976921bca
4 changes: 4 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# THIS FILE IS AUTOGENERATED, DO NOT MODIFY
runtime: python27
api_version: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our discussion, let's just have one app.yaml file in the codebase so that there's a single source of truth.

@vojtechjelinek FYI we discussed having a template file from which to generate dev/prod, but then we figured that it would be better to just have the "dev" version in the codebase (as we do now) and then do the changes needed to transform it to the "prod" version (like we do with other files/folders). This means that we only have one indirectly-generated file rather than two (which is better, since indirect pipelines like this often lead to errors).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanlip, should this file still be in the codebase?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so.

threadsafe: false
instance_class: F2
# The "version" line is added here so that MR jobs can run locally (see issue
# #6534 on oppia/oppia).


builtins:
- appstats: on
Expand Down
2 changes: 1 addition & 1 deletion assets/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,5 +587,5 @@ var constants = {

"ALLOW_YAML_FILE_UPLOAD": false,

"DEV_MODE": true
"DEV_MODE": false
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<base-content>
<content>
<div class="oppia-static-header">
<h1 translate="I18N_GET_STARTED_PAGE_HEADING"></h1>
<h1 translate="I18N_GET_STARTED_PAGE_HEADING" class="protractor-test-get-started-page"></h1>
</div>
<background-banner></background-banner>
<div class="oppia-page-card oppia-static-content oppia-static-content-below-banner">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<base-content>
<content>
<splash-page></splash-page>
<splash-page class="protractor-test-splash-page"></splash-page>
</content>
</base-content>

Expand Down
2 changes: 1 addition & 1 deletion core/templates/dev/head/pages/splash-page/splash_at0.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<base-content>
<content>
<div ng-controller="Splash">
<div ng-controller="Splash" class="protractor-test-splash-page">
<div class="oppia-splash-section-one text-center">
<h1 class="oppia-splash-h1" style="max-width: 800px; font-size: 2.3em; line-height: 1.5em; padding-bottom: 0.5em;">Lesson plans aren't just for the schoolday</h1>

Expand Down
2 changes: 1 addition & 1 deletion core/templates/dev/head/pages/splash-page/splash_at1.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<base-content>
<content>
<div ng-controller="Splash">
<div ng-controller="Splash" class="protractor-test-splash-page">
<div class="oppia-splash-section-one text-center">
<h1 class="oppia-splash-h1" style="max-width: 800px; font-size: 2.3em; line-height: 1.5em; padding-bottom: 0.5em;">Tired of the same lesson plans?</h1>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<base-content>
<navbar-breadcrumb>
<ul class="nav navbar-nav oppia-navbar-breadcrumb">
<ul class="nav navbar-nav oppia-navbar-breadcrumb protractor-test-teach-page">
<li>
<span class="oppia-navbar-breadcrumb-separator"></span>
Teach with Oppia
Expand Down
5 changes: 5 additions & 0 deletions core/tests/protractor_desktop/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,27 @@ describe('Oppia static pages tour', function() {
it('visits the Get started page', function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanlip, the tests are here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assert for something that should exist in the page (to make sure it's not serving a 404)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

browser.get('/get_started');
waitFor.pageToFullyLoad();
expect(element(by.css('.protractor-test-get-started-page'))).toBe(true);
});

it('visits the Teach page', function() {
browser.get('/teach');
waitFor.pageToFullyLoad();
expect(element(by.css('.protractor-test-teach-page'))).toBe(true);
});

it('visits the Splash pages', function() {
browser.get('/splash');
waitFor.pageToFullyLoad();
expect(element(by.css('.protractor-test-splash-page'))).toBe(true);

browser.get('/splash?c=at0');
waitFor.pageToFullyLoad();
expect(element(by.css('.protractor-test-splash-page'))).toBe(true);

browser.get('/splash?c=at1');
waitFor.pageToFullyLoad();
expect(element(by.css('.protractor-test-splash-page'))).toBe(true);
});

afterEach(function() {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
# hash).
# This is because these files don't need cache invalidation, are referenced
# from third party files or should not be moved to the build directory.
# Statically served pages from app.yaml should be here to since they don't
# need cache invalidation.
FILEPATHS_NOT_TO_RENAME = (
'*.py',
'third_party/generated/fonts/*',
Expand All @@ -127,6 +129,25 @@
HASH_BLOCK_SIZE = 2**20


def generate_app_yaml():
"""Generate app.yaml from app_dev.yaml."""
dev_file_prefix = 'core/templates/dev/head'
prod_file_prefix = 'build/templates/head'
content = '# THIS FILE IS AUTOGENERATED, DO NOT MODIFY\n'
with open('app_dev.yaml', 'r') as yaml_file:
content += yaml_file.read()
for file_path in FILEPATHS_NOT_TO_RENAME:
if '/dist/' in file_path:
content = content.replace(
dev_file_prefix + file_path[1:],
prod_file_prefix + file_path[1:])
content = content.replace('version: default', '')
if os.path.isfile('app.yaml'):
os.remove('app.yaml')
with open('app.yaml', 'w+') as prod_yaml_file:
prod_yaml_file.write(content)


def require_compiled_js_dir_to_be_valid():
"""Checks if COMPILED_JS_DIR matches the output directory used in
TSCONFIG_FILEPATH.
Expand Down Expand Up @@ -1307,6 +1328,7 @@ def build():
if options.prod_mode:
build_using_webpack()
minify_third_party_libs(THIRD_PARTY_GENERATED_DEV_DIR)
generate_app_yaml()
if not options.minify_third_party_libs_only:
generate_build_directory()

Expand Down
6 changes: 3 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ if [[ "$FORCE_PROD_MODE" == "True" ]]; then
constants_env_variable="\"DEV_MODE\": false"
sed -i.bak -e s/"\"DEV_MODE\": .*"/"$constants_env_variable"/ assets/constants.js
$PYTHON_CMD scripts/build.py --prod_env --enable_watcher
APP_YAML="app.yaml"
APP_YAML_FILEPATH="app.yaml"
else
constants_env_variable="\"DEV_MODE\": true"
sed -i.bak -e s/"\"DEV_MODE\": .*"/"$constants_env_variable"/ assets/constants.js
$PYTHON_CMD scripts/build.py --enable_watcher
APP_YAML="app_dev.yaml"
APP_YAML_FILEPATH="app_dev.yaml"
fi

# Delete the modified feconf.py file(-i.bak)
Expand All @@ -114,7 +114,7 @@ if ! [[ "$FORCE_PROD_MODE" == "True" ]]; then
($NODE_MODULE_DIR/webpack/bin/webpack.js --config webpack.dev.config.ts --watch)&
fi
echo Starting GAE development server
(python $GOOGLE_APP_ENGINE_HOME/dev_appserver.py $CLEAR_DATASTORE_ARG $ENABLE_CONSOLE_ARG --admin_host 0.0.0.0 --admin_port 8000 --host 0.0.0.0 --port 8181 --skip_sdk_update_check true $APP_YAML)&
(python $GOOGLE_APP_ENGINE_HOME/dev_appserver.py $CLEAR_DATASTORE_ARG $ENABLE_CONSOLE_ARG --admin_host 0.0.0.0 --admin_port 8000 --host 0.0.0.0 --port 8181 --skip_sdk_update_check true $APP_YAML_FILEPATH)&

# Wait for the servers to come up.
while ! nc -vz localhost 8181 >/dev/null 2>&1; do sleep 1; done
Expand Down