Currently, I'm using 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?
steps:
- uses: actions/checkout@v2
- name: Prepare The Environment
run: cp .env.dusk-phpunit.testing .env
- name: Create bootstrap/cache directory
run: sudo mkdir bootstrap/cache
- name: Preparing permission
run: |
sudo chmod -R gu+w storage
sudo chmod -R guo+w storage
sudo chmod -R gu+w bootstrap/cache
sudo chmod -R guo+w bootstrap/cache
sudo chmod -R 777 bootstrap/cache
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug
- name: Install Composer Dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Generate Application Key
run: php artisan key:generate
- name: Create DB
run: |
sudo apt update --yes
sudo apt install postgresql --yes
sudo service postgresql start
sudo -u postgres createdb moje_clanky_core_testing
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'braf';"
- name: Checking key
run: echo "The key is:${{env.DB_PASSWORD_TESTING}}"
- name: Databse Migration and seed
run: |
php artisan migrate:reset
php artisan migrate
php artisan db:seed
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
CACHE_DRIVER: array
SESSION_DRIVER: array
QUEUE_DRIVER: sync
run: |
vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Feature --stderr
vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Integration --stderr
vendor/bin/phpunit --bootstrap ./vendor/autoload.php ./tests/Unit --stderr
- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver --detect
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux &
- name: Clear caches
run: php artisan optimize:clear
- name: Run Laravel Server
run: php artisan serve --no-reload &
- name: Run Dusk Tests
run: php artisan dusk -vvv
- name: Upload Dusk fail screenshots
if: failure()
uses: actions/upload-artifact@v2
with:
name: dusk-fail-screenshots
path: tests/Browser/screenshots/failure-*
retention-days: 1