├── LICENSE.txt ├── README.md ├── bin └── mage-ci ├── composer.json └── installer /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EcomDev/MageCI/f41b07ee00160ba26d48ce39e21e7f871b355665/LICENSE.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Magento Continuous Integration Tools 2 | =================================== 3 | 4 | A set of tools to help set up 5 | a proper environment for testing magento 6 | 7 | Installation 8 | ------------ 9 | 10 | Installation is very easy though composer.json 11 | 12 | In your application or dependent library root directory, create a _composer.json_ file. 13 | In case you are not familiar with [Composer](http://getcomposer.org/), see [composer.json Schema](http://getcomposer.org/doc/04-schema.md). 14 | 15 | In the _require_ or alternatively in the _require-dev_ section, add the following dependency: 16 | 17 | "ecomdev/mage-ci": "dev-master" 18 | 19 | Usage 20 | ----- 21 | 22 | ### Running a batch of PHPUnit tests 23 | $ mage-ci phpunit 24 | Runs unit tests for all phpunit.xml or phpunit.dist.xml files in or its subdirectories. 25 | will be passed directly to phpunit binary. 26 | 27 | 28 | ### Installing a particular Magento version 29 | $ bin/mage-ci install 30 | Installs a Magento version to a specified destination 31 | -c Create databases flag 32 | -t Create test database flag (only in combination with -c option) 33 | -u DB Username 34 | -p DB Password 35 | -r SQL dumps repository url for a particular Magento version (/.sql.gz) 36 | -f SQL dump file, if you'd like to preinstall some data and specfied -c option 37 | 38 | ### Installing a Magento module 39 | $ bin/mage-ci install-module 40 | Installs a Magento module with modman definition 41 | 42 | ### Updating installed Magento modules 43 | $ bin/mage-ci update-modules 44 | Updates all installed modman modules at specified Magento instnace 45 | 46 | ### Uninstalling Magento version 47 | $ bin/mage-ci uninstall [] 48 | Performs uninstall of Magento instance 49 | -u DB Username 50 | -p DB Password 51 | 52 | ### Uninstalling Magento module 53 | $ bin/mage-ci uninstall-module 54 | Performs uninstall of Magento module from instance 55 | 56 | ### Mass Install of Magento versions 57 | $ bin/mage-ci install-multiple ... 58 | Installs multiple version of magento at in subdirectories which name is a combined value of - 59 | -d Directory where all downloads are stored 60 | -u DB Username 61 | -p DB Password 62 | -t Create test db as well 63 | -r SQL dumps repository url for a particular Magento version (/.sql.gz) 64 | 65 | ### Dump databases of existing installed versions 66 | $ bin/mage-ci db-dump ... 67 | Creates Magento database dump file at directory with name .sql.gz, the dumped database is _ 68 | -u DB Username 69 | -p DB Password 70 | -s sql file prefix 71 | 72 | 73 | Magento Clean DB Dumps 74 | ---------------------- 75 | 76 | It is possible to specify base url for downloading of database dump for a particular Magento version. 77 | Most of the time clean installation of Magento takes a lot of time, so it is nice to have this clean db dump prepared for each Magento version. 78 | 79 | We created such repository at the following url: 80 | http://mage-ci.ecomdev.org 81 | 82 | You just need to specify it during installation of process: 83 | 84 | $ bin/mage-ci install magento-1.7.0.2 1.7.0.2 mage_1.7.0.2 -r http://mage-ci.ecomdev.org 85 | 86 | This command will download db dump from the following URL: http://mage-ci.ecomdev.org/1.7.0.2.sql.gz 87 | 88 | -------------------------------------------------------------------------------- /bin/mage-ci: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Magento Continuous Integration Tools 4 | # 5 | # NOTICE OF LICENSE 6 | # 7 | # This source file is subject to the Open Software License (OSL 3.0) 8 | # that is bundled with this package in the file LICENSE.txt. 9 | # It is also available through the world-wide-web at this URL: 10 | # http://opensource.org/licenses/osl-3.0.php 11 | # 12 | # @category EcomDev 13 | # @package EcomDev/MageCI 14 | # @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org) 15 | # @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 16 | # @author Ivan Chepurnyi 17 | 18 | # Identify which PHP executable to run 19 | if [ "$PHP" = "" ] 20 | then 21 | php_bin="php" 22 | else 23 | php_bin=$PHP 24 | fi 25 | 26 | OS=`uname -s` 27 | 28 | if [ "$OS" = "Darwin" ] 29 | then 30 | # @see http://stackoverflow.com/a/18443300/283844 31 | realpath() { 32 | OURPWD=$PWD 33 | cd "$(dirname "$1")" 34 | LINK=$(readlink "$(basename "$1")") 35 | while [ "$LINK" ]; do 36 | cd "$(dirname "$LINK")" 37 | LINK=$(readlink "$(basename "$1")") 38 | done 39 | REALPATH="$PWD/$(basename "$1")" 40 | cd "$OURPWD" 41 | echo "$REALPATH" 42 | } 43 | fi 44 | if hash realpath 2>/dev/null; then 45 | script_bin=$(realpath $0) 46 | else 47 | script_bin=$(readlink -f $0) 48 | fi 49 | script=$(basename $script_bin) 50 | script_dir=$(dirname $script_bin) 51 | action=$1 52 | shift; 53 | 54 | MAGECI_TMP=$(dirname $script_dir)/.tmp 55 | 56 | if [ -e $HOME/.mageci.conf ] 57 | then 58 | . $HOME/.mageci.conf 59 | fi 60 | 61 | if [ -e $PWD/.mageci.conf ] 62 | then 63 | . $PWD/.mageci.conf 64 | fi 65 | 66 | MAGECIF=( 67 | $(tput sgr0) # Reset char 68 | $(tput setaf 2) # Success Message 69 | $(tput setaf 3) # Info Message 70 | $(tput setaf 5) # Error Message 71 | $(tput bold) # Important text 72 | ) 73 | print_usage () 74 | { 75 | echo " 76 | Usage: 77 | ${MAGECIF[4]}$ mage-ci install ${MAGECIF[0]} 78 | Installs a Magento version to a specified destination 79 | -c Create databases flag 80 | -t Create test database flag (only in combination with -c option) 81 | -d Directory where all downloads are stored 82 | -n By specifying this flag you skip downloading process of magento code base, useful for composer based installments 83 | -u DB Username 84 | -p DB Password 85 | -b If you'd like to have custom base url, just specify in this option 86 | -r SQL dumps repository url for a particular Magento version (/.sql.gz) 87 | -f SQL dump file, if you'd like to preinstall some data and specfied -c option 88 | 89 | ${MAGECIF[4]}$ mage-ci install-module ${MAGECIF[0]} 90 | Installs a Magento module with modman definition 91 | 92 | ${MAGECIF[4]}$ mage-ci update-modules ${MAGECIF[0]} 93 | Updates all installed modman modules at specified Magento instance 94 | 95 | ${MAGECIF[4]}$ mage-ci uninstall [] ${MAGECIF[0]} 96 | Performs uninstall of Magento instance 97 | -u DB Username 98 | -p DB Password 99 | 100 | ${MAGECIF[4]}$ mage-ci uninstall-module ${MAGECIF[0]} 101 | Performs uninstall of Magento module from instance 102 | 103 | ${MAGECIF[4]}$ mage-ci install-multiple ... ${MAGECIF[0]} 104 | Installs multiple version of magento at in subdirectories which name is a combined value of - 105 | -d Directory where all downloads are stored 106 | -u DB Username 107 | -p DB Password 108 | -t Create test db as well 109 | -r SQL dumps repository url for a particular Magento version (/.sql.gz) 110 | 111 | ${MAGECIF[4]}$ mage-ci db-dump ... ${MAGECIF[0]} 112 | Creates Magento database dump file at directory with name .sql.gz, the data dunped database is _ 113 | -u DB Username 114 | -p DB Password 115 | -s sql file prefix 116 | 117 | ${MAGECIF[4]}$ mage-ci phpunit ${MAGECIF[0]} 118 | Runs unit tests for all phpunit.xml or phpunit.dist.xml files in or its subdirectories. will be passed directly to phpunit. 119 | 120 | ${MAGECIF[4]}$ mage-ci shell ${MAGECIF[0]} 121 | Runs magento shell script with name at /shell directory with specified options. 122 | 123 | To specify a PHP binary to use when executing PHP commands, define the PHP environment variable with the invocation of the script. For example: 124 | 125 | ${MAGECIF[4]}$ PHP=/path/to/bin/php mage-ci ... 126 | " 127 | } 128 | 129 | show_usage () 130 | { 131 | print_usage 132 | exit 1; 133 | } 134 | 135 | run_shell () 136 | { 137 | local magento_dir=$1 138 | local current_dir=$(pwd) 139 | local script_name=$2 140 | shift 2; 141 | 142 | # Check that first parameter is directory 143 | if [ ! -d "$magento_dir/shell" ] 144 | then 145 | echo "${MAGECIF[3]}Magento shell directory is not found at $magento_dir/shell ${MAGECIF[0]}" 146 | exit 1 147 | fi 148 | 149 | cd $magento_dir/shell 150 | $php_bin -f $script_name -- ${@} 151 | check_error_exit 152 | } 153 | 154 | run_phpunit () 155 | { 156 | local test_dir=$1; 157 | local current_dir=$(pwd); 158 | local phpunit_bin="phpunit"; 159 | 160 | if [ -e "$current_dir/vendor/bin/phpunit" ] 161 | then 162 | phpunit_bin="$current_dir/vendor/bin/phpunit" 163 | elif [ -e "$current_dir/bin/phpunit" ] 164 | then 165 | phpunit_bin="$current_dir/bin/phpunit" 166 | fi 167 | 168 | local phpunit_version=$($phpunit_bin --version) 169 | echo "${MAGECIF[2]}PHPUnit binary: $phpunit_bin" 170 | echo "Version $phpunit_version${MAGECIF[0]}" 171 | 172 | # Check existance of phpunit at the system 173 | if [ $? -ne 0 ] 174 | then 175 | echo "${MAGECIF[3]}PHPUnit is not installed on your system, please visit http://phpunit.de/ for installation" 176 | exit 1; 177 | fi 178 | 179 | # Check that first parameter is directory 180 | if [ ! -d "$test_dir" -a -d tests ] 181 | then 182 | tests_dir="tests" 183 | elif [ ! -d "$test_dir" ] 184 | then 185 | echo "${MAGECIF[3]}PHPUnit tests directory doesn't exists: $test_dir${MAGECIF[0]}" 186 | exit 1 187 | else 188 | shift; # Correct test dir, so remove it from args list 189 | fi 190 | 191 | if hash realpath 2>/dev/null; then 192 | test_dir=$(realpath $test_dir) 193 | else 194 | test_dir=$(readlink -f $test_dir) 195 | fi 196 | 197 | cd $test_dir 198 | 199 | local exitCode=1 200 | 201 | if [ -f phpunit.xml -o -f phpunit.xml.dist ] 202 | then 203 | echo "${MAGECIF[2]}Running test in $test_dir...${MAGECIF[0]}" 204 | $phpunit_bin ${@} 205 | check_error_exit 206 | exitCode=0 207 | else 208 | for dir in $test_dir/* 209 | do 210 | if [ -f "$dir/phpunit.xml" -o -f "$dir/phpunit.xml.dist" ] 211 | then 212 | cd $dir; 213 | echo "${MAGECIF[2]}Running test in $dir...${MAGECIF[0]}" 214 | $phpunit_bin ${@} 215 | check_error_exit 216 | exitCode=0 217 | fi 218 | done 219 | fi 220 | 221 | if [ $exitCode -eq 1 ] 222 | then 223 | echo "${MAGECIF[2]}No tests were found${MAGECIF[0]}" 224 | else 225 | echo "${MAGECIF[1]}PHPUnit tests run completed${MAGECIF[0]}" 226 | fi 227 | 228 | exit $exitCode 229 | } 230 | 231 | dump_magento () 232 | { 233 | local dest_dir=$1; local prefix=$2; shift 2; 234 | local db_name; local db_cred; local db_user="root"; local db_pass=""; 235 | local version=""; local options=""; local file_prefix="" 236 | 237 | if [ ! -d "$dest_dir" ] 238 | then 239 | mkdir -p $dest_dir 240 | fi 241 | 242 | for arg 243 | do 244 | if [[ $arg =~ ^[0-9.]+$ ]] 245 | then 246 | version+=" $arg" 247 | else 248 | options+=" $arg" 249 | fi 250 | done 251 | 252 | while getopts :u:p:f: opt $options 253 | do 254 | case $opt in 255 | u) db_user=$OPTARG ;; 256 | p) db_pass=$OPTARG ;; 257 | f) file_prefix=$OPTARG ;; 258 | \?) echo "${MAGECIF[3]}Unkown option -$OPTARG${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 259 | :) echo "${MAGECIF[3]}Option -$OPTARG requires an argument.${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 260 | esac 261 | done 262 | 263 | db_cred="-u ${db_user}" 264 | 265 | if [[ $db_pass != "" ]] 266 | then 267 | db_cred+="-p${db_pass}" 268 | fi 269 | 270 | if [[ $prefix == "" ]] 271 | then 272 | echo "${MAGECIF[3]} is required ${MAGECIF[0]}" 273 | print_usage; exit 1; 274 | fi 275 | 276 | for ver in $version 277 | do 278 | db_name="${prefix}_${ver//./_}" 279 | echo "${MAGECIF[2]}Dump magento database version $ver into $dest_dir/${file_prefix}${ver}.sql.gz file ${MAGECIF[0]}" 280 | mysqldump $db_cred $db_name > $dest_dir/${file_prefix}${ver}.sql 281 | if [ $? -ne 0 ] 282 | then 283 | echo "${MAGECIF[3]}Failed to dump $db_name... Skipping${MAGECIF[0]}" 284 | else 285 | gzip -f -9 $dest_dir/${file_prefix}${ver}.sql 286 | echo "${MAGECIF[1]}Dumped...${MAGECIF[0]}" 287 | fi 288 | done 289 | } 290 | 291 | install_multiple_magento () 292 | { 293 | local magento_dir=$1; local pass_options="-c"; local prefix=$2; shift 2 294 | local version=""; local options="" 295 | 296 | for arg 297 | do 298 | if [[ $arg =~ ^[0-9.]+$ ]] 299 | then 300 | version+=" $arg" 301 | else 302 | options+=" $arg" 303 | fi 304 | done 305 | 306 | while getopts :u:r:p:f:d:t opt $options 307 | do 308 | case $opt in 309 | u) pass_options="$pass_options -u $OPTARG" ;; 310 | p) pass_options="$pass_options -p $OPTARG" ;; 311 | r) pass_options="$pass_options -r $OPTARG" ;; 312 | t) pass_options="$pass_options -t" ;; 313 | d) pass_options="$pass_options -d $OPTARG" ;; 314 | \?) echo "${MAGECIF[3]}Unkown option -$OPTARG${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 315 | :) echo "${MAGECIF[3]}Option -$OPTARG requires an argument.${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 316 | esac 317 | done 318 | 319 | local db_name 320 | 321 | for ver in $version 322 | do 323 | # Running as subprocess to not break all version installs 324 | db_name="${prefix}_${ver//./_}" 325 | echo "${MAGECIF[2]}Installing magento version $ver into $magento_dir/${prefix}-${ver} directory and $db_name mysql DB${MAGECIF[0]}" 326 | $script_bin install $magento_dir/${prefix}-${ver} $ver $db_name $pass_options > /dev/null 2>&1 327 | if [ $? -ne 0 ] 328 | then 329 | echo "${MAGECIF[3]}Failed to install $magento_dir/$prefix-$ver... Skipping${MAGECIF[0]}" 330 | else 331 | echo "${MAGECIF[1]}Installed...${MAGECIF[0]}" 332 | fi 333 | done 334 | } 335 | 336 | install_magento () 337 | { 338 | local magento_dir=$1; local version=$2; local db_name=$3; shift 3 339 | local db_create; local db_user="root"; local db_pass=""; local sql_dump_file=""; local include_test_db 340 | local phpunit_local_xml; local opt; local sql_base_url; local db_cred 341 | local base_url="http://magento.local/"; local download_dir=$MAGECI_TMP; 342 | local admin_password="123123test"; local clean_up=0; local no_download="0"; 343 | 344 | while getopts :u:r:p:f:b:d:a:cton opt 345 | do 346 | case $opt in 347 | u) db_user=$OPTARG ;; 348 | p) db_pass=$OPTARG ;; 349 | f) sql_dump_file=$OPTARG ;; 350 | c) db_create="1" ;; 351 | t) include_test_db="1" ;; 352 | d) download_dir=$OPTARG ;; 353 | r) sql_base_url=$OPTARG ;; 354 | b) base_url=$OPTARG ;; 355 | a) admin_password=$OPTARG ;; 356 | o) clean_up="1" ;; # New flag for cleaning up previous install 357 | n) no_download="1" ;; # Flag for skipping download process of Magento code-base 358 | \?) echo "${MAGECIF[3]}Unkown option -$OPTARG${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 359 | :) echo "${MAGECIF[3]}Option -$OPTARG requires an argument.${MAGECIF[0]}" >&2; print_usage; exit 1 ;; 360 | esac 361 | done 362 | 363 | [[ $db_pass == "" ]] && db_cred="-u $db_user" || db_cred="-u $db_user -p$db_pass" 364 | 365 | if [[ $magento_dir == "" ]] 366 | then 367 | echo "${MAGECIF[3]}Magento directory should be specified${MAGECIF[0]}" 368 | print_usage; 369 | exit 1 370 | fi 371 | 372 | if [ ! -d "$magento_dir" ] 373 | then 374 | echo "${MAGECIF[2]}Creating Magento directory: $magento_dir ...${MAGECIF[0]}" 375 | mkdir -p "$magento_dir" 376 | fi 377 | 378 | if [[ ! $version =~ ^[a-z0-9.\-]+$ ]] 379 | then 380 | echo "${MAGECIF[3]}Version should be specified: $version${MAGECIF[0]}" 381 | exit 1 382 | fi 383 | 384 | if [[ $db_name == "" ]] 385 | then 386 | echo "${MAGECIF[3]} is required${MAGECIF[0]}" 387 | exit 1 388 | fi 389 | 390 | if [ ! -d "$download_dir" ] 391 | then 392 | mkdir -p $download_dir 393 | check_error_exit 394 | fi 395 | 396 | if [[ $db_create == "1" ]] 397 | then 398 | echo "${MAGECIF[2]}Creating ${db_name} database...${MAGECIF[0]}" 399 | mysql $db_cred -e "DROP DATABASE IF EXISTS ${db_name};CREATE DATABASE ${db_name};" 400 | check_error_exit 401 | 402 | if [[ $include_test_db == "1" ]] 403 | then 404 | echo "${MAGECIF[2]}Create ${db_name}_test database...${MAGECIF[0]}" 405 | mysql $db_cred -e "DROP DATABASE IF EXISTS ${db_name}_test;CREATE DATABASE ${db_name}_test;" 406 | check_error_exit 407 | fi 408 | 409 | if [[ $sql_base_url =~ ^https?\:// ]] 410 | then 411 | echo "${MAGECIF[2]}Trying download SQL dump from url: $sql_base_url/$version.sql.gz" 412 | wget -q --no-clobber -P $download_dir $sql_base_url/$version.sql.gz 413 | if [ $? -eq 0 ] 414 | then 415 | echo "Dump is downloaded and will be used for installation${MAGECIF[0]}" 416 | sql_dump_file="$download_dir/$version.sql.gz" 417 | else 418 | echo "Dump is not available...${MAGECIF[0]}" 419 | fi 420 | fi 421 | 422 | 423 | if [ -f "${sql_dump_file}" ] 424 | then 425 | if [[ $sql_dump_file =~ \.gz$ ]] 426 | then 427 | echo "${MAGECIF[2]}Uncompressing dump file...${MAGECIF[0]}" 428 | mkdir -p $download_dir/dump 429 | local dest_file=$(basename $sql_dump_file) 430 | cp $sql_dump_file $download_dir/dump/$dest_file 431 | gzip -f -d $download_dir/dump/$dest_file 432 | sql_dump_file="$download_dir/dump/${dest_file/.gz/}" 433 | fi 434 | 435 | echo "${MAGECIF[2]}Loading db dump into ${db_name} database...${MAGECIF[0]}" 436 | mysql -B $db_cred $db_name < $sql_dump_file 437 | check_error_exit 438 | if [[ $include_test_db == "1" ]] 439 | then 440 | echo "${MAGECIF[2]}Create ${db_name}_test database...${MAGECIF[0]}" 441 | mysql -B $db_cred ${db_name}_test < $sql_dump_file 442 | check_error_exit 443 | fi 444 | fi 445 | fi 446 | 447 | if [[ $clean_up == "1" ]] 448 | then 449 | uninstall_magento $magento_dir 450 | fi 451 | 452 | if [[ $no_download == "0" ]] 453 | then 454 | echo "${MAGECIF[2]}Downloading Magento from URL: http://www.magentocommerce.com/downloads/assets/$version/magento-$version.tar.gz${MAGECIF[0]}" 455 | wget -q --no-clobber -P $download_dir http://www.magentocommerce.com/downloads/assets/$version/magento-$version.tar.gz 456 | check_error_exit; 457 | echo "${MAGECIF[2]}Unpacking magento installment...${MAGECIF[0]}" 458 | tar -zxf $download_dir/magento-$version.tar.gz -C $magento_dir --strip=1 magento 459 | # Special case for PHP5.4 with installation process 460 | echo "${MAGECIF[2]}Applying pdo_mysql check fix...${MAGECIF[0]}" 461 | config_file="${magento_dir}/app/code/core/Mage/Install/etc/config.xml" 462 | config_file_tmp="${config_file}.tmp" 463 | cp $config_file $config_file_tmp 464 | sed 's//1<\/pdo_mysql>/' $config_file_tmp > $config_file 465 | fi 466 | 467 | echo "${MAGECIF[2]}Installing Magento...${MAGECIF[0]}" 468 | cd $magento_dir 469 | $php_bin -f install.php -- --license_agreement_accepted yes \ 470 | --locale en_US --timezone "America/Los_Angeles" --default_currency USD \ 471 | --db_host localhost --db_name "$db_name" --db_user "$db_user" --db_pass "$db_pass" \ 472 | --url "$base_url" --use_rewrites yes \ 473 | --use_secure no --secure_base_url "$base_url" --use_secure_admin no \ 474 | --admin_lastname Owner --admin_firstname Store --admin_email "admin@example.com" \ 475 | --admin_username admin --admin_password "$admin_password" \ 476 | --skip_url_validation yes --encryption_key "key" 477 | 478 | check_error_exit 479 | echo "${MAGECIF[1]}Installation sucesfully finished${MAGECIF[0]}" 480 | if [ -n $include_test_db ] 481 | then 482 | read -d '' phpunit_local_xml < 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 1 498 | 499 | 500 | ${base_url} 501 | 502 | 503 | ${base_url} 504 | 505 | 506 | 0 507 | 508 | 509 | 510 | 511 | LOCALXML 512 | echo "${MAGECIF[2]}Adding local.xml.phpunit..." 513 | echo $phpunit_local_xml > "app/etc/local.xml.phpunit" 514 | check_error_exit 515 | echo "... to app/etc directory (finished)${MAGECIF[0]}" 516 | fi 517 | 518 | exit 0 519 | } 520 | 521 | install_module () { 522 | local magento_dir=$1 523 | local magento_module_source=$2 524 | shift 2 525 | local magento_module 526 | local modman="${script_dir}/modman" 527 | local modman_args="$@" 528 | 529 | init_modman $magento_dir 530 | 531 | if [[ $magento_module_source =~ ^git@ || $magento_module_source =~ \.git$ ]] 532 | then 533 | magento_module=$(basename ${magento_module_source/.git//}) 534 | check_error_exit 535 | elif [ -d "${magento_module_source}" ] 536 | then 537 | magento_module=$(basename ${magento_module_source}) 538 | else 539 | echo "${MAGECIF[3]}Unkown source type${MAGECIF[0]}" 540 | print_usage; 541 | exit 1 542 | fi 543 | 544 | if [ ! -d ".modman/${magento_module}" ] 545 | then 546 | if [[ $magento_module_source =~ ^git@ || $magento_module_source =~ \.git$ ]] 547 | then 548 | echo "${MAGECIF[2]}Installing module from git repository: $magento_module_source${MAGECIF[0]}" 549 | $modman clone $magento_module_source $modman_args 550 | check_error_exit 551 | elif [ -d "$magento_module_source" ] 552 | then 553 | echo "${MAGECIF[2]}Installing module from local directory: $magento_module_source${MAGECIF[0]}" 554 | $modman link $magento_module_source $modman_args 555 | check_error_exit 556 | fi 557 | else 558 | $modman update $magento_module 559 | echo "${MAGECIF[2]}Updating module${MAGECIF[0]}" 560 | fi 561 | 562 | echo "${MAGECIF[1]}Module was sucessfully installed/updated${MAGECIF[0]}" 563 | 564 | exit 0 565 | } 566 | 567 | init_modman () { 568 | local magento_dir=$1 569 | local modman="${script_dir}/modman" 570 | 571 | if [ ! -f "$modman" ] 572 | then 573 | echo "${MAGECIF[2]}Installing modman...${MAGECIF[0]}" 574 | curl -s -o "$modman" https://raw.githubusercontent.com/colinmollenhour/modman/master/modman 575 | check_error_exit 576 | chmod +x "$modman" 577 | check_error_exit 578 | fi 579 | 580 | cd $magento_dir 581 | check_error_exit 582 | 583 | if [ ! -d ".modman" ] 584 | then 585 | echo "${MAGECIF[2]}Initializing modman...${MAGECIF[0]}" 586 | $modman init 587 | fi 588 | } 589 | 590 | update_modules () { 591 | local magento_dir=$1 592 | local modman="${script_dir}/modman" 593 | 594 | init_modman $magento_dir 595 | $modman update-all 596 | $modman deploy-all 597 | echo "${MAGECIF[1]}Modules updated${MAGECIF[0]}" 598 | } 599 | 600 | uninstall_magento () { 601 | local magento_dir=$1; local db_name=$2; shift 2 602 | local db_user="root"; local db_pass=""; local opt;local db_cred 603 | 604 | while getopts :u:p: opt 605 | do 606 | case $opt in 607 | u) db_user=$OPTARG ;; 608 | p) db_pass=$OPTARG ;; 609 | \?) echo "${MAGECIF[3]}Unkown option -$OPTARG${MAGECIF[0]}" >&2; exit 1 ;; 610 | :) echo "${MAGECIF[3]}Option -$OPTARG requires an argument.${MAGECIF[0]}" >&2; exit 1 ;; 611 | esac 612 | done 613 | 614 | [[ $db_pass == "" ]] && db_cred="-u $db_user" || db_cred="-u $db_user -p$db_pass" 615 | 616 | echo "${MAGECIF[2]}Cleaning up Magento directory...${MAGECIF[0]}" 617 | rm -rf $magento_dir/* $magento_dir/.ht* 618 | 619 | if [[ $db_name != "" ]] 620 | then 621 | echo "${MAGECIF[2]}Uninstalling database...${MAGECIF[0]}" 622 | mysql $db_cred -e "DROP DATABASE IF EXISTS ${db_name};DROP DATABASE IF EXISTS ${db_name}_test;" 623 | check_error_exit 624 | fi; 625 | 626 | echo "${MAGECIF[1]}Magento was uninstalled at: $magento_dir" 627 | } 628 | 629 | uninstall_module () { 630 | local magento_dir=$1 631 | local magento_module_source=$2 632 | local magento_module 633 | local modman="${script_dir}/modman" 634 | 635 | init_modman $magento_dir 636 | 637 | if [[ $magento_module_source =~ ^git@ || $magento_module_source =~ \.git$ ]] 638 | then 639 | magento_module=$(basename ${magento_module_source/.git//}) 640 | check_error_exit 641 | elif [ -d "${magento_module_source}" ] 642 | then 643 | magento_module=$(basename ${magento_module_source}) 644 | elif [ -d ".modman/$magento_module_source" ] 645 | then 646 | magento_module=$magento_module_source 647 | else 648 | echo "${MAGECIF[3]}Unkown source type${MAGECIF[0]}" 649 | print_usage; 650 | exit 1 651 | fi 652 | 653 | if [ -d ".modman/$magento_module" ] 654 | then 655 | echo "${MAGECIF[2]}Removing $magento_module module${MAGECIF[0]}" 656 | $modman remove $magento_module 657 | echo "${MAGECIF[1]}$magento_module module was removed${MAGECIF[0]}" 658 | else 659 | echo "${MAGECIF[2]}$magento_module module is already removed${MAGECIF[0]}" 660 | fi 661 | } 662 | 663 | check_error_exit () { 664 | local errorCode=$? 665 | if [ $errorCode -ne 0 ] 666 | then 667 | echo "${MAGECIF[3]}Previous command returned an error exit code $errorCode${MAGECIF[0]}" 668 | exit $errorCode 669 | fi 670 | } 671 | 672 | case $action in 673 | install) install_magento "$@" ;; 674 | install-module) install_module "$@" ;; 675 | update-modules) update_modules "$@" ;; 676 | uninstall-module) uninstall_module "$@" ;; 677 | uninstall) uninstall_magento "$@" ;; 678 | install-multiple) install_multiple_magento "$@" ;; 679 | db-dump) dump_magento "$@" ;; 680 | phpunit) run_phpunit "$@" ;; 681 | shell) run_shell "$@" ;; 682 | *) show_usage ;; 683 | esac 684 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecomdev/mage-ci", 3 | "license": "OSL-3.0", 4 | "description": "Magento Continuous Integration Tools", 5 | "homepage": "https://github.com/EcomDev/MageCI", 6 | "authors":[ 7 | { 8 | "name": "Ivan Chepurnyi", 9 | "email":"ivan.chepurnyi@ecomdev.org", 10 | "homepage": "http://www.ecomdev.org", 11 | "role":"Developer" 12 | } 13 | ], 14 | "bin": [ 15 | "bin/mage-ci" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /installer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Magento Continuous Integration Tools 4 | # 5 | # NOTICE OF LICENSE 6 | # 7 | # This source file is subject to the Open Software License (OSL 3.0) 8 | # that is bundled with this package in the file LICENSE.txt. 9 | # It is also available through the world-wide-web at this URL: 10 | # http://opensource.org/licenses/osl-3.0.php 11 | # 12 | # @category EcomDev 13 | # @package EcomDev/MageCI 14 | # @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org) 15 | # @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 16 | # @author Ivan Chepurnyi 17 | 18 | current_dir=$(pwd) 19 | 20 | # create bin directory in current dir 21 | if [ ! -d "$current_dir/bin" ] 22 | then 23 | mkdir -p $current_dir/bin 24 | fi 25 | 26 | wget -q -O $current_dir/bin/mage-ci https://raw.githubusercontent.com/EcomDev/MageCI/master/bin/mage-ci --no-check-certificate 27 | chmod +x $current_dir/bin/mage-ci 28 | --------------------------------------------------------------------------------