CI as a Service


Travis CI使CI使
JavaScript(JavaScript)

 Buster.JS 使

Karma (Testacular)  Karma  Travis CI CI Service

CI Services


Travis CI

drone.io

BuildHive

Jepso CI



Jepso CI 


(一)Capture

(二) capture URL 

(三)

(四)Capture


JsTestDriverTest Runner

CIGithubpush

CIUbuntuapt-getnpm使
Travis CIdrone.ioNode.jsBuildHive

travis-ci.org Travis CI


Travis CI.travis.yml




azu/Browser_CI_as_a_Service · GitHub


 Browser_CI_as_a_Service / .travis.yml 
env:
- DISPLAY=:99.0
before_script:
- sh -e /etc/init.d/xvfb start
- sh .travis/scripts/setup_busterjs.sh
script:
- npm test
language: node_js
node_js:
- 0.8

Travis CIではデフォルトでNode.js(npm)、PhantomJS、Firefoxの環境が入っているため、before_scriptでインストールするものは、Buster.JSのみとなります。

Travis CIにデフォルトで入っているものは以下で見られます

.travis.yml内に language: node_js を記述しておくと、自動で npm install を実行してくれるので、
レポジトリの Browser_CI_as_a_Service / package.jsondevDependenciesBuster.JS を追加しておきます。

{
    "author" : "azu",
    "name" : "Browser_CI_as_a_Service",
    "description" : "Buster.JS with CI Service example",
    "version" : "0.0.1",
    "scripts" : {
        "test" : "node_modules/.bin/buster-test -r specification"
    },
    "devDependencies" : {
        "buster" : "~0.6"
    },
    "engines" : {
        "node" : "~0.8"
    }
}

これで、自動で npm install が実行されれば、テスト環境が揃います。

テストの実行を設定

.travis.yml の事前準備の部分を見ていきます

env:
- DISPLAY=:99.0
before_script:
- sh -e /etc/init.d/xvfb start
- sh -e .travis/scripts/setup_busterjs.sh

before_script: で実行しているsetup_busterjs.sh は以下のような内容になってます。

#!/bin/sh

node_modules/.bin/buster-server & sleep 5 firefox http://localhost:1111/capture & sleep 5 phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture & sleep 5 if [ -x "google-chrome" ]; then google-chrome –no-default-browser-check –no-first-run –disable-default-apps http://localhost:1111/capture & sleep 5 fi





(一)GUIxvfbstart(before_script:)

(二)Capture(buster server)(setup_busterjs.sh)

(三)Firefox/PhantomJSCature URL(setup_busterjs.sh)


Travis CI: GUI & Headless browser testing on travis-ci.org



.travis.yml script:  npm test npm testBuster.JS package.json 
(language: node_js)
script:
- npm test

package.json に以下のように書いて、npm test でBuster.JSのテスト実行されるようにしました。

"scripts" : {
        "test" : "node_modules/.bin/buster-test -r specification"
    }

Travis CIの有効化


Travis CIGithub

Repositories  ON

Travis CI  Free Hosted Continuous Integration Platform for the Open Source Community 2013 03 20 17 31 36
Travis CIGithubService HooksGithubPushCI


Build Status
azu/Browser_CI_as_a_Service · GitHub 


Travis CITravis CI ClientCLICLICITravis CICLI

Travis CI Client便




Travis CI: Documentation

Travis CI  The little book of Buster.JS 1.0 documentation

Karma  Travis CI

drone.io drone.io


 drone.io 

drone.ioGithub/Bitbucket/Google Code使Github

drone.ioNode.jsPhantomJSGoogle Chrome
Firefox/PhantomJS/Google Chrome3

Admin  azu 2013 03 20 18 43 45

drone.ioTravis CI
( soft limits50/monthUnlimited)


drone.ioTravis CI(.travis.yml)

Githubdrone.io

 New Project  Github

Add Repo  drone io 2013 03 20 19 08 02
CINode.js
()



Build Setup  Browser CI as a Service 2013 03 20 19 42 58
Commands
sudo start xvfb
npm -d install
sh -e .travis/scripts/install_phantomjs.sh
sh -e .travis/scripts/install_chrome.sh
# start buster server
node_modules/.bin/buster-server &
sleep 5
# start browsers
firefox http://localhost:1111/capture &
sleep 5
phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture &
sleep 5
google-chrome --no-default-browser-check --no-first-run --disable-default-apps http://localhost:1111/capture &
npm test

npm install Buster.JS
PhantomJS(npm)Google Chrome(apt-get)

scriptazu/Browser_CI_as_a_Service · GitHub
(jubianchi/travisci-helper · GitHub
)

Travis CIbuster serverCapture URL
npm test 

Travis CI setup_busterjs.sh 

 Build Setup | Browser_CI_as_a_Service 


drone.io Build Status
azu/Browser_CI_as_a_Service · GitHub


drone.io TravisCICI

buildhive.cloudbees.com BuildHive


Jenkins
BuildHivedrone.io

Node.js
Travis CIdrone.io

Add Git Repository Github

BuildHive Cloud Continuous Integration 2013 03 20 20 32 57
  
export PATH=$HOME/.nodebrew/current/bin:$PATH
if [ ! -x "$HOME/.nodebrew/current/bin/nodebrew" ]; then
    curl https://raw.github.com/hokaccha/nodebrew/master/nodebrew | perl - setup
    nodebrew install-binary stable
    nodebrew use stable
fi

if [ -e /tmp/.X1-lock ]; then rm /tmp/.X1-lock # たまにロックがかかって死ぬので fi if [ -z "$DISPLAY" ]; then export DISPLAY=:1 Xvfb :1 & fi npm -d install node_modules/.bin/buster-server & sleep 5 firefox http://localhost:1111/capture & sleep 5 node_modules/phantomjs/bin/phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture & sleep 5

npm test


Node.jsnodebrew使

XvfbstartCaptureCapture URL
npm test 


BuildHive Build Status
azu/Browser_CI_as_a_Service · GitHub 



(Node.js buildhive for node)


jepso-ci.com Jepso CI


 Jepso CI 
CIJavaScriptJepso CIHTMLJavaScript

Sauce  testling-ci CI

使
(2013-03-20)

azu/BusterJS_JepsoCI · GitHub


CI使
QUnitHTML .jepso-ci.json 

(azu/BusterJS_JepsoCI · GitHub) test.html 
.jepso-ci.json
{
    "url": "/test.html"
}

次に、BusterJS_JepsoCI / test.html を見ていきます。

Jepso CIのテストの成否判定は、test.html内の2つのプロパティによって判定されます。

window.testsPassed;// bool
window.completedTests;// number

Buster.JSのtest runnerとなる test.html は以下のような感じです。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Buster.JS</title>
    <link rel="stylesheet" href="http://cdn.busterjs.org/releases/latest/buster-test.css">
    <script type="text/javascript" src="http://cdn.busterjs.org/releases/latest/buster-test.js"></script>
<span class="c">&lt;!-- jepso-ci --&gt;</span>
<span class="nt">&lt;script </span><span class="na">type=</span><span class="s">&quot;text/javascript&quot;</span><span class="nt">&gt;</span>
    <span class="c1">// start test</span>
    <span class="nx">buster</span><span class="p">.</span><span class="nx">testRunner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;suite:start&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">results</span><span class="p">)</span> <span class="p">{</span>
        <span class="nb">window</span><span class="p">.</span><span class="nx">completedTests</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
        <span class="nb">window</span><span class="p">.</span><span class="nx">testsPassed</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">});</span>
    <span class="c1">// each passed test</span>
    <span class="nx">buster</span><span class="p">.</span><span class="nx">assertions</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;pass&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
        <span class="nb">window</span><span class="p">.</span><span class="nx">completedTests</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">;</span>
    <span class="p">});</span>
    <span class="c1">// each failure test</span>
    <span class="nx">buster</span><span class="p">.</span><span class="nx">assertions</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;failure&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
        <span class="nb">window</span><span class="p">.</span><span class="nx">testsPassed</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
    <span class="p">});</span>
    <span class="c1">// finish all test</span>
    <span class="nx">buster</span><span class="p">.</span><span class="nx">testRunner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;suite:end&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">results</span><span class="p">)</span> <span class="p">{</span>
        <span class="nb">window</span><span class="p">.</span><span class="nx">testsPassed</span> <span class="o">=</span> <span class="nx">results</span><span class="p">.</span><span class="nx">ok</span><span class="p">;</span><span class="c1">// result boolean</span>
    <span class="p">});</span>
<span class="nt">&lt;/script&gt;</span>
<span class="c">&lt;!--test source--&gt;</span>
<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;./src/hello.js&quot;</span> <span class="na">type=</span><span class="s">&quot;text/javascript&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;./tests/async-test.js&quot;</span> <span class="na">type=</span><span class="s">&quot;text/javascript&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;./tests/hello-test.js&quot;</span> <span class="na">type=</span><span class="s">&quot;text/javascript&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>

</head> <body> </body> </html>


test.html window.testsPassed  true 
window.completedTests ++timeout

Buster.JS .on 
buster.testRunner.on("suite:start", function… はテスト開始時に初期化
buster.assertions.on("pass", function... でテストが通るたびにインクリメント
buster.assertions.on("failure", function... で一つでも失敗したらテスト失敗
buster.testRunner.on("suite:end", function... でテスト終了時にテスト結果を代入


(*.jsscript)

Jepso CIGithub


GithubPost-Receive HooksWebHook URLs https://jepso-ci.com/api/hook 

GithubpushJepso CI
Jepso CI https://jepso-ci.com/<user>/<repogitory> 


Build Status
azu/BusterJS_JepsoCI · GitHub 


HTML使SVG



Jepso CIHTML


jsFiddle使JavaScript | Web scratch


testling-ciHTML(2013-03-21)


substack/testling-html-example · GitHub

FAQ

Travis CIBuildHiveChrome使?


Travis CI Ubuntu-64bitChrome()

Chromium/Chrome does not work in an OpenVZ container · Issue #938 · travis-ci/travis-ci Issue使

 : Travis CIChrome


Chrome
Travis CIChrome


fix Google-Chrome for Travis CI · d736273 · azu/Browser_CI_as_a_Service





Travis CI  Free Hosted Continuous Integration Platform for the Open Source Community





Chromium/Chrome does not work in an OpenVZ container · Issue #938 · travis-ci/travis-ci



  1. /dev/shm のパーミッションを修正する
sudo chmod 1777 /dev/shm 
  1. Chromeの起動引数に --no-sandboxつける

Travis CIGoogleChrome
Chrome(--no-sandbox )


BuildHive  sudo 使

?


 Travis CIdrone.ioBuildHive ()

BrowserStack  testling-ci Sauce Labs 

CI Services




Travis CItravis-ci/travis-cookbooks · GitHub

gildegoma/travis-ci-inspector · GitHub調

()

Example Project


使URL


azu/Browser_CI_as_a_Service · GitHub

azu/BusterJS_JepsoCI · GitHub

Test Tools


 Buster.JS 使Test Tool

Special Thanks