git@github.com:ncareol
Erik Johnson, NCAR EOL
Boulder Ruby, 2014/08/19
http://erikj.github.io/gitgithubncareol
Erik, Software Engineer w/ NCAR EOL here in Boulder. Here to share our experience
using Git and GitHub to enhance our development and deployment workflows. Also, I
have stickers to give out afterwards.NCAR Earth Observing Laboratory
(EOL)
NCAR is the US National Science Foundation's National Center for Atmospheric Research.
EOL provides instruments, infrastructure, logistics for atmospheric research
upsondes, dropsondes, radar, Gulfstream V and C-130 research aircraft, instruments aboard NASA Globalhawke UAVNCAR EOL Facilities
NSF/NCAR Gulfstream V
NCAR EOL Facilities
Anvil cloud from G-VNCAR EOL Facilities
NSF/NCAR Gulfstream C-130NCAR EOL Facilities
S-POL RadarNCAR EOL Facilities
S-POL Radar Ops
- EOL computing & IT infrastructure
- Data-management services
- real-time & post-facto access
- Field-project support
CDS supports everything from EOL networking, printers, workstations and laptops,
to ingest, access and archival of research data from satellites, radar, aircraft,
weather stations, research instruments, etc.NCAR EOL CDS
Collaborative Technologies & Metadata (CTM) group
- Databases of metadata
- Web applications
- MapServer
- Data ingest
- IRC
Field Projects
- Campaigns to conduct atmospheric research
- Weather
- Climate
- Chemistry
- Pollution
Field Catalog
- ingests, serves and archives field-project data:
- operational
- research
- model
- primarily images, text, HTML, PDF and KML
- used during and after project
Field Catalog
Suite of applications:
-
zith9 database schema (MySQL)
-
Catalog Models Rubygem (Ruby, ActiveRecord)
-
Catalog Ingest application (Ruby, ActiveRecord, Inotify, EventMachine)
-
Field Catalog web application (Ruby on Rails, Haml, CoffeeScript, Bootstrap, PDF.js, CKEditor)
-
Catalog Maps web application (Ruby on Rails, Haml, CoffeeScript, OpenLayers, Bootstrap)
-
Catalog Nagios monitoring utility (Ruby, ActiveRecord, Nagios)
-
Catalog Stats command-line application (Ruby, ActiveRecord)
-
IRCBot Bot-provided IRC utilities (Ruby, Cinch)
Most applications after Catalog Models all depend on it.
We're currently using: Ruby 1.9.3, Rails 3.2 and Bootstrap 2.3
Product Navigation
Categories#dateSatellite Product
Files#showCatalog Maps
catalog.eol.ucar.edu/maps/deepwave
Geo interface. Features: geolocated imagery, KMLs of satellite data and aircraft
flight tracks, realtime and playback / temporal navigation. Made w/ OpenLayers,
OpenStreet Maps, Bootstrap, jQuery UI.Field-Catalog Development
- Group lead is Product Owner
- developed by 2-6 active Software Engineers @ any time: CTM team & others
- administered by ~ one Software Engineer / active project
- scrum: three times / week
Git
- Distributed revision-control system
- every check out is a complete, free-standing repository
developers have a complete VCS w/o need to interact w/ central / other repositories
CTM has been using GitHub for most of our development for ~ 3 yearsgithub.com:ncareol
- 17 private repositories
- 9 public repositories
- 13 teams
- 16 members
- initial plan: Bronze, 10 private repositories, $25 / month
- later: Silver, 20 private repositories, $50 / month
https://github.com/pricing
this is much cheaper than paying staff developers and / or system administrators to maintain similar functionality. mention Gitosis?
teams: we have many that have a team of contributors, and a team-admins for those
who are to administer the team's repositoriesGitHub Issues
In the beginning...
There is an issue:
GitHub Issues
Issues generally fall into one of two categories:
- features: make something / make something better
- bugs: something is wrong and needs to be fixed
Issue Description
composed in plain text and / or Markdown / GFM + GitHub Hotlinking
which I'll get into...Markdown
plain-text syntax for authoring that compiles to HTML
designed to be written quickly w/ rich-text formatting provided by HTML
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). https://daringfireball.net/projects/markdown/
Issue Description
# Issue Heading
A **good idea** for a *new feature* from @erikj that relates to #60:
```ruby
puts 'Hello Boulder Ruby'
```
heading gets h1 tag, bold text, italics, username and issue ID are hotlinked.
hovering over issue ID displays issue title.
text formatting enhances communication w/ fellow humans, which is valuable in online interactionsIssues
Issues can be observed and commented upon as they progress
Users can also unsubscribe from Issues if they're not interestedLabels
-
Issues can be assigned one or more labels
-
Create / edit / delete labels as needed
-
Useful for categorizing issues
Labels: CatalogMaps
These are the labels we use for CatalogMapsCHECKED OUT
When a developer is ready to work on an issue:
good for using the Issues interface to determine who is working on what: MANAGER FRIENDLY!Milestones
A Milestone is composed of:
- title
- description (optional)
- due date
- set of issues
an issue can be assigned to only one milestoneMilestones
We generally assign significant, planned versions to their own milestones, e.g.
- Catalog Maps 2.0
- Catalog Maps 2.1
- Catalog Maps 2.2
Git Branches
- Branches are a fundamental part of Git
- Subversion branches are complete copies of their parent branch
- Git branches are only the commits that diverge from their parent branch
so fundamental that they're represented in Git's logoGit-Branching Workflow
-
"Never commit to your master"
- everything is branched from develop
- changes are made in dedicated branches
- branches are merged back in to develop when they are ready
-
master is updated via merge from develop
-
master is always deployable
Branch Names
There are two hard problems in computer science: cache invalidation, naming things and off-by-one errors. - Phil Karlton + Martin Fowler
branch names are a form of communication to other humans, so it's important to use a good branch name to communicate clearlyBranch Names
Use branch category as prefix: e.g. feature, fix
Include the issue number-- easy point of reference to which issue the branch applies
Short-but-informative description
e.g.
- feature-42-the-answer
- fix-314-pi-miscalculation
- hotfix-all-bugs
Branch naming conventions that we've adopted.
2 is important and often used.Commit Messages: GitHub Hotlinking
Like Issue content and comments, #issue IDs, @usernames and commit hashes will be autolinked in GitHub's web interface.
once we have a branch checked out, we're going to make commits to it. via hotlinking, GitHub enhances the value of our commit messages by adding human-friendly featuresGitHub Pull Requests
- request to merge one branch into another
- can be from separate branch in same repository or a branch in a separate repository
Github Pull Requests: Features
- description
- commits to be merged
- code diff
- comments
- in line
- specific code lines
- can be merged locally and request will be closed when merge is pushed to origin
https://help.github.com/articles/using-pull-requests
this is where other developers have a chance to review and comment proposed changes.
good to provide a link to a demonstration of changes.Putting Things Together: Bundler
transition slideBundle w/ Git
- Rubygems
- Bundler package manager
-
Catalog Models gem: library of shared ActiveRecord models
- Gem loaded by Bundler via Git, specified in application's Gemfile:
gem 'catalog_models',
git: 'git@github.com:ncareol/catalog_models.git',
tag: 'v1.7.3'
http://bundler.io/v1.5/git.html
we're already versioning our software w/ Git tags, so this eliminates
the dependency on packaging and distributing the gem w/ every release.
Bundler also allows specification of commit or a branch.Easy Deploys w/ Git
$ git push heroku master
Counting objects: 63, done.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (63/63), 26.35 KiB, done.
Total 63 (delta 2), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.0.pre.5
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/.....
...
https://devcenter.heroku.com/articles/git
Easy Deploys w/ Git
.git/config
On Server / deployment target, enable push to non-bare repository:
[receive]
denyCurrentBranch = ignore
Easy Deploys w/ Git
.git/hooks/post-receive
#!/bin/sh
# git stuff
cd ..
GIT_DIR='.git'
umask 002 && /usr/bin/git reset --hard
read oldcommit newcommit refname
# on-update actions
echo "bundling"
bundle install --local --path=vendor --deployment --without development test
if git diff-tree --name-status -r $newcommit $oldcommit \
app/assets vendor/assets > /dev/null ; then
echo "precompiling assets"
rake RAILS_ENV=production assets:precompile
fi
echo "reloading"
/usr/local/catalog/etc/catalog-ui-reload
Easy Deploys w/ Git: Remotes
[ej@kepler] git remote -v
dev ssh://ej@ctm-dev.eol.ucar.edu/usr/local/catalog/catalog_ui (fetch)
dev ssh://ej@ctm-dev.eol.ucar.edu/usr/local/catalog/catalog_ui (push)
ops ssh://ej@sferic.eol.ucar.edu:23/usr/local/catalog/catalog_ui (fetch)
ops ssh://ej@sferic.eol.ucar.edu:23/usr/local/catalog/catalog_ui (push)
staging ssh://ej@sferic-dev.eol.ucar.edu/usr/local/catalog/catalog_ui (push)
staging ssh://ej@sferic-dev.eol.ucar.edu/usr/local/catalog/catalog_ui (fetch)
Easy-Deploy Example
$ git checkout develop && git pull
$ git merge --no-ff feature-42-awesomeness
$ git push dev develop # deploy local develop branch to dev
# test changes on dev environment
$ git checkout master && git pull
$ git merge --no-ff develop
$ git push staging master # deploy local master to staging
# test changes on staging environment
# tag release:
$ git tag -a v1.4.2 -m "add awesomeness"
$ git push ops master # deploy local master to ops
# test changes on ops environment
# push merged branches and tag to origin:
$ git push origin develop && git push origin master
$ git push --tags
Workflow Summary
Scrum
Open issue, assign to developer, label as CHECKED OUT
branch from develop
Make and commit changes
push changes to GitHub
Open pull request on GitHub
Review pull request
merge and tag locally
Deploy via push from local environment to dev, staging, ops environments
push merged branches and tags to github
Close issue
Lessons Learned
- Learn and use the tools that we have / are available: Git, Markdown, languages' preferred packaging utilities, etc.
- Git can enhance your workflow
- GitHub
- Reliable and simple but powerful
- Great tool for communication between developers and stakeholders
- Subscribe to GitHub's blog for updates on features
- Issue discovery can be difficult when there are many Issues
- => Easy to create duplicates
- Organize w/ labels
- Use Git tags for releases
- Minimize / eliminate third-party dependencies
you can make the most of your VCS and management software to enhance your workflow and team communication.Room For Improvement
- Cross-repo issues: where do they issues belong?
- Deployment collision-- surprise!
user friendly, can be surprising, in violation of PLOS, surprises in ops are bad
- Application and assets out of sync while precompiling on deployment
- Scrum, less useful when staff are working on isolated tasks
- Schema scattered across two repositories as Rails migrations and SQL files
- cross-repo issues: duplicate issues across repos, sacrifice private-repo
slot as meta repo for cross-repo issues?
- deployment collision: hasn't happened, handled gracefully by git, but not
user friendly, can be surprising, in violation of PLOS, surprises in ops are bad
- Scrum: isolated tasks, historically how our organization operatesSummary
- Development starts w/ an Issue
- Markdown / GFM and auto-linking features
- Git-Branching Workflow
- GitHub Pull Requests: code review and discussion
- Bundle / w/ Git, Vendor Everything
- Git-Based Easy Deploys
Future / Wish List
- More Features
- Ruby 2.1, Rails 4.1, Bootstrap 3
- Continuous Integration
- DevOps
- Docker
- Open Source
</content>
thanks for your attention and thanks to the SEA for welcoming me.
email address if you'd like to discuss git or github later.
slides available online w/ source code @ these URLs.