From 4a397972fad993cfdf7f6d9c6f20146734d16f4e Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 10:33:42 -0400 Subject: [PATCH 1/8] Sort the css and js assets by numerical index --- common/lib/rooted_paths.py | 2 +- common/lib/xmodule/xmodule/static_content.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/rooted_paths.py b/common/lib/rooted_paths.py index 9084768639..3339d6471d 100644 --- a/common/lib/rooted_paths.py +++ b/common/lib/rooted_paths.py @@ -8,7 +8,7 @@ def rooted_glob(root, glob): Uses glob2 globbing """ - return remove_root(root, glob2.glob('{root}/{glob}'.format(root=root, glob=glob))) + return remove_root(root, sorted(glob2.glob('{root}/{glob}'.format(root=root, glob=glob)))) def remove_root(root, paths): diff --git a/common/lib/xmodule/xmodule/static_content.py b/common/lib/xmodule/xmodule/static_content.py index c110d310eb..f433a9d6c9 100755 --- a/common/lib/xmodule/xmodule/static_content.py +++ b/common/lib/xmodule/xmodule/static_content.py @@ -68,7 +68,7 @@ def _write_styles(selector, output_root, classes): css_fragments[idx, filetype, fragment].add(class_.__name__) css_imports = defaultdict(set) for (idx, filetype, fragment), classes in sorted(css_fragments.items()): - fragment_name = "{idx}-{hash}.{type}".format( + fragment_name = "{idx:0=3d}-{hash}.{type}".format( idx=idx, hash=hashlib.md5(fragment).hexdigest(), type=filetype) @@ -102,7 +102,7 @@ def _write_js(output_root, classes): module_js = [] for idx, filetype, fragment in sorted(js_fragments): - path = output_root / "{idx}-{hash}.{type}".format( + path = output_root / "{idx:0=3d}-{hash}.{type}".format( idx=idx, hash=hashlib.md5(fragment).hexdigest(), type=filetype) From fb28384de728e090eb359c02cdaa87b9041e0730 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 13:17:45 -0400 Subject: [PATCH 2/8] Use local install of coffee --- rakefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rakefile b/rakefile index 1f60a18486..fb9fcd833b 100644 --- a/rakefile +++ b/rakefile @@ -93,7 +93,7 @@ end def template_jasmine_runner(lib) coffee_files = Dir["#{lib}/**/js/**/*.coffee", "common/static/coffee/src/**/*.coffee"] if !coffee_files.empty? - sh("coffee -c #{coffee_files.join(' ')}") + sh("node_modules/.bin/coffee -c #{coffee_files.join(' ')}") end phantom_jasmine_path = File.expand_path("common/test/phantom-jasmine") common_js_root = File.expand_path("common/static/js") @@ -128,7 +128,7 @@ def compile_assets(watch=false, debug=false) --command='#{xmodule_cmd}' \ common/lib/xmodule" end - coffee_cmd = "coffee #{watch ? '--watch' : ''} --compile */static" + coffee_cmd = "node_modules/.bin/coffee #{watch ? '--watch' : ''} --compile */static" sass_cmd = "sass #{debug ? '--debug-info' : '--style compressed'} " + "--load-path ./common/static/sass " + "--require ./common/static/sass/bourbon/lib/bourbon.rb " + @@ -155,6 +155,20 @@ default_options = { :cms => '8001', } +task :install_prereqs => [:install_node_prereqs, :install_ruby_prereqs, :install_python_prereqs] + +task :install_node_prereqs do + sh('npm install') +end + +task :install_ruby_prereqs do + sh('bundle install') +end + +task :install_python_prereqs do + sh('pip install -r requirements.txt') +end + task :predjango do sh("find . -type f -name *.pyc -delete") sh('pip install -q --no-index -r local-requirements.txt') From 7e07b951b0a892bc962edfa227059ce24f2db89b Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 13:42:41 -0400 Subject: [PATCH 3/8] Ignore the node_modules directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8fb170c30f..87a0778a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ cover_html/ chromedriver.log /nbproject ghostdriver.log +node_modules From 8dc0df3e6b521e4ae01a195cdd83722f3d1eb9d3 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 15:24:16 -0400 Subject: [PATCH 4/8] Don't ignore the old directories for xmodule sass and coffeescript --- cms/static/coffee/.gitignore | 2 -- cms/static/sass/.gitignore | 2 -- lms/static/coffee/.gitignore | 1 - lms/static/sass/.gitignore | 1 - 4 files changed, 6 deletions(-) diff --git a/cms/static/coffee/.gitignore b/cms/static/coffee/.gitignore index e114474f98..a6c7c2852d 100644 --- a/cms/static/coffee/.gitignore +++ b/cms/static/coffee/.gitignore @@ -1,3 +1 @@ *.js -descriptor -module diff --git a/cms/static/sass/.gitignore b/cms/static/sass/.gitignore index 62a745a9d7..b3a5267117 100644 --- a/cms/static/sass/.gitignore +++ b/cms/static/sass/.gitignore @@ -1,3 +1 @@ *.css -descriptor -module diff --git a/lms/static/coffee/.gitignore b/lms/static/coffee/.gitignore index bb90193362..a6c7c2852d 100644 --- a/lms/static/coffee/.gitignore +++ b/lms/static/coffee/.gitignore @@ -1,2 +1 @@ *.js -module diff --git a/lms/static/sass/.gitignore b/lms/static/sass/.gitignore index c8578e8cd3..b3a5267117 100644 --- a/lms/static/sass/.gitignore +++ b/lms/static/sass/.gitignore @@ -1,2 +1 @@ *.css -module From a2aacce2441b677dce9a9c218fb7fa1aefe9baf9 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 15:24:33 -0400 Subject: [PATCH 5/8] Fail hard if one of the asset compilation steps fails --- rakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rakefile b/rakefile index fb9fcd833b..cd1349373d 100644 --- a/rakefile +++ b/rakefile @@ -142,6 +142,9 @@ def compile_assets(watch=false, debug=false) puts "Waiting for `#{cmd}` to complete (pid #{pid})" Process.wait(pid) puts "Completed" + if !$?.exited? || $?.exitstatus != 0 + abort "`#{cmd}` failed" + end end end end From b4e9de67e033cf0016c1d81e39d1ed9e69ee2590 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 15:24:46 -0400 Subject: [PATCH 6/8] Add docs to the prereqs rake commands --- rakefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rakefile b/rakefile index cd1349373d..766dd8a914 100644 --- a/rakefile +++ b/rakefile @@ -158,16 +158,20 @@ default_options = { :cms => '8001', } +desc "Install all prerequisites needed for the lms and cms" task :install_prereqs => [:install_node_prereqs, :install_ruby_prereqs, :install_python_prereqs] +desc "Install all node prerequisites for the lms and cms" task :install_node_prereqs do sh('npm install') end +desc "Install all ruby prerequisites for the lms and cms" task :install_ruby_prereqs do sh('bundle install') end +desc "Install all python prerequisites for the lms and cms" task :install_python_prereqs do sh('pip install -r requirements.txt') end From 436d95bfabe579537152c99ab3bfa5fcc53d4b05 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 15:25:13 -0400 Subject: [PATCH 7/8] Make tests install coffee locally --- jenkins/test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jenkins/test.sh b/jenkins/test.sh index e1d44bf6b5..53643b8440 100755 --- a/jenkins/test.sh +++ b/jenkins/test.sh @@ -40,6 +40,8 @@ yes w | pip install -q -r requirements.txt bundle install +npm install + rake clobber rake pep8 > pep8.log || cat pep8.log rake pylint > pylint.log || cat pylint.log From 8c4526ed07d658125ff8984fa8df488c3734a931 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 26 Apr 2013 16:52:39 -0400 Subject: [PATCH 8/8] Fix coffeescript error in video spec file --- .../xmodule/js/spec/video/display/video_player_spec.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee b/common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee index d59e936b8c..b6c562c88a 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/video/display/video_player_spec.coffee @@ -37,7 +37,7 @@ xdescribe 'VideoPlayer', -> expect(window.VideoProgressSlider).toHaveBeenCalledWith el: $('.slider', @player.el) it 'create Youtube player', -> - expect(YT.Player).toHaveBeenCalledWith 'example' + expect(YT.Player).toHaveBeenCalledWith('example', { playerVars: controls: 0 wmode: 'transparent' @@ -48,6 +48,7 @@ xdescribe 'VideoPlayer', -> events: onReady: @player.onReady onStateChange: @player.onStateChange + }) it 'bind to video control play event', -> expect($(@player.control)).toHandleWith 'play', @player.play