Add mechanism for running migrations of developer workspaces
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -38,3 +38,5 @@ ghostdriver.log
|
||||
node_modules
|
||||
.pip_download_cache/
|
||||
.prereqs_cache
|
||||
autodeploy.properties
|
||||
.ws_migrations_complete
|
||||
|
||||
@@ -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')
|
||||
|
||||
16
rakefiles/workspace.rake
Normal file
16
rakefiles/workspace.rake
Normal file
@@ -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
|
||||
29
ws_migrations/README.rst
Normal file
29
ws_migrations/README.rst
Normal file
@@ -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.
|
||||
11
ws_migrations/clean_xmodule_assets.sh
Executable file
11
ws_migrations/clean_xmodule_assets.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user