Skip to content
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.

Commit

Permalink
Add doit test, mysql and start-over commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed May 18, 2018
1 parent 7dbb37a commit 4638544
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 22 deletions.
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '3.2'
services:
drupal:
build: .
build:
context: .
dockerfile: dockerfiles/drupal
ports:
- "8888:80"
- "8889:80"
Expand All @@ -13,7 +15,9 @@ services:
environment:
- DRUPAL_DATABASE_HOST=mysql
mysql:
image: "mysql:5.6"
build:
context: .
dockerfile: dockerfiles/mysql
command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
ports:
- "3306:3306"
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions dockerfiles/mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mysql:5.6

WORKDIR /mysql
RUN apt-get update
# Install less so we can use mysql in the container with a useful pager.
RUN apt-get install less
73 changes: 53 additions & 20 deletions doit
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,23 @@ function doithelp() {
echo -e "${LightBlue} serve${NC} Starts the containers and runs continuously to show logs."
echo -e "${LightBlue} init-bos${NC} Creates fresh \"drupal\" db for Boston.gov and sets profile info."
echo -e "${LightBlue} init-hub${NC} Creates fresh \"hub\" db for the Hub and sets profile info."
echo -e "${LightBlue} start-over${NC} Deletes all docker-compose containers and rebuilds from scratch."
echo -e "${LightBlue} drush${NC} Allows you to run drush commands in your container."
echo -e "${LightBlue} mysql${NC} Opens a MySQL prompt inside the database container."
echo $'\r'
echo -e "${Yellow}Staff Commands:${NC}"
echo -e "${LightBlue} build-bos${NC} Builds Boston.gov using a database from staging and runs tests."
echo -e "${LightBlue} build-hub${NC} Build the Hub using a database from staging and runs tests."
echo -e "${LightBlue} test-bos${NC} Runs Behat against Boston.gov database."
echo -e "${LightBlue} test-hub${NC} Runs Behat against the Hub database."
echo -e "${LightBlue} sync-files${NC} Gets the \"sites/default/files\" directory from staging."
echo -e "${LightBlue} cheatsheet${NC} List of drush commands helpful to City of Boston (COB) dev."
echo $'\r'
}

# Use docker-compose to start the containers.
function doitserve() {
echo $'\r'
echo -ne "${Yellow}Starting containers using ${LightGreen}docker-compose up${NC}"
echo $'\r'
echo $'\r'
doitcomment "Starting containers using" "docker-compose up"
echo -ne "******************************************************************"
echo $'\r'
echo -ne "*** This command will continue to run so you can see the logs ***"
Expand All @@ -76,45 +77,61 @@ function doitserve() {

# Initialize Boston.gov (create db and set profile info).
function doitinitbos() {
echo $'\r'
echo -ne "${Yellow}Initializing Boston.gov ${LightGreen}with a fresh database.${NC}"
echo $'\r'
echo $'\r'
doitcomment "Initializing Boston.gov" "with a fresh database."
docker exec -t bostongov_drupal_1 scripts/init-docker-container.sh
}

# Initialize the Hub (create db and set profile info).
function doitinithub() {
echo $'\r'
echo -ne "${Yellow}Initializing the Hub ${LightGreen}with a fresh database.${NC}"
echo $'\r'
echo $'\r'
doitcomment "Initializing the Hub" "with a fresh database."
docker exec -t bostongov_drupal_1 scripts/init-docker-container.sh hub
}

# Build Boston.gov with staging db.
function doitbuildbos() {
echo $'\r'
echo -ne "${Yellow}Running build for Boston.gov ${LightGreen}with Behat tests${NC}"
echo $'\r'
echo $'\r'
doitcomment "Running build for Boston.gov" "with Behat tests"
docker exec -t bostongov_drupal_1 ./task.sh -Dbehat.run-server=true build:test
}

# Ran Behat test on the Boston.gov
function doittestbos() {
doitcomment "Running Behat against" "Boston.gov"
docker exec -t bostongov_drupal_1 ./vendor/bin/behat tests/behat/features --config=tests/behat/local.yml -p local
}

# Build the Hub with staging db.
function doitbuildhub() {
echo $'\r'
echo -ne "${Yellow}Running build for the Hub ${LightGreen}with Behat tests${NC}"
echo $'\r'
echo $'\r'
doitcomment "Running build for the Hub" "with Behat tests"
docker exec -t bostongov_drupal_1 ./hub-task.sh -Dbehat.run-server=true build:test:hub
}

# Ran Behat test on the Hub.
function doittesthub() {
doitcomment "Running Behat against" "the Hub"
docker exec -t bostongov_drupal_1 ./vendor/bin/behat tests/behat/features --config=tests/behat/local.yml -p hub
}

# Copy files from the staging site to your local environment.
function doitsyncfiles() {
docker exec -it bostongov_drupal_1 drush rsync @boston.test:%files/ %files -azP
}

# Open MySQL prompt.
function doitmysql() {
doitcomment "Opening MySQL promt inside container" "type \"exit\" or use Ctrl+c to escape)."
docker exec -it bostongov_mysql_1 mysql --pager="less -SFX"
}

# Delete all containers and rebuild.
function doitstartover() {
doitcomment "Stopping any running docker-compose containers."
docker-compose stop
doitcomment "Deleting all docker-compose containers."
docker-compose rm
doitcomment "Building the containers again."
docker-compose build
}

# Quick cheatsheet of common commands.
function doitcheatsheet() {
echo $'\r'
Expand Down Expand Up @@ -170,6 +187,14 @@ function doitdrush() {
fi
}

# Formatting for a simple comment.
function doitcomment() {
echo $'\r'
echo -ne "${Yellow}$1${LightGreen} $2${NC}"
echo $'\r'
echo $'\r'
}

# Get the first word from user input.
command=$1
# Get everything after the first word from input.
Expand All @@ -181,16 +206,24 @@ if [[ -n "$command" ]]; then
doitbuildbos
elif [[ $command == "init-bos" ]]; then
doitinitbos
elif [[ $command == "test-bos" ]]; then
doittestbos
elif [[ $command == "build-hub" ]]; then
doitbuildhub
elif [[ $command == "init-hub" ]]; then
doitinithub
elif [[ $command == "test-hub" ]]; then
doittesthub
elif [[ $command == "sync-files" ]]; then
doitsyncfiles
elif [[ $command == "drush" ]]; then
doitdrush
elif [[ $command == "mysql" ]]; then
doitmysql
elif [[ $command == "cheatsheet" ]]; then
doitcheatsheet
elif [[ $command == "start-over" ]]; then
doitstartover
elif [[ $command == "help" ]]; then
doithelp
elif [[ $command == "brand" ]]; then
Expand Down

0 comments on commit 4638544

Please sign in to comment.