Jenkins, the CI.
CI here is not an abbreviation for Confidential Informant but for Continuous Integration. In the sequel, I will discuss how to build the CI environment with Jenkins + Github.
Target sbt project
Here is a sample sbt project with specs2 testing framework. I will use this project as a CI target.
name := "expmtlSbtSpecs2" version := "1.0" scalaVersion := "2.9.1" resolvers ++= Seq( "Specs2 Repo" at "http://oss.sonatype.org/content/repositories/releases" ) libraryDependencies := Seq( "org.specs2" %% "specs2" % "1.11" % "test", "org.scala-tools.testing" %% "scalacheck" % "1.9", "org.mockito" % "mockito-all" % "1.9.0" )
Installing Jenkins on Community Enterprise OS 6
Adding jenkins.repo to rpm.repo
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
Installing Jenkins via yum
yum install jenkins
Starting up Jenkins
sudo /etc/init.d/jenkins start
Now your Jenkins is listenning to port 8080. Go to http://yourhost:8080. Jenkins will be compiled when the first access has made, so it may take some time before you see the rendered page. Now we move to configuration of Jenkins. There are 2 kinds of configuration:
- Global Settings
- Project Settings
In the Global Settings
[Jenkins Home -> Manage Jenkins -> Configure System]
we configure Git path, JDK path, SBT path ... something that Jenkins uses for CI.
In the Project Settings
[Jenkins Home -> Project Page -> Configure ]
we configure project build options, github repository ... something depending to the project.
Activating Security
By the default setting, anybody has full access to the Jenkins, which means anybody create jobs and run the build. That's no good at all. Running builds consume a lot of resources. We need to restrict certain actions to certain users. To do that, go to
[Manage Jenkins -> check Enable Security]
And configure followings:
Security Realm
- check Jenkins's user database
- check Allow users to sign up
Authorization
- check Matrix-based security
Add user by using
[User/group to add:]
- check all attributes for your username (an administrator)
- Do not forget to check Read[Overall] for Anonymous
Installing plugins.
I'm going to create the job that build sbt project I defeined previously. Jenkins will build the project and run the test when changes are pushed to the configured github repository. Firstly, we need plugins to build the sbt project and synchronize with github. Go to
[ Jenkins Home -> Manage Jenkins -> Manage Plugins ]
And install the following:
- Jenkins sbt plugin
- Github plugin
Configuring plugins.
Now we need to configure plugins we installed previously in order to make sure these work correctly.
Go to
[Jenkins Home -> Manage Jenkins -> Configure System]
Sbt
Descriptor | value |
Name | sbt |
Path | /path/to/sbt-launch.jar |
Global Github setting.
Here you need to set WebHook. Basically what this does is that if you push to github repo, github POST the JSON to Jenkins so the Jenkins know that changes are made.
Go to
[Jenkins Home > Manage Jenkins -> Configure System]
GitHub Web Hook
Descriptor | value |
Let Jenkins auto-manage hook URLs | selectected |
Override Hook URL | http://yourdomain/github-webhook/ |
GitHub Credentials | set your github account and password |
Create a new job
Now we are going to make a new job. To make a new job,
[Jenkins Home -> New Job]
Select [Build a free-style software project] and click [OK].
Configuring the job.
Now we are going to configure the job we made previously. Go to the Jenkins home and you will find the project. Go to the project page and go to [Configure]. Following is the settings you want.
General
Descriptor | value |
Project name | Your Project Name |
GitHub project | https://github.com/username/YourProject/ |
Source Code Management
Descriptor | value |
Git | https://github.com/username/YourProject.git |
Branches to build | develop / master / * / ** etc |
Build Triggers
Descriptor | value |
Build when a change is pushed to GitHub | checked |
Build
Descriptor | value |
sbt | selected |
JVM Flags | -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M |
sbt Flags | -Dsbt.log.noformat=true |
Action | clean test |
CodeTime: Testing AK47 with JUnit.
東京マルイ AK47 β(ヴェータ)スペツナズ ニッケルフルセット
- 出版社/メーカー: 東京マルイ
- メディア:
- この商品を含むブログを見る
JUnit
Reference: http://www.jetbrains.com/idea/webhelp/configuring-testing-libraries.html
JUnit is a testing framework for Java as far as I know, and I use it for the first time. After some research on google, now I know that JUnit comes with intelliJ IDEA. I'm using intelliJ, so try it. Basically what you have to do to make the test code is highlighting the class you want to test and press ⌘(CTRL) + Shift + T. Boom! Dialog will soon pop up.
Click OK to generate test class. Now let's make some test and see how it works.
Here is the AK47 I will test with JUnit ... For the sake of ease of test, I leave ammo and safety as public properties.
package models.guns; public class AK47 implements Firearm { public final String cartridge = "7.62x39mm M43/M67"; public Integer ammo = 20; public Boolean safety = false; public void shoot(){ if(ammo == 1){ reload(); }else{ ammo--; } } public void reload(){ ammo = 20; } public Boolean isSafetyOn(){ return safety; } public void switchSafety(){ safety = !safety; } }
Now initiate the dialog with ⌘(CTRL) + Shift + T. Check all the methods you want to test. This will automatically generates the scheme for ya. FYI, sometimes it generates some lines that you don't want. If you don't like such behavior, then just leave all the methods unchecked.
package models; import junit.framework.TestCase; import org.testng.annotations.Test; public class AK47Test extends TestCase{ @Test public void testShoot() throws Exception { AK47 ak47 = new AK47(); assertEquals(ak47.cartridge, "7.62x39mm M43/M67"); ak47.shoot(); assertSame(20 - 1, ak47.ammo); } public void testReload() throws Exception { AK47 ak47 = new AK47(); for(int i = 0; i < 20; i++){ ak47.shoot(); } assertSame(20, ak47.ammo); ak47.reload(); assertSame(19 + 1, ak47.ammo); } public void testIsSafetyOn() throws Exception { AK47 ak47 = new AK47(); assertSame(false, ak47.isSafetyOn()); } public void testSwitchSafety() throws Exception { AK47 ak47 = new AK47(); ak47.switchSafety(); assertSame(true, ak47.isSafetyOn()); } }
Tests all passed. Seems my AK47 is in good condition. Let's lock n load.
Aspell, your savior.
Spelling (Grades 1 - 2) (Step Ahead)
- 作者: Sharon Hoover
- 出版社/メーカー: Golden Books
- 発売日: 2000/03/15
- メディア: ペーパーバック
- クリック: 2回
- この商品を含むブログ (2件) を見る
Misspelling is embarrassing
As I misspelled the word, embarrassing, for 5 times before I finally spelled correctly, misspelling occurs every 10 minutes or so when you are writing foreign language. And of course misspellings of simple words like shcool, dicsionary, ... are pretty embarrassing when it is revealed to educated people.
Here is the way you can reduce the misspelling by using the help of computers.
These commands list you up misspelled words in shellscript comments.
cat shell.sh | grep -P "^#" | sed s:#::g | aspell -a --lang=en
If you simply want to check if there is no misspelling in the text file, do the following
aspell --lang=en misspelled.txt
sed is actually seductive
- アーティスト: 50 Cent
- 出版社/メーカー: Universal Import
- 発売日: 2005/04/05
- メディア: CD
- この商品を含むブログを見る
Why I failed.
Yesterday I was trying to implement array_unique compliant on shellscript. The attempt failed, but this morning I found out the reason why it didn't work. The answer is the difference between BSD sed command and GNU sed command. Both sed command treat white space and newline differently. What I meant by that is
echo -e "AK47\nM16\nM14\nAA12" | sed 's/\s/\n/g'
will work fine on GNU sed, but it doesn't work on BSD sed. Instead you should write like
echo -e "AK47\nM16\nM14\nAA12" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'
Finally, we get array_unique compliant on shellscript.
# Non-unique array Array=(AK47 M16 MP5 MP5 M16 AK47 AA12) # This will work on both BSD sed and GNU sed. ArrayUnique=$(echo ${Array[@]} | sed $'s/ /\\\n/g' | sort | uniq | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')
sed is not seductive.
マルイ 89式 小銃 折曲式銃床 本体+バッテリー+充電器 マスターフルセット
- 出版社/メーカー: 東京マルイ
- メディア: おもちゃ&ホビー
- クリック: 17回
- この商品を含むブログを見る
Failed attempt: array_unique compliant on shellscript
I've just started writing shellscript. I am noob and unfortunately, stupid enough not to be able to write array_unique compliant by myself. I wanted to know the way to elegantly implement array_unique compliant on shellscript, but Google didn't help me out.
FYI, I pasted the code supposed to work correctly as far as I expect.
#!/bin/bash # Array containing non-unique elements ArrayNotUnique=(AK47 SR-16 MP5 M4 MP5 AA-12 AK47 Type89 AK47) # It doesn't work! f*! $UniqueArray=($(echo ${ArrayNotUnique[@]} | sed s/\s/\n/g | sort | uniq | sed s/\n/\s/g))
I don't understand.
Hackintosh: XFX 6870 Quad Display Revealed
Things you need to know
When I first use Mac, that was an astonishing experience I've never had, as Steve Jobs promised. As both an entertainment platform and a development platform, it has been and going to be the best choice from computers on the market. Still, I must admit that Mac is the expensive computer despite its awesomeness. Yes, the awesome experience I had on that machine is not possible without highly optimized connection between Hardware and Software like no other existing Operating Systems have. Since Apple started to ship intel architecture based Mac, the movement called Hackintosh begun. That is the attempt to run the Mac OS X on DOS/V hardware. Once you had a correct hardware configuration, you are able to have PC running OS X, in other words, Poor Man's Mac. PC Mac won't promise you a literally perfect Mac experience; however, taking account the half the price, Hackintosh is the best choice if you want a cheap Mac. In this entry, I will provide the complete guide building PC Mac with specified M/B, CPU and GPU. Like I said, OS X designed to run on specially designed hardware, the most important thing is to choose right hardware. I'm going to use following components listed below. The goal is to build the PC Mac with quad display enabled(one from DVI, one from HDMI, two from DP), audio enabled and networking enabled(RadeonHD6870 supports up to 6 displays on Windows).
Note: Although the procedure in the sequel might work in other component configuration, it is strongly recommended that checking other blog posts or something mentioning about hardware configuration similar to yours(Focusing on MB and GPU).
If you want to check out whether your PC is able to run OS X, google keywords: Unibeast, CustMac, osx86. The search results will help you a lot. (I think you will do that anyway)
Component | Identity | |
---|---|---|
M/B | intel DP55WG LGA1156 Motherboard | |
CPU | intel Core i7 870 | |
GPU | XFX RadeonHD6870 | |
SSD | Sumsung 830Series SSD 128GB | |
RAM | UMAX DDR3 1333 2GB x 4 | |
PSU | Corsair TX850 | |
DISP | LG E2241 (1920x1080) x 4 |
Requirements
Unfortunately, to proceed, you have to meet all the requirements listed below.
- Mac running Snow Leopard or greater
- USB thumb drive with 8GB or greater capacity
- Mac OS Lion Install Package purchased on Apple App Store
- HDMI cable
- DP -> DVI Active Converter Buy on Amazon x 2
- Basic knowledge of building PC from parts
- Patience
That's all you need, now you are ready to enter the Hackintosh world.
Step1 - Getting ready your PC
We don't want to encounter a trouble caused by extra hardware like PCI cards and USB devices, so before beginning the installation process, please unplug all unnecessary hardware from you PC. All you need are MB, CPU, PSU, RAM, SSD you will install Mac on and GPU.
Step2 - Install OS X Lion on your PC
Go to UniBeast: Install Mac OS X Lion Using an All-In-One Bootable USB Drive
Follow the instructions.
Note: Do not go over STEP4 If you finished install and booted from HDD, come back here. I will cover all MultiBeast post installation procedure.
Step3 - Post installation set up
Open up MultiBeast and install drivers shown in the picture. Since DP55WG uses Realtek ALC889 chip and intel 1000e Ethernet chip, we are going to install that drivers over MultiBeast. Once you install all drivers listed below, your Hackintosh is ready to use. Make sure not to install DSDT from DSDT database on tonymacx86.com with the option: UserDSDT Install. It will only gives you a Kernel Panic after reboot. Instead of using DSDT from website, you are recommended to use EasyBeast. EasyBeast basically enables you to boot the OS X from HDD without USB bootable thumb drive we used in installing process. If you don't want to install MBR to your disk, then keep it unchecked. In that case, you need thumb drive to boot up the machine. After installation, Audio I/O and Networking should be working perfectly. In the next section, I will show you how to enable 4 ports on XFX RadeonHD6870.
Step4 - Enabling ports on GPU
Now, this part is the main purpose of this article. We are going to enable 4 displays on a Mac! We can NOT use lower DVI ports because Mac Pro only has one DVI port! Actually, there is a way to activate it. Check out the forum post: Getting XFX 6850 connectors working if you want to step in to the really dangerous zone. Unless you do that, the ports you can use are 4 ports listed below. If your display natively supports DP, you don't need miniDP->DVI Active Converter.
Note: You need an Active Converter not a Passive Converter.
Upper DVI port -> LCD1
Lower DVI port -> Disabled
HDMI port -> LCD2(max resolution 1920 x 1080)
miniDP1 -> miniDP--DVI Single-Link Active Converter -> LCD3
miniDP2 -> miniDP--DVI Single-Link Active Converter -> LCD4
To enable the ports, you have to choose right Profile and Ports. To do that, you change boot.plist file in your
/Extra/
directory. If you followed my instruction, then you will find the
/Extra/org.chameleon.Boot.plist
file. It's an xml file. Open it up with Vim text editor, and change these lines:
<key>Kernel Flags</key> <string>ncpi=0x3000 darkwake=0 AtiConfig=Duckweed AtiPorts=5</string>
Add this line to avoid flickering display via miniDP at login screen. You might want to change the values according to your display specification. Without this lines, you have to reconnect DP every time you boot up the machine!
<key>Graphics Mode</key> <string>1920x1080x32</string>
After reboot, you have 4 displays working. That's it! Enjoy your Hackintosh!