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?

More than 3 years have passed since last update.

LaravelのCI実行時にcomposer installでCIが落ちる現象を回避したい

Last updated at Posted at 2020-07-24

要約

  • CIのcomposer install時には--no-scriptsをつけておく

概要

LaravelをGitHub Actionsでテスト実行時になぜかcomposer installで落ちる時期が突然出てきた。
ログを見るとphp artisan ide-helper:generateで毎回落ちている。

composer.json
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate"
    ],
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover",
      "php artisan ide-helper:generate", 
      "php artisan ide-helper:meta"
    ]
  }

barryvdh/laravel-ide-helperのREADME.mdによると、 Some classes need a working database connection.とのこと。

マイグレーション前にDB接続されるのは回避したい。

The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.

Some classes need a working database connection. 
If you do not have a default working connection, some facades will not be included. You can use an in-memory SQLite driver by adding the -M option.

解決策

composer install時には--no-scriptsをつけて、script実行を回避することにした。

github-bactions.yml
~~省略~~
      - name: Install Composer dependencies
        run: composer install --no-scripts
~~省略~~

こんな感じで。

composer install時の引数についてはComposer公式ドキュメントを参照。

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?