Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Pantheon Workflow Solution on Kalabox - Boomshakalaka!

Parent Feed: 

In Kalatheme in Kalabox on Pantheon for a minute about time, we pulled down a Kalatheme based sub-theme into a recently installed Kalabox on our laptop, so we could run it locally and work on the project using Eclipse or any other IDE.

In this article we explore a simple but realistic Git-based workflow for Multidev and non-Multidev topic branches of a Pantheon dev project.

Branches and environments

When you are going to make a change, make a branch.

When you are going to make a change, make a branch.

$ git status
# On branch adevbranch
nothing to commit (working directory clean)
$ 
$ git checkout -b mytinycontribution
…
mess around
…
works well!
...
$ git commit -am “My tiny contribution makes a big difference. Oh, and downloaded views”
… 
$ git checkout adevbranch
$ git merge mytinycontribution
$ git push origin adevbranch

Cool!

Now, an environment in Drupal is the actual running code. Meaning versioned code + database + files

If you are working with everything in code, and you should, the database and the files basically constitute content plus superficial state (cached images, css, javascript). But you need them to actually see what your commit has done. Hence, “environment”.

The beauty of multidev on Pantheon, for example, is that you are given a full environment for each topic branch on your git workflow.

For more on branches, see References 1.2

For more on multidev, see References 2.5 and resources on Pantheon site.

Making changes and pushing back to a Multidev environment

We covered cloning a site into the Kalabox environment here.

Without Kalabox, it's a question of generating ssh keys on your dev environment (laptop or VPS), loading them into your Pantheon account, and getting started with Git.

So however you got it, you change directory into your newly cloned repo, do your changes, commit them, and push back.

$ cd multidevbranch
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/multidevbranch02
  remotes/origin/master
  remotes/origin/master_before_restore_to_nnnnnnnn
  remotes/origin/multidevbranch
$ git checkout multidevbranch
Branch multidevbranch set up to track remote branch multidevbranch from origin.
Switched to a new branch 'multidevbranch'

So now, conscious of the fact that you are not on “master” and not going to screw anything up, you make your changes, test them in your local environment, then if happy:

$ git commit -am “done it”
$ git push origin multidevbranch

Now if you're really getting confident, and someone has approved the fruit of your efforts, perhaps you'd like to actually merge into master (the Pantheon 'dev' environment):

$ git checkout master   # switch to dev branch branch
$ git pull origin master # did anyone else commit anything while I was working? If so fetch it and merge it into local master
$ git merge origin/multidevbranch # merge in your stuff you just pushed to pantheon
$ git push origin master  # merge it into dev environment

Coming into work and keeping your Multidev branch up-to-date

At the risk of redundancy, here is what you do on any morning, actually; also works for after lunch, or getting home and wanting to do something after dinner:

$ cd multidevbranch
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/multidevbranch02
  remotes/origin/master
  remotes/origin/master_before_restore_to_nnnnnnnn
  remotes/origin/multidevbranch
$ git pull origin master
$ git checkout multidevbranch
$ git merge origin/master
$ git push origin victorkane ## bring your multidev environment up-to-date!

Keeping your local Kalabox environment up-to-date

Now that the local branch is up-to-date and useful into the bargain, what happens if others have added files, etc.? Got to keep your local environment up-to-date. For VPS or non-Kalabox situations, just download and untar and/or drush.

For Kalabox, we have terminatur (see References 4.1), a Kalamuna creation, included in the Kalabox setup.

To grab database and files from dev, then download to kalabox:

1. Go to multidevbranch Workflow
2. Clone from dev Environment (database and files and run update.php all checked)
3. Hit button "Clone the Database & Files from Dev..."

4. Use terminatur within Kalabox to refresh local environment with the database and files

$ drush help pulldata
Pulls down the database for a Pantheon site.

Examples:
 drush pulldata sitename.dev               Pulls down the database for a site 
                                           at @terminatur.mysite.dev.         
Arguments:
 sitename                                  The sitename.dev part of  
                                           @terminatur.sitename.dev. 

$ drush help pullfiles
Pulls down the files for a Pantheon site.

Examples:
 drush pullfiles sitename.dev              Pulls down the files for a site at 
                                           @terminatur.mysite.dev.            
Arguments:
 sitename                                  The sitename.dev part of  
                                           @terminatur.sitename.dev. 
Options:
 --destination=/www/>                 The destination of your webroot. 

$ drush ta          # refresh aliases usable by terminatur
$ drush sa
...
...
@terminatur.multidevbranch.dev
@terminatur.multidevbranch02.dev
@terminatur.multidevbranch02.dev

So the sitename parameter will be: multidevbranch.dev
And the commands will be:

$ drush pullfiles multidevbranch.dev
$ drush pulldata multidevbranch.dev
$ drush cc all  ## Did you remember to clear cache?

Results:


vagrant@kala:/var/www/multidevbranch$ drush pullfiles multidevbranch.dev
Downloading files... [warning]
Files downloaded. [success]
vagrant@kala:/var/www/multidevbranch$ drush pulldata multidevbranch.dev
How do you want to download your database?
[0] : Cancel
[1] : Get it from the latest Pantheon backup.
[2] : Create a new Pantheon backup and download it.
[3] : Pick one from a list of Pantheon backups.

2
Creating database backup... [warning]
Database backup complete! [success]
Downloading data... [warning]
Data downloaded. [success]
vagrant@kala:/var/www/multidevbranch$

References

  1. Git

    1. Git Pro book

    2. Git Pro book on branches

  2. Kalabox

    1. Kalabox website

    2. Kalabox wiki page

    3. Video: http://www.youtube.com/watch?v=ed1EufMfAJQ (Jan 15 2014)

    4. This Kalamuna article, Power to the People, explains that Kalabox is built upon a powerful Vagrant driven stack, Kalastack

    5. This Kalamuna article, Ride the Hydra: Reduce Complexity, introduces the three goals for reducing Drupal workflow complexity:

      1. Developers must use a standardized local development platform. (Kalabox)

      2. Deployment (moving code between local, staging, and production environments) must be automated. (Pantheon)

      3. Development must be transparent to site owners and team members alike. (Pantheon workflow, including branches coupled with complete environments (code+db+files), i.e. Multidev  (My own take: Of course you can do “branching on the cheap” and just use Kalabox for that, or own VPS server; mix with additional GitHub remote!).

    6. Kalastack on Github

  3. Kalatheme

    1. Kalatheme project page

    2. Kalatheme docs

      1. Panels layouts

      2. SASS and COMPASS

    3. Bootwatch bootstrap themes

    4. Wrapbootstrap example of paid bootstrap themes

    5. Mike Pirog's classic Kalatheme video Keep theming simple with panels and bootstrap

  4. terminatur

    1. GitHub page

Bookmark/Search this post with

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web