canvas-lms/script/canvas_update

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

97 lines
1.9 KiB
Plaintext
Raw Normal View History

#!/bin/bash
source script/common/utils/common.sh
source script/common/canvas/build_helpers.sh
LOG="$(pwd)/log/canvas_update.log"
# TODO: improve usage / help
function usage {
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
echo "usage: canvas_update [-qhv] [-n phase]"
}
function bad_usage {
usage
exit 1
}
# TODO: moar tips plz
function tips {
echo "Tips:"
echo " - 'bundle exec guard': auto-compiles JS files while developing"
echo " - 'script/delayed_job run': run delayed jobs in the foreground"
}
function update_canvas {
ensure_in_canvas_root_directory
message "Bringing Canvas up to date ..."
init_log_file "Canvas Update"
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
if [[ -z "$SKIP_CODE" ]] ; then
./script/rebase_canvas_and_plugins.sh
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
fi
if [[ -z "$SKIP_DEPS" ]] ; then
bundle_install_with_check
install_node_packages
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
fi
if [[ -z "$SKIP_DATA" ]] ; then
rake_db_migrate_dev_and_test
# skip if QUICK_MODE
if ! $QUICK_MODE; then
compile_assets
fi
fi
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
# We should only display tips if this script is being run standalone
if [[ -n "$SKIP_CODE" && -n "$SKIP_DEPS" && -n "$SKIP_DATA" ]] ; then
tips
fi
}
# default options
PERFORM_UPDATE=true
QUICK_MODE=false
# parse options
# http://www.tldp.org/LDP/abs/html/internal.html#EX33
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
while getopts ":qhn:v" Option
do
case $Option in
q )
echo "Quick mode enabled (assumes you have guard running and don't want to generate docs)"
QUICK_MODE=true;;
h )
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
usage
exit 0;;
n )
case $OPTARG in
code )
SKIP_CODE=true;;
deps )
SKIP_DEPS=true;;
data )
SKIP_DATA=true;;
assets )
QUICK_MODE=true;;
* )
bad_usage;;
esac
echo "Skipping $OPTARG";;
v )
set -x
LOG=/dev/stdout;;
* )
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
echo "Sorry, -$OPTARG is not a valid option!"
bad_usage;;
esac
done
if [ "$PERFORM_UPDATE" == "true" ]; then
trap trap_result INT TERM EXIT
create_log_file
Match services docker workflow. Fixes OUT-2367 There are now two scripts: - docker_dev_setup.sh: will create / recreate the service and all databases locally - docker_dev_update.sh: can be used to migrate the local master branch. Will also pull plugin changes and run the relevant migrations. Both scripts now directly use parts of canvas_update under the hood, which will hopefully make future workflow changes less painful. Test Plan: - With docker: - optional: create a new canvas checkout (you can use a different directory name to avoid destroying your current database) - git fetch - check out this gerrit, and use `git checkout -b 2367` to create a branch for it - git checkout origin/master~200 - git checkout 2367 -- script - ./script/docker_dev_setup.sh (follow all prompts) - docker-compose up -d - login, accept the terms of use - docker-compose down - git checkout master - ./script/docker_dev_update.sh -n code - docker-compose up -d - login, verify you are not asked for terms of use and the school name is the same as before. - docker-compose down - ./script/docker_dev_setup.sh again (nuke the old database, change the root account name) - docker-compose up -d - login, accept the terms of use, verify the new account name Change-Id: Ie40600d7ea1e90633d9139b4cc1cf853695ac8f8 Reviewed-on: https://gerrit.instructure.com/151547 Tested-by: Jenkins Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> Reviewed-by: Augusto Callejas <acallejas@instructure.com> QA-Review: Dariusz Dzien <ddzien@instructure.com> Product-Review: Neil Gupta <ngupta@instructure.com>
2018-05-26 03:01:25 +08:00
update_canvas
fi