diff --git a/.gitignore b/.gitignore index dde5a397c5..76cc1efa95 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ ghostdriver.log node_modules .pip_download_cache/ .prereqs_cache +autodeploy.properties +.ws_migrations_complete diff --git a/rakefiles/prereqs.rake b/rakefiles/prereqs.rake index 7bd1940b4c..430e650127 100644 --- a/rakefiles/prereqs.rake +++ b/rakefiles/prereqs.rake @@ -11,21 +11,21 @@ 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 +task :install_node_prereqs => "ws:migrate" do when_changed('package.json') do sh('npm install') end unless ENV['NO_PREREQ_INSTALL'] end desc "Install all ruby prerequisites for the lms and cms" -task :install_ruby_prereqs do +task :install_ruby_prereqs => "ws:migrate" do when_changed('Gemfile') do sh('bundle install') end unless ENV['NO_PREREQ_INSTALL'] end desc "Install all python prerequisites for the lms and cms" -task :install_python_prereqs do +task :install_python_prereqs => "ws:migrate" do when_changed('requirements/**') do ENV['PIP_DOWNLOAD_CACHE'] ||= '.pip_download_cache' sh('pip install --exists-action w -r requirements/base.txt') diff --git a/rakefiles/workspace.rake b/rakefiles/workspace.rake new file mode 100644 index 0000000000..c705899f58 --- /dev/null +++ b/rakefiles/workspace.rake @@ -0,0 +1,16 @@ +MIGRATION_MARKER_DIR = File.join(REPO_ROOT, '.ws_migrations_complete') +SKIP_MIGRATIONS = ENV['SKIP_WS_MIGRATIONS'] || false + +directory MIGRATION_MARKER_DIR + +namespace :ws do + task :migrate => MIGRATION_MARKER_DIR do + Dir['ws_migrations/*'].select{|m| File.executable?(m)}.each do |migration| + completion_file = File.join(MIGRATION_MARKER_DIR, File.basename(migration)) + if ! File.exist?(completion_file) + sh(migration) + File.write(completion_file, "") + end + end unless SKIP_MIGRATIONS + end +end \ No newline at end of file diff --git a/ws_migrations/README.rst b/ws_migrations/README.rst new file mode 100644 index 0000000000..c952a25c7b --- /dev/null +++ b/ws_migrations/README.rst @@ -0,0 +1,29 @@ +Developer Workspace Migrations +============================== + +This directory contains executable files which run once prior to +installation of pre-requisites to bring a developers workspace +into line. + +Specifications +-------------- + +Each file in this directory should meet the following criteria + +* Executable (`chmod +x ws_migrations/foo.sh`) +* Idempotent (ideally, each script is run only once, but no + guarantees are made by the caller, so the script must do + the right thing) +* Either fast or verbose (if the script is going to take + a long time, it should notify the user of that) +* A comment at the top of the file explaining the migration + +Execution +--------- + +The scripts are run by the rake task `ws:migrate`. That task +only runs a given script if a corresponding marker file +in .completed-ws-migrations doesn't already exist. + +If the SKIP_WS_MIGRATIONS environment variable is set, then +no workspace migrations will be run. \ No newline at end of file diff --git a/ws_migrations/clean_xmodule_assets.sh b/ws_migrations/clean_xmodule_assets.sh new file mode 100755 index 0000000000..ebda0fda55 --- /dev/null +++ b/ws_migrations/clean_xmodule_assets.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +# Remove all of the old xmodule coffee and sass directories +# in preparation to switching to use the xmodule_assets script + +rm -rf cms/static/coffee/descriptor +rm -rf cms/static/coffee/module +rm -rf cms/static/sass/descriptor +rm -rf cms/static/sass/module +rm -rf lms/static/coffee/module +rm -rf lms/static/sass/module