my "perfect" toolchain setup for grails projects

Post on 10-May-2015

3.960 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

Presentationslides from the GR8Conf presentation. Find the abstract here: http://gr8conf.eu/Presentations/my-perfect-grails-toolchain

TRANSCRIPT

Stefan Armbrusternetjay GmbH & Co. KG

My "Perfect" Toolchain Setup for Grails Projects

about me ●located in Munich/Germany●freelancer since +10 years ●cofounder of Netjay●Java +10 years, Groovy ~5 years, Grails 3+ years●+3 years Neo4j experience, involved in the community●author of some Grails plugins and Neo4j-Grails integration plugin●passionate volunteer firefighter

●@darthvader42●http://blog.armbruster-it.de

We're hiring

http://www.netjay.de/job.html

Compare developing a Grails application

with cooking

Tools you'll need●Software engineering process●Ticketing system●Editor / IDE●Version control / branching model●continuous integration●Automated deployments●Load testing / Profiling

Education science

Only hear 20 %

Only see 30 %

See and hear 50 %

See, hear and discuss 70 %

See, hear, discuss and

do-it-yourself

90%

About this workshop●Let's create a small application●Setup all tooling●Deliver today !●For server side tools:

– Ubuntu 12.04 image as VM image

– Login: dev / 12345dev!●Developer's laptop:

– JDK, Grails, Virtualbox, IntelliJ, git

Introducing demo project: gr8shop●Small shopping application●Simple use-cases

● As a shopmanager I want to CRUD my products so the customers can buy something

● As a customer I want to put products in my shopping cart to buy them

● As a customer I want my shopping cart to be persistent so I can access it at a later timepoint

Choose a process●Scrum●Waterfall●RUP●Many more available●Combined with Kanban ?●None ;-)

Stefan's lessons learned●Team agreement on a DoD „defintion of done“:

– Tested (unit, functional, ...)

– Peer review

– Documentation (how and where?)

●Don't omit the physical taskboard●Do pair programming

– on important things

– If team skills differ

●If you're not familiar with scrum, hire a good coach! ●On start, get management committment and remember them

Ticketing systems / backlog tool●Single location for user stories●Support for non-local teammebers●We'll look at:

– JIRA (https://gr8confdemo.atlassian.net)• Only available during workshop +2 weeks

– Redmine • We'll install that in the dev server vm

Atlassian JIRA + Greenhopper●Most powerful issue tracking system●Lots of plugins, great IDE integration●Widely used (e.g. Grails itself uses Jira)●Not free for commercial use●Download as war or hosted product („Studio“)●http://www.atlassian.com/software/jira/overview●Our demo instance: https://gr8confdemo.atlassian.net/

– admin / gr8admin

– dev / gr8dev

– po / gr8po

Redmine●RoR based●Issues, wiki, news, documents, forum ....●SCM integration, lots of plugins●Debian/Ubuntu packages available

sudo apt­get install redmine redmine­sqlite libapache2­mod­passenger

Apache: copy contents of

/usr/share/doc/redmine/examples/apache2­passenger­host.conf to /etc/apache2/sites­available/default

●Access: http://<server>, user:admin, pw:admin

IDE matrix - YMMVName Pros Cons

IntelliJ •IDE with a strong focus on java development•„knows what you want to do“•most advanced support for Grails (IMHO)

•You have to pay when used commercially•Learning curve•Task integration

SpringSource Eclipse STS

•Eclipse is widely adopted•backed by SpringSource•free•rich Plugin ecosystem

•More a set of plugins instead of a well integrated monolith

Netbeans ? ?

Textmate A lot of „gurus“ use it Mac only

vi(m), emacs •Everywhere available•Uses very few resources•Only real programmers use vi

•Not the easiest thing to learn•Poor code assist

Sublime ? ?

Hints for IntelliJ●Use the same codestyle settings for your team

– esp. line seperator setting●Learn keybindings, use „key promoter“ plugin●When using Jira use Atlassian connector●Some of my favourites:

– Ctrl+W: semantic highlighting

– Shelve/Unshelve

– Run units test for Grails directly

– Debugger

– Zen coding support

SCM overview

You have the choie:– The old ones: diff/patch, RCS, CVS

– The most used (currently): SVN

– The hip ones: GIT, hg, bazaar, ... (DVCS's)

– The PITAs: Perforce, M$ Sourcesafe, ...

Online repo providers:– Github, Bitbucket, Sourcforge, etc.

GIT: overview (kudos to @struberg)●GIT works similar to patch based systems●GIT is de-centralised: all changes are also available

'offline'●GIT is distributed: changes can be pulled/pushed

from/to remote repositories●All 'patches' are available locally●Commits are cryptographically strong

GIT concepts – object tree●GIT always tracks the whole repository●GIT tracks a tree containing diffs with their 'parents' and

commit information●.git/objects contains all those commits●each commit has a unique sha1 containing the diff-object

plus●tree information, and further●each commit has a unique sha1 containing the tree-object

+ commit info●git 'packs' objects space optimized

GIT commit tree

●GIT doesn't work directly against the Repository but has a 'preparation area' called 'Index'

●all changes prepared in that 'Index' will only get stored to the Repositories tree-objects with the 'commit'

localrepo

INDEX

filechange

upstreamrepo1

upstreamrepo2

GIT documentation / tools

Docs:

– Interactive cheatsheet http://ndpsoftware.com/git-cheatsheet.html

– http://git-scm.com/documentation

– http://gitcasts.com/

Tools:

– Command line, gitk, giggle

– IDE (IntelliJ, STS, netbeans)

– Mac: git-tower

– SmartGit (free for non-commercial)

git flow: a branching model

Applys a practical proven branching model on top of git

develop: permanent branch, current development

master: permantent branch, holds stable releases

release: temporary branch for stabilizing/hardening prerelease

hotfix: temporary branch for bugfixing

git flow - setupwget ­q – http://github.com/nvie/gitflow/raw/develop/contrib/gitflow­installer.sh –no­check­certificate

sudo chmod a+x gitflow­installer.sh; sudo ./gitflow­installer.sh

Usage:

cd <repo>; git flow init (use once)

git flow feature [start|publish|finish|pull|list]

git flow release [start|publish|finish]

git flow hotfix [start|finish]

GIT tips●Choose .gitignore carefully:

– https://github.com/github/gitignore/raw/master/Grails.gitignore

– Consider adding IDE control files ?

●Team agreement on commit messages– e.g. „refs/closes #<id>: [NEW|FIX|CON|ETF] <msg>“

●Rebase is powerful, but do not rebase pushed stuff!

Remote repo manager: gitolite●GIT by itself has no security or authentication●Gitolite uses ssh for this●apt­get install gitolite, provide admin key●Clone admin repo:

– git clone gitolite@<hostname>:gitolite­admin.git

– Add public ssh keys to keys/

– Setup project in conf/gitolite.conf

– Commit & push

Publish gr8shop●Connect local repo to remote (only once)

– git remote add origin gitolite@<hostname>:gr8shop.git

●git push –all●Other team mates:

– git clone gitolite@<hostname>:gr8shop.git

Setup CI: Jenkins●apt-get install jenkins-tomcat

– http://<hostname>:8080/jenkins●Install some plugins:

– Chuck Norris (you can't live without it!)

– Grails (obvious)

– Git

– Violations

– Maven

– Deploy

Jenkins●Configure multiple small dependent jobs instead of 1 huge job

– Faster response when something goes wrong

●Let git postreceive hook trigger jenkins instead of jenkins querying git every x minutes

– Jenkins must be security enabled

– Use external trigger in job's config

– Postreceive hook for git:curl "http://admin:admin@localhost:8080/jenkins/job/gr8shop_unittests/build?

token=abc"

●Parameterize deploy job with a git refspec

Functional tests●Killer combo for testing: Spock + Geb●Demoing...●For running Geb tests on Jenkins: either use:

– RemoteWebDriver,

– HtmlUnit driver, or

– [Firefox,Chrome] + Xvnc plugin, see• http://www.rapaul.com/2011/06/05/zero-to-headless-

browser-tests-jenkins/

Code quality●Use codenarc plugin●Apply to grails-app/conf:

codenarc {

    reportName = 'target/test­reports/CodeNarcReport.xml'

    reportType = 'xml'

    propertiesFile = 'grails­app/conf/codenarc.properties'

}

●And Jenkins' violation plugin:– „Report violations, codenarc“:

target/test-reports/CodeNarcReport.xml

Loadtesting

Demoing jmeter....

Alternatives:– Grinder

– HP LoadRunner (if you have too much $$$)

Profiling

Demoing Yourkit Profiler

Alternatives– JVisualVM

– JDK's command line tools (jmap/jhat/jstat/jstack)

– Netbeans Profiler

Need to modify existing plugin?●Fork the plugin on github●Use git submodule to nest the fork in your project●Inline the plugin●Think of contributing your plugin changes!●My blog post for this: http://bit.ly/pwahJ1

Kudos / references

●Boris Gloger's scrum checklist: http://www.infoq.com/minibooks/scrum-checklists

●http://farm4.staticflickr.com/3241/3130372498_c1e0812548_z.jpg?zz=1

●http://farm4.staticflickr.com/3482/3456875252_ee129a8dbf_b.jpg

●http://farm4.staticflickr.com/3117/2585841913_699976a643_b.jpg

●http://nvie.com/posts/a-successful-git-branching-model/

●http://yakiloo.com/getting-started-git-flow/

●http://ndpsoftware.com/git-cheatsheet.html

top related