要約
- 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公式ドキュメントを参照。