0

將放在github上的專案掛上CI-serevr吧

 2 years ago
source link: https://blog.niclin.tw/2017/01/08/%E5%B0%87%E6%94%BE%E5%9C%A8github%E4%B8%8A%E7%9A%84%E5%B0%88%E6%A1%88%E6%8E%9B%E4%B8%8Aci-serevr%E5%90%A7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

關於自動化測試

在這個世代開發網站,少不了的就是「測試」,能把寫好的測試讓機器幫你做自動化測試,只有通過才可以Merge,這樣一來保障了程式碼品質,同時也不會在有新的變動時搞砸了原有的設計或架構,在共同協作上也能更保障不會在上Production的時候弄爛了整個程式。

專案程式碼放在Github上面,但是誰來幫我做測試?

  • 你必須要先寫好測試,在Ruby上面最常聽見的不外乎是Rspec
  • 你必須要有一台Server自動Run script

如果Github是免費的,那CI-server也會有免費的吧?

這裡推薦目前很好用的服務,Travis-CI,不過要注意的是如果要讓你的Private repository也使用這個服務必須是付費的。

CI-Server

在Travis的網站上面註冊新的帳號後,就可以連結到自己的Githib上,並且可以直接選擇你的公開專案,選完之後就是進行細部設定。

設定你的Repository

先在你的專案目錄下新增一隻檔案,可以直接下指令

touch .travis.yml

並將下面的內容填上(這裡適用Rails project)


language: ruby

rvm:

- 2.3.2

bundler_args: --jobs 1 --retry 3

script:

  - bin/rake db:migrate RAILS_ENV=test

  - bin/rake

cache: bundler

詳細設定在網站的Getting start都有說明文件可以按照不同的Project去做調整

Github調整參考測試結果

1 .在你的Github專案上進入該專案的setting -> branches 將 master加入 Protected branches 2. 按下Edit進去之後就可以參考CI吐回的結果決定pull request是否可以 accept merge了

螢幕快照 2017-01-04 下午4.10.12.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK