Open m-tmatma opened 5 years ago
調査中だけど現状こんな状態です。 codeclimate のサポートに質問したところ、 docker を使ってローカルで試してほしいと回答あったので、ローカルで調査中です。
以下は Fedora 29 で実行しました。
$ sudo dnf install -y docker
$ sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
$ sudo systemctl start docker
$ sudo docker pull codeclimate/codeclimate
Using default tag: latest
Trying to pull repository docker.io/codeclimate/codeclimate ...
sha256:8daae57e179cbbb84a1e3668dc056b441a34445e047a5f6fc96a00a27900da11: Pulling from docker.io/codeclimate/codeclimate
3489d1c4660e: Pull complete
a573b8415c39: Pull complete
751d35716411: Pull complete
7cf050728789: Pull complete
5151597413c5: Pull complete
2ad11156f5bc: Pull complete
e6fd3efc3075: Pull complete
f08b7d7f5f7e: Pull complete
55d381ab6c0e: Pull complete
3c61b25c3a5d: Pull complete
Digest: sha256:8daae57e179cbbb84a1e3668dc056b441a34445e047a5f6fc96a00a27900da11
Status: Downloaded newer image for docker.io/codeclimate/codeclimate:latest
$ git clone https://github.com/test-m-tmatma/sakura.git
$ cd sakura
$ git checkout -b feature/codeclimate origin/feature/codeclimate
Branch 'feature/codeclimate' set up to track remote branch 'feature/codeclimate' from 'origin'.
Switched to a new branch 'feature/codeclimate'
$ sudo docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate help
Usage: codeclimate COMMAND ...
Available commands:
analyze [-f format] [-e engine[:channel]] [path] Run analysis with the given arguments
console Open a ruby console for the CLI. Useful for developing against the CLI.
engines:install Pull the latest images for enabled engines in your configuration
engines:list List all available engines
help [command] Display help information.
prepare [--allow-internal-ips] Run the commands in your prepare step.
validate-config Validate your .codeclimate.yml or .codeclimate.json.
version Display the CLI version.
エラーが発生
$ sudo docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze
Starting analysis
error: (Errno::EACCES) Permission denied @ dir_initialize - .
$ sudo docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate validate-config
No checked in config: nothing to validate.
$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/codeclimate/codeclimate latest cc186d9141fd 7 weeks ago 109 MB
codeclimate の導入を検討する https://codeclimate.com/quality/
codeclimate は CodeFactor と同様に Cloud 対応の静的解析ツールです。 (カバレッジも扱うことができるみたいですが試していません。)
CodeFactor があるのに新たなものいる? と思われるかもしれませんが、 プラグインを有効にすることにより cppcheck の解析を行うことができます。 https://docs.codeclimate.com/docs/cppcheck
appveyor 等各種 Cloud サービスと同様に権限を与えた上で
.codeclimate.yml
の 設定ファイルを置くことにより、cppcheck などの静的解析を行ってくれます。 プラグインの設定も.codeclimate.yml
のファイルで行います。appveyor 等の CI に依存しないので、appveyor では cppcheck の実行をなくして ビルド時間の短縮を行うことができます。また、cppcheck を PR のたびに確認 することができて、何の警告が増えたかあるいは減ったかを簡単に確認できます。
なお、codeclimate で報告された警告をあえて無視する場合、
approve
を押せば 警告が出てるけど一括で無視します、ということも可能です。実例
サクラエディタとは全く全然別のプロジェクトで導入して動いています。
issue 一覧 https://codeclimate.com/github/JunSotaSoftware/Backup/issues
PR の例
https://github.com/JunSotaSoftware/Backup/pull/13
過去のビルド
https://codeclimate.com/github/JunSotaSoftware/Backup/builds
badge
https://github.com/JunSotaSoftware/Backup
現状の問題点
サクラエディタのソース (fork) で実行した場合、制限時間内に終わらずにタイムアウトになります。 https://codeclimate.com/github/test-m-tmatma/sakura/builds/5
原因および対策の調査中です。
codeclimate のうれしいところ
おそらく 15 ビルドまで同時に実行できます。 (https://docs.codeclimate.com/docs/enterprise-analysis-settings)
※ URL に enterprise が入っているのでひょっとしたら 15個まで というのは有料版だけかもしれません。
This default for this option is 15.
とあるのでもっと増やせるのかもしれません。 現時点で 3 つまで同時実行可能なのは確認しています。必要な権限
https://docs.codeclimate.com/docs/setting-github-oauth-permission-levels
ログインに使用するために email アドレスにアクセスします。 リポジトリにアクセスします。
なお、リポジトリのアクセス権に関しては GitHub 自体にリポジトリへの読み込み権限 という権限がないために書き込み権限も付与される、と説明されています。
このことに関しては GitHub のサポートに確認して裏を取っています。