scrutinizer-ciとGitHubの連携によるCI
scrutinizer-ci.comは、GitHubのpublicなリポジトリだったら無料でCIを回してくれます。これがコードの品質を維持するのによいのですが、とあるプロジェクトでcomposerがうまくいかなくてエラーを出し続ける自体に遭遇しました。
composerのinstallでエラー
You are using Composer 1 which is deprecated. You should upgrade to Composer 2, see https://blog.packagist.com/deprecating-composer-1-support/
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 will be shutdown on August 1st 2025. You should upgrade to Composer 2. See https://blog.packagist.com/shutting-down-packagist-org-support-for-composer-1-x/
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
「composerのバージョンが古い」ということなんですが、手元で使っているものは当然1系ではないですし、scrutinizerのなかでcomposerの1系をinstallしようとしている問題でしょ?……と、思うのですが、ハマってしまいました。
ほかにもcomposerの入ったプロジェクトでscrutinizer-ciを使わせてもらっていたことがあるんですが、同様の事態に遭遇したこともありませんでした。
scrutinizer.yml
こういうときには設定変更かしらと、最小限構成のYAMLを突っ込んだところ、エラーがでなくなりました。
checks:
php: true
build:
dependencies:
override: true
nodes:
analysis:
tests:
override: [php-scrutinizer-run]
filter:
paths: ["src/*"]
本当の解決
上記をやってscrutinizer-ciをかけてわかったのですが、composerのinstallをスキップすると、use Vendor\Class;
みたい依存をチェックできなくなるのですね。結果、bug
の誤検知がたくさん出てしまいました。
本当の解決としては、「composer.lock
を.gitignore
に加えないで、commitする」でした(つまりcomposer.lock
もGitHubのリポジトリに加える)。
これで依存関係込みでチェックをしてくれるようになりました。