0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub + scrutinizer-ciでcomposerがエラーを出すときの対応

Last updated at Posted at 2024-12-30

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のリポジトリに加える)。

これで依存関係込みでチェックをしてくれるようになりました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?