LoginSignup
0
0

More than 5 years have passed since last update.

TravisCI でcomposer とbundle を両方動かして、phan も入れてみた

Last updated at Posted at 2018-10-22

やりたいこと

  • PHP のプログラムをいっぱい書いた
  • phanとか、phpcs は基本的に入れるでしょ!
  • phan とかの実行結果がそのままコードレビューのコメントとかで実行できると楽だなぁ。。
    • そうだ。saddlerをいれよう

travis.yml の設定

language: php
before_script:
  - composer install --dev
  - bundle check || bundle install --without production --deployment
  - git clone https://github.com/nikic/php-ast
  - cd php-ast
  - phpize
  - ./configure
  - make
  - make install
  - echo "extension=ast.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
  - cd ../
php:
  - 7.1
branches:
  only:
    - master
    - develop
git:
  depth: 500
  submodules: false
sudo: false
cache:
  directories:
    - $HOME/.composer/cache
    - vendor/bundle
job:
  include:
    - stage: inspection
      if: type IN (pull_request)
      script:
        - bash ./bin/phan_inspect.sh;
        -  # 後はテストしたい内容を書いて下さい

yml解説

  • before_script: に環境構築に必要な諸々のパッケージを入れる設定を書いた
    • composer のinstall
    • bundle のinstall
    • php-ast(phanの実行に必要)のinstall
  • cache の設定で少し高速化

phan_inspect.sh に書いてある内容(本物はGithubのPrivateRepoにあるよ)

#!/bin/bash

echo "Start"
TARGET_LIST=`git diff --name-only origin/$TARGET_BRANCH | grep -e '.php$'`

if [ -z "$TARGET_LIST" ]; then
    echo "PHP file not changed."
    exit 0
fi

RESULT_TEXT=`echo $RESULT | bundle exec saddler report \
    --require saddler/reporter/text \
    --reporter Saddler::Reporter::Text`
if [ -n "$RESULT_TEXT" ]; then
    if [ -n "$COMMON_PULL_REQUEST" ]; then
        `echo $RESULT | bundle exec saddler report \
            --require saddler/reporter/github \
            --reporter Saddler::Reporter::Github::PullRequestReviewComment`
    fi

    echo ""
    echo "An error has been detected,this following:"
    echo "$RESULT_TEXT"
    exit 1
else
    echo "Passed"
    exit 0
fi

補足

現在、Github でテスト中なんだけど、Github が落ちてて暇なのでQiitaに書いてみた

0
0
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
0
0