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

(Partially) Fix #2100: add cache slugs. #2208

Merged
merged 34 commits into from
Jul 23, 2016

Conversation

gvishal
Copy link
Contributor

@gvishal gvishal commented Jul 2, 2016

Fix #2100: add cache slugs for.

/cc @seanlip @BenHenning @maitbayev

@codecov-io
Copy link

codecov-io commented Jul 2, 2016

Current coverage is 48.00% (diff: 15.46%)

Merging #2208 into develop will increase coverage by <.01%

@@            develop      #2208   diff @@
==========================================
  Files           185        190     +5   
  Lines         15852      15914    +62   
  Methods        2720       2733    +13   
  Messages          0          0          
  Branches       2689       2693     +4   
==========================================
+ Hits           7609       7639    +30   
- Misses         8243       8275    +32   
  Partials          0          0          

Powered by Codecov. Last update e8a2de2...3b83d27

@@ -14,3 +14,7 @@ venv/
.DS_Store
.idea
.vagrant/*

# required for cache slugs
Copy link
Member

Choose a reason for hiding this comment

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

I think you can add more detail to this comment -- please give enough detail so that someone who is not familiar with all our discussions knows what's going on. It's OK for the comment to span multiple lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

@seanlip
Copy link
Member

seanlip commented Jul 3, 2016

Hi @gvishal, this is a good first pass; I've made some comments. Let me know if anything's unclear!

One question: did you run the backend tests at all before you committed -- or test this manually? The Travis checks all seem to be failing. I would strongly advise at least testing things manually before you submit a PR; it helps you fix accidental errors.

…e level html files and corresponding directives/controllers to use it, addressed review comments
@gvishal
Copy link
Contributor Author

gvishal commented Jul 3, 2016

@seanlip those tests failed since cache_slug was defined outside get_cache_slug() and it was working fine locally AFAIR despite not marking it global, fixed that error now. PTAL!

@gvishal gvishal changed the title (Partially) Fix #2100: add cache slugs for images. (Partially) Fix #2100: add cache slugs for images and scripts. Jul 3, 2016
@gvishal gvishal changed the title (Partially) Fix #2100: add cache slugs for images and scripts. (Partially) Fix #2100: add cache slugs. Jul 3, 2016
# Oppia uses cache slugs for various resources and we need separate resource
# directories for dev and prod. Resource directories for prod are generated
# via build.py and should not be committed to the repo.
static/prod
Copy link
Contributor

Choose a reason for hiding this comment

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

add TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already there in build.py.

@gvishal
Copy link
Contributor Author

gvishal commented Jul 9, 2016

@bbriggs @wxyxinyu I implemented a basic POC for the new approach. PTAL! Thanks!

@bbriggs
Copy link
Contributor

bbriggs commented Jul 11, 2016

Still reviewing. Lots of changes to catch up on.

var generatedTargetDir = path.join(
'third_party', 'generated',
isMinificationNeeded ? 'prod' : 'dev');
isMinificationNeeded ? 'prod' : cacheSlugDev);
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about this. This refers to the files generated in /third_party/generated. I don't see why anything needs to change here, nor what it has to do with the cache slug?

Copy link
Contributor Author

@gvishal gvishal Jul 21, 2016

Choose a reason for hiding this comment

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

This is because we need to make it uniform to use cache slugs. eg. Right now we have urls like /third_party/generated/css/file.css else we'll have /third_party/generated/dev/css/file.css, which is a problem.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry -- I seem to have missed this comment, or read an older version of it.

Yep, sounds like there's a good reason for this. Can you add a (long) comment explaining in detail why we choose '' (to someone who's never heard of cache slugs)? That would make this more maintainable going forward.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@seanlip
Copy link
Member

seanlip commented Jul 21, 2016

Hi Vishal, I did a fairly careful check of this, and I also ran it with --prod_env. It looks generally good, I have a bunch of comments which I've noted inline.

Two other issues:

  • You'll need to resolve the lint issues, as discussed on chat.
  • If you run with --prod_env and go to the splash page on chrome, you'll find that the buttons look weird -- they're pushed off to the left. I tracked the issue down to CSS minification -- it appears that calc(50% + 200px) is a valid CSS value but calc(50%+200px) (without the spaces) is not. Could you adjust the CSS minification to fix this?

Also, I noticed some other issues like missing images for interactions and gadgets. Please make sure you test your work by going to the various pages and making sure that things load properly -- don't depend on the reviewer to find them. I may well have missed others. If you want to be thorough, also look at the requests that are being made to the server (in the terminal), and make sure that they're going to the right places; make a note as well of the still-uncached ones, since this is what you'll need to fix in the next stage.

Thanks!

Also, /cc @BenHenning for info.

@gvishal
Copy link
Contributor Author

gvishal commented Jul 21, 2016

@seanlip For the css issue we can do double math. See: yui/yuicompressor#59 (comment). Or, write a custom fn which modifies the minified css See: yui/yuicompressor#59 (comment)

@seanlip
Copy link
Member

seanlip commented Jul 21, 2016

Hi @gvishal, replied to your comments!

Re the CSS issue, let's do double math for now. Could you please fix that in your PR, and also add a comment to reference the YUI thread in each of the places where you do double math? Thanks!

var generatedTargetDir = path.join(
'third_party', 'generated',
isMinificationNeeded ? 'prod' : cacheSlugDev);
isMinificationNeeded ? 'prod' : '');
Copy link
Member

@seanlip seanlip Jul 21, 2016

Choose a reason for hiding this comment

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

Why not keep as 'dev' (like it was before)? Otherwise you kind of end up with a weird dir structure: prod becomes a sibling of css, fonts, js.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, ignore. Wrote this before seeing your other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

@@ -325,5 +325,6 @@ <h2 class="activity-title protractor-test-exp-summary-tile-title">
{{ include_js_file('components/SharingLinksDirective.js') }}
{{ include_js_file('dashboard/Dashboard.js') }}
{{ include_js_file('domain/dashboard/DashboardBackendApiService.js') }}
{{ include_js_file('domain/utilities/UrlInterpolationService.js') }}
Copy link
Member

Choose a reason for hiding this comment

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

@gvishal I thought you were dropping this import from this and all other pages where it isn't needed?

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.

@seanlip
Copy link
Member

seanlip commented Jul 22, 2016

Just one comment, but otherwise this looks ready for merge. Two things:

(a) did you test the new CSS on prod, and does it look correct?
(b) did you figure out the lint issue?

Thanks!

@gvishal
Copy link
Contributor Author

gvishal commented Jul 22, 2016

  1. Css works fine.
  2. It's the js files wherein the linter is failing. Log: http://pastebin.com/rJa1XqGj.

Update: The linter is successfully able to lint both py + js files, but gets stuck processing scripts/gulp-start-gae-devserver.js. Probably waiting for the processes to return. See: https://gist.github.com/gvishal/268f43b01646aefe816d68e25031cfd6

@seanlip
Copy link
Member

seanlip commented Jul 22, 2016

Aha. You could set the linter to ignore the build/ directory? There's no
need to lint generated files.

As a note, in develop, there should only be around 244 files to lint.

On Friday, July 22, 2016, Vishal Gupta notifications@github.com wrote:

  1. Css works fine.
  2. Linter gets stuck processing files from 251 to 291. Log:
    http://pastebin.com/rJa1XqGj


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2208 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AKFeyoFPArcAfWrnBSehjXrahLw7NxBMks5qYMbagaJpZM4JDv96
.

@gvishal
Copy link
Contributor Author

gvishal commented Jul 22, 2016

I was thinking about the same thing, but build/ wouldn't be generated on travis would it?

Also, there are 339 js files in my branch.

Here's travis logs for pylint on a separate PR: https://travis-ci.org/oppia/oppia/jobs/146661059

It's an issue with waiting for threads to return.

@seanlip
Copy link
Member

seanlip commented Jul 22, 2016

Hm, yeah, I don't know why build/ is being generated on travis. Also good call, I was only referring to py files when I said 244.

Not sure why the js files are causing issues. Is it the same file each time? What if you run lint on only that file in isolation? (Not sure if it's the specific file, or the number of files, that's the problem.)

@seanlip
Copy link
Member

seanlip commented Jul 23, 2016

LGTM. Let's hope the travis checks pass, and then we can merge this!

@seanlip seanlip merged commit 3adb944 into oppia:develop Jul 23, 2016
@gvishal gvishal mentioned this pull request Jul 23, 2016
wxyxinyu pushed a commit that referenced this pull request Aug 8, 2016
* Added cache slugs for images and modified all references to the images.

* Added interpolation service to get static image url, modified non-page level html files and corresponding directives/controllers to use it, addressed review comments

* Modified /script tags

* Added cache slugs for i18n

* Fixed failing test and added i18n/prod to git ignore.

* Cache slugs new approach POC

* Modified references for images, scripts and i18n.
Added methods to return static resource url.
Modified app.yaml.

* Modified gulp file and references to oppia.css and third_party css and js files.

* Added slugs to extensions

* Fixed test for get_cache_slug

* Modified build.py and deploy.py

* Addressed review comments

* Modify imports

* Modified src to ng-src and other review comments fixed.

* Modified build.py

* Minor change

* Removed feconf.CACHE_SLUG_DEV and refactored

* Added random cache slug

* Refactored code.

* Modified references for extensions, added extensions to build process and refactored methods in UrlInterpolationService

* Fixed bug

* Addressed review comments.

* Fix failing tests

* Fixed bug.

* Added tests for urlinterpolationservice.

* Added interpolation for interactions and logic_proof.html

* Addressed review comments

* Addressed review comments

* Removed unnecessary include from templates

* Modified precommit linter script to fix endless waiting

* Commented script and added assets/scripts to exclusions.
ctao5660 pushed a commit to ctao5660/oppia that referenced this pull request Nov 23, 2018
* Added cache slugs for images and modified all references to the images.

* Added interpolation service to get static image url, modified non-page level html files and corresponding directives/controllers to use it, addressed review comments

* Modified /script tags

* Added cache slugs for i18n

* Fixed failing test and added i18n/prod to git ignore.

* Cache slugs new approach POC

* Modified references for images, scripts and i18n.
Added methods to return static resource url.
Modified app.yaml.

* Modified gulp file and references to oppia.css and third_party css and js files.

* Added slugs to extensions

* Fixed test for get_cache_slug

* Modified build.py and deploy.py

* Addressed review comments

* Modify imports

* Modified src to ng-src and other review comments fixed.

* Modified build.py

* Minor change

* Removed feconf.CACHE_SLUG_DEV and refactored

* Added random cache slug

* Refactored code.

* Modified references for extensions, added extensions to build process and refactored methods in UrlInterpolationService

* Fixed bug

* Addressed review comments.

* Fix failing tests

* Fixed bug.

* Added tests for urlinterpolationservice.

* Added interpolation for interactions and logic_proof.html

* Addressed review comments

* Addressed review comments

* Removed unnecessary include from templates

* Modified precommit linter script to fix endless waiting

* Commented script and added assets/scripts to exclusions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants