Oct 29, 2022
0
Level 1
How to properly set-up Heroku CI Pipeline for Laravel in app.json
Currently, I'm using the Heroku's app.json for testing Pipeline in this manner:
{
"environments": {
"test": {
"buildpacks": [
{ "url": "heroku/php" },
{ "url": "https://github.com/heroku/heroku-buildpack-google-chrome" }
],
"scripts": {
"test-setup": "nohup bash -c 'cp .env.dusk-phpunit-heroku.testing .env' && nohup bash -c 'sudo chmod -R gu+w storage' && nohup bash -c 'sudo chmod -R guo+w storage' && nohup bash -c 'sudo chmod -R gu+w bootstrap/cache' && nohup bash -c 'sudo chmod -R guo+w bootstrap/cache' && nohup bash -c 'sudo chmod -R 777 bootstrap/cache' && nohup bash -c 'php artisan key:generate' && nohup bash -c 'sudo apt update --yes' && nohup bash -c 'sudo apt install postgresql --yes' && nohup bash -c 'sudo service postgresql start' && nohup bash -c 'sudo -u postgres createdb moje_clanky_core_testing' && nohup bash -c 'sudo -u postgres psql -c \"ALTER USER postgres WITH PASSWORD 'braf';\"' && nohup bash -c 'php artisan migrate:reset' && nohup bash -c 'php artisan migrate' && nohup bash -c 'php artisan db:seed'",
"test": "nohup bash -c 'vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Feature --stderr' && nohup bash -c 'vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Integration --stderr' && nohup bash -c 'vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Unit --stderr' && nohup bash -c './vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 &' && nohup bash -c 'php artisan serve --no-reload > /dev/null 2>&1 &' && php artisan dusk"
}
}
}
}
As you may see, this is really terrible for readability, and worse, the Heroku test gives me an error that is not descriptive and I don't know where the error can be.
My question is how can I split the commands for the Laravel setup, so it's readable and usable, something like in the case of GitHub Actions?
# ...
- name: Databse Migration and seed
run: |
php artisan migrate:reset
php artisan migrate
php artisan db:seed
- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver --detect
# ...
Please or to participate in this conversation.