LoginSignup
5
5

More than 5 years have passed since last update.

PHP + Travis CI + Coveralls + Code Climate

Posted at

Travis CI その他諸々を使ってみた作業ログ。

ソースは https://github.com/nishimura/laiz-monad これ。
すべてGitHubアカウントでログインするので設定が超早い。

Travis CI

テスト自動化。

# .travis.yml
language: php

php:
  - '5.6'
  - '7.0'
  - hhvm
  - nightly

before_script:
  - composer install --dev --no-interaction

script:
  - vendor/bin/phpunit

Travis CIのサーバーにphpunitが入っているので、vendor/bin/phpunitじゃなくても良い。
その場合はlanguageとphpバージョンだけ指定すれば良さそう。

パッケージルートにphpunit.xmlを書いている。

<phpunit bootstrap="vendor/autoload.php" colors="true"
         forceCoversAnnotation="false"
         verbose="true"
         >
  <testsuites>
    <testsuite name="Laiz\Monad Test">
      <directory>test/src</directory>
    </testsuite>
  </testsuites>

  <filter>
    <whitelist>
      <directory>src</directory>
    </whitelist>
  </filter>
</phpunit>

タイプヒンティングのエラーチェックで、PHP7のTypeErrorとPHPUnit_Framework_Errorの両方対応するのにちょっと困った。

Coveralls

CIサービスを利用したカバレッジ測定サービス。

  "require-dev": {
      "satooshi/php-coveralls": "dev-master"
  }
language: php

php:
  - '5.6'
  - '7.0'
  - hhvm
  - nightly

before_script:
  - composer install --dev --no-interaction

script:
  - mkdir -p build/logs
  - vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_success:
  - travis_retry php vendor/bin/coveralls -v

ネットで検索した情報は古いのが多かったのでgithubを見ながらやるのが良い。

Code Climate

静的解析。
GitHubアカウントでログインすれば特に設定の必要はない。
PHPも https://codeclimate.com/features 機能説明のサンプルにあるように普通に対応してた。

テストカバレッジもこっちでやりたい場合は

  "require-dev": {
      "codeclimate/php-test-reporter": "dev-master"
  }
language: php

php:
  - '5.6'
  - '7.0'
  - hhvm
  - nightly

before_script:
  - composer install --dev --no-interaction

script:
  - mkdir -p build/logs
  - vendor/bin/phpunit --coverage-clover build/logs/clover.xml

addons:
  code_climate:
    repo_token: #token#

このような設定に変更。
codeclimate/php-test-reporter を入れると satooshi/php-coveralls も入る。

でも何となく Coveralls の方が見やすいので両方使った。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5