[Play 2.0] Example about how to test your Play2 applications with GitHub and Travis CI

363 views
Skip to first unread message

gildegoma

unread,
Apr 14, 2012, 12:42:08 PM4/14/12
to play-fr...@googlegroups.com
Hi Play2 Developers !

Are you interested in free and powerful Continuous Integration for your applications based on Play2 Framework ? Yes, so just try Travis CI!

Here is an example about how you can test a Play2 application on Travis: https://github.com/gildegoma/travis-ci-ScalaOnPlay-sample
The current example runs the test with release 2.0 (other variant would consist in building all from source, Play20 included (see pending issue https://github.com/gildegoma/travis-ci-ScalaOnPlay-sample/issues/1)

Have fun! Feedbacks are welcome...
Gilles

Some more notes (a bit out of post's scope, sorry I can't resist to drop some more ideas in the air ;-)
  • I'm pretty sure it will be easy to setup testing of Play2 Modules on Travis as well, but I did not work on that point so far. 
  • For people interested about how to build Play20 framework itself on Travis, you can have a look on https://github.com/gildegoma/Play20/tree/pr-integrate-travis-ci. So far I have not opened any pull request on master project (I think that according to current guidelines of Play20 project such kind of change would not be evaluated for now). Even if main project is tested on cloudbees, I think it could be a nice improvement for the general fork/pull-request community process, if PRs are publicly tested by Travis, before their integration.

Matthieu

unread,
Apr 23, 2012, 4:36:41 PM4/23/12
to play-fr...@googlegroups.com
Thanks your example.

I just had to do a 'chmod +x travis/setup' in order to avoid an error on Travis and then it worked like a charm.

Matthieu

Ivan Meredith

unread,
Apr 23, 2012, 6:21:43 PM4/23/12
to play-fr...@googlegroups.com
CloudBees have a service in early beta called BuildHive. It provides
a one-click integration with github to set up jobs from repos. You do
not need a CloudBees account to use it, just oauth with github.

For play2 it needs no extra files at all to build.

https://buildhive.cloudbees.com/

As I said above, it is in early beta - so we are looking for feedback
and it may not work 100% just yet. However I have a play2 app building
on it :)

- Ivan, CloudBees Engineering

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/3TjrtFW8vU4J.
>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

gildegoma

unread,
Apr 24, 2012, 7:10:46 PM4/24/12
to play-fr...@googlegroups.com
Hi again Ivan,

I noticed a few more things after sending my first response, hence these updates:

I found where you can configure:
  • branches to build :-)
  • the shell script to run for 'unkown template' project :-) but if a template has been found (e.g. 'sbt'), shell script cannot be redefined... :-/
Your play2 sample indeed builds well with 'sbt clean test', that install Play2 dependencies on the fly (https://buildhive.cloudbees.com/job/hadashi/job/play2-test-app/lastBuild/console):

[info] Resolving play#play_2.9.1;2.0 ...                                         
[info] Resolving play#templates_2.9.1;2.0 ...

But the build run #1 of my sample project failed a few steps before because commons-httpclient.jar was not possible to download (see https://buildhive.cloudbees.com/job/gildegoma/job/travis-ci-ScalaOnPlay-sample/lastBuild/console).

Can I force a new job to start? I cannot find a manual trigger...

Anyway, thanks again for the very interesting news... being impatient for next steps (more documentation, more stable service, more features :).

Regards, Gilles

gildegoma

unread,
Apr 24, 2012, 7:19:13 PM4/24/12
to play-fr...@googlegroups.com

Hi Ivan! 

SORRY: I mixed myself and my 'second' answer has been posted while I actually failed to send first reponse... which I include now. Sorry, I think I better have to read Google Groups Help, but it's time to sleep now :-/

Thank you for the announcement. BuildHive/GitHub integration is smooth, quite similar as Travis/GitHub. Nice concurrence in perspective! 

I actually tested 3 Projects (1 Play2 and 2 pure Scala) with following results:

Configuration auto-detection are nice features, but anyway it is a must to let user override/reconfigure default settings... Travis-CI is already quite mature, BuildHive can for sure take some good influences from it :-). 

on https://buildhive.cloudbees.com/template/, I see that the list of build templates is already quite nice (sbt, maven, gradle, bundler/rake, ...). I would recommend you to setup a Play2 template, and then BuildHive wins one point in the race with Travis ;-) 

I am looking forward a new discussion thread about BuildHive upcoming features !

Cheers, Gilles

gildegoma

unread,
Apr 24, 2012, 7:42:52 PM4/24/12
to play-fr...@googlegroups.com

Hi Matthieu,

Thank you very much for the feedback! Yeah, missing 'x' permission is common pitfall when doing copy-paste of shell script content. Actually, I created this extra script 'travis/setup' in a Don't Repeat Yourself and clean code spirit, but it's not straightforward and maybe error-prone...

I thus created another variant where the complete Travis settings fit in main .travis.yml (no more extra shell script to integrate into project). Check it here: https://github.com/gildegoma/travis-ci-ScalaOnPlay-sample/blob/travis.yml-only/.travis.yml (not yet merged into master)

Let me know which variant you find better... My current feeling: +1 for this new variant (everything in .travis.yml).

Precision: Comments from Ivan Meredith show how Play projects can auto-download the Play dependency via Maven/Ivy/sbt. This is also quite nice way to do it, and it works fine either on BuildHive/Jenkins or Travis. My idea here was merely to save download time/traffic, with only a single file to download (play-2.0.zip release), which is also matches with Installation Guide of Play Framework (see http://www.playframework.org/documentation/2.0/Installing)

Regards, Gilles

Ivan Meredith

unread,
Apr 24, 2012, 7:56:36 PM4/24/12
to play-fr...@googlegroups.com
Thanks for the feedback!

SBT detection sucks atm because I only made it work for play2. Ive
updated it a bit and now it detects akka and maybe others.

I will work on getting things going. However, your play2 app should be
working, unsure why its not.

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/play-framework/-/d7_bLE5ZEkQJ.

Ivan Meredith

unread,
Apr 24, 2012, 8:13:19 PM4/24/12
to play-fr...@googlegroups.com
Can you try making those jobs again? I've updated the template

On 25 April 2012 11:19, gildegoma <gilles...@gmail.com> wrote:

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/play-framework/-/d7_bLE5ZEkQJ.

Matthieu

unread,
Apr 25, 2012, 2:04:51 AM4/25/12
to play-fr...@googlegroups.com
Hi Gilles,

I've just tested the variant with all the configuration in the .travis.yml file and it works well. 

I prefer this variant because It's easier to understand and configure, and it also reduces the risk of error.


Matthieu

Gilles Cornu

unread,
Apr 25, 2012, 6:41:47 AM4/25/12
to play-fr...@googlegroups.com
Hi Ivan,

I started a second job for Akka, and now 'sbt' detection indeed works fine, but the related command ('sbt test') is not valid in BuildHive environment. You should either:
- directly execute java -jar /opt/sbt/sbt-launch-0.11.0.jar clean test (as you do for your Play project)
or
- configure some symlink/script alias to "java -jar /opt/sbt/sbt-launch-0.11.0.jar" (example: https://github.com/mxcl/homebrew/blob/master/Library/Formula/sbt.rb#L10)


I also tried to re-run my Play2 app sample, but it still fails on the same step


My questions and remarks are now:
- It seems that the project workspace is permanently stored on BuildHive server-side between test runs. That's quite fine…
- Now I'm not able anymore to find the Menu 'configure' in the project context (where it was possible to select which branches must be built, which test script must be executed,…)
- I would recommend to start a new discussion thread dedicated to BuildHive itself (maybe on another group?). It's going to get messy here…

I found interesting documentation http://wiki.cloudbees.com/bin/view/DEV/BuildHive. Maybe we can further collaborate through IRC #cloudbees channel, as proposed in BuildHive help.

I'm looking forward to seeing these jobs succeed on BuildHive ;-)

Gilles Cornu

unread,
Apr 25, 2012, 6:43:03 AM4/25/12
to play-fr...@googlegroups.com
Hi Mathieu,

Thanks for positive feedback, I thus merged it to master :-)
Reply all
Reply to author
Forward
0 new messages