วิธีการเชื่อมต่อ Github กับ Scrutinizer-CI

Saturday, March 7, 2015 10:49 PM 0 Comments , , , , , ,

ต่อจากบทความ วิธีการเชื่อมต่อ Github กับ Travis-CI บทความนี้ก็จะมาเล่าเกี่ยวกับวิธีการเชื่อมต่อ Github กับ Scrutinizer-CI เพื่อที่ Build & Test และจะได้มี  Badge สำหรับ Code Coverage กับ  Code Quality สวยๆมาแปะครับ

1. เข้าไปที่ Website https://scrutinizer-ci.com แล้วทำการ Login ด้วย Github

2. เมื่อ Login เรียบร้อยแล้วให้สร้าง Repository https://scrutinizer-ci.com/g/new

3. ใส่ URL Github Project ของเราที่ต้องการใช้งาน (ในที่นี่ใช้ Project นี้ https://github.com/kittinan/php-http) ดังภาพ



4. สร้างไฟล์สำหรับ Build Configuration เจ้า Scrutinizer-CI โดยใช้ชื่อว่า .scrutinizer.yml ที่ root path ของ Project และใส่ code ดังนี้ https://gist.github.com/kittinan/6baf4dd0961e18dc7812

filter:
excluded_paths: [tests/*]
checks:
php:
code_rating: true
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 1200
runs: 3
php_analyzer: true
php_code_coverage: false
php_code_sniffer:
config:
standard: PSR2
filter:
paths: ['src']
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]
php_loc:
enabled: true
excluded_dirs: [vendor, tests]
php_pdepend: true
php_sim: true

สามารถดูรายละเอียดเพิ่มเติมสำหรับ Build Configuration ได้ที่ https://scrutinizer-ci.com/docs/configuration/build

5. แก้ไขไฟล์ .travis.yml เพื่อให้ Travis-CI อัพโหลด Code Coverage ไปที่  Scrutinizer-CI ดังนี้
https://gist.github.com/kittinan/124d539cd6fbf7c5e8d5

language: php
php:
- 5.5
- 5.4
- 5.3
- hhvm
before_script:
- wget http://getcomposer.org/composer.phar
- php composer.phar install --dev --no-interaction
script:
- phpunit ./tests
- mkdir -p build/logs
- phpunit --coverage-clover build/logs/clover.xml ./tests
after_script:
- php vendor/bin/coveralls -v
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
view raw .travis.yml hosted with ❤ by GitHub


5. Push file .scrutinizer.yml และ .travis.yml  ขึ้น Github

6. สั่ง Run your first inspection ที่ Scrutinizer-CI แล้วรอสักพักใหญ่


7. เมื่อ  Scrutinizer-CI ประมวลผลเสร็จเรียบร้อยก็จะพบกับ Code Quality และ Code Coverage  ดังภาพ



8. เราก็สามารถนำ Badge Code Quality และ Code Coverage เท่ๆมาแปะที่  Github Project ของเราได้แล้วครับ https://github.com/kittinan/php-http


0 comments: