Travis CI and Laravel Dusk - laravel

I have just added the tests with Laravel Dusk.
Everything works if I test on my pc. I thus set up a travis.yml file :
language: php
sudo: required
dist: trusty
php:
- 7.1
- 7.2
addons:
chrome: stable
services:
- mysql
install:
- cp .env.travis .env
- mysql -e 'create database homestead_test;'
- travis_retry composer self-update
- travis_retry composer install --no-interaction
- php artisan key:generate
- php artisan migrate:fresh --seed
before_script:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
- php artisan serve &
script:
- php artisan code:analyse --level=7
- php artisan dusk
- vendor/bin/phpunit
notifications:
email: false
However, when I push on Github I obtains errors : show travis errors
I does not understand to make how so that my tests work on travis.
Would anybody know how to help me on this point? Best Regards, Quentin
Update :
The exact commit on github

The issue is SESSION_DRIVER=array in your .env.travis file, change it to SESSION_DRIVER=file.
The login tests aren't working because the sessions vanish after each request.

Related

laravel CI / CD Development

Can anyone point me in the right direction for the Laravel CI/CD Development in code commit AWS?
I have gone through a lot of tutorials but always fail to connect the Database to either elastic beanstalk or EC2,
Can someone recommend a good tutorial for this
This is my build Command.
version: 0.2
phases:
install:
runtime-versions:
php: 7.4
nodejs: 12.x
commands:
- apt-get update -y
- apt-get install -y libpq-dev libzip-dev
- apt-get install -y php-pgsql
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
pre_build:
commands:
- cp .env.beta .env
- composer install
- npm install
build:
commands:
- npm run production
- php artisan migrate --force
- php artisan db:seed
artifacts:
files:
- '**/*'
name: $(date +%Y-%m-%dT%H:%M:%S).zip
proxy:
upload-artifacts: yes
logs: yes
now i am getting ngnix 404 error,Even after adding " /public " in beanstalk

LARAVEL v9.21.6 plugin v0.5.2

I use docker (sail) and I will use Breeze and I do everything was into the documentation
sail require laravel/breeze --dev
sail artisan breeze:install react
sail npm install
sail npm run dev
Everything was ok until I put sail npm run dev command becouse it display me error like in title of this post
LARAVEL v9.21.6 plugin v0.5.2
I don't know what plugins are involved. How can I solve this problem?
#Update
> dev
> vite
VITE v3.0.3 ready in 459 ms
➜ Local: http://localhost:5173/
➜ Network: http://IP:5173/
LARAVEL v9.21.6 plugin v0.5.2
➜ APP_URL: http://hello.test
But I can't after run command
sail npm run watch
Can you try clear all cache;
php artisan optimize:clear
After that enter maintenance mode;
php artisan down
Than publish again;
php artisan up

Artisan can't connect to composer in containers

I am doing laravel application and installing Laravel jetstream in Docker containers. I have separate containers for composer and artisan. And when I try to install jetstream by command:
docker-compose run --rm artisan jetstream:install inertia
I get an error:
Starting mysql ... done
sh: exec: line 1: composer: not found
Unable to locate publishable resources.
Publishing complete.
Inertia scaffolding installed successfully.
Please execute the "npm install && npm run dev" command to build your assets.
The webpage still doesn't work with error message Class 'Inertia\Inertia' not found. I assume there is a problem with connection between composer and artisan containers, but how I can set up this connection?
Docker-compose.yml
composer:
image: composer:latest
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- laravel
artisan:
build:
context: .
dockerfile: Dockerfile
container_name: artisan
volumes:
- ./src:/var/www/html
depends_on:
- mysql
working_dir: /var/www/html
entrypoint: ['/var/www/html/artisan']
networks:
- laravel
Sadly I can't comment yet (< 50 reputation), but had a similar issue as you just now, an alternative to running it in different containers is to make a helper container and executing it all inside:
docker-compose.yml (note: ./code is your laravel root/folder)
version: '3'
services:
helper:
build: ./composer-artisan-helper
volumes:
- ./code:/app
Make a folder composer-artisan-helper and create a Dockerfile inside:
FROM php:7.4-fpm
# Install git
RUN apt-get update && apt-get install -y git
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Keep running
ENTRYPOINT ["tail", "-f", "/dev/null"]
# Set work-directory
WORKDIR /app
Now run it and drop into that container:
docker-compose exec helper bash
make sure it now has all your laravel folder by doing a quick ls - if everything is fine execute
php artisan jetstream:install inertia
you should now be greeted eventually with Inertia scaffolding installed successfully..
Hope that helps! even though it's not split up into multiple containers (which isn't possible afaik anyway).
I was trying to install it with command:
docker-compose run --rm artisan jetstream:install inertia
But actually it works when I try to run it in second container:
docker-compose run --rm composer php artisan jetstream:install inertia
In my configuration artisan container doesn't have a connection to the composer, but the composer container has to the artisan obviously.
there is a right answer here! thank you Jsowa
But you can install related packages separately.
You need to install inertiajs package for laravel with the following command.
docker-compose run --rm composer require inertiajs/inertia-laravel
docker-compose run --rm artisan inertia:middleware

Travis CI: Split Builds from PHPUnit and Laravel Dusk

I would like to set up a testing scenario where I can separate the test-builds for PHPUnit and Laravel Dusk. The reason why is, that this I would like to run different .env & phpunit.xml files for each test-approach.
Set the environment for PHPUnit
Test PHPUnit
Clean the Travis Build
Set the environment for Laravel Dusk
Test Laravel Dusk
I've gone through the Travis documentation about jobs and the matrix but I can't find a proper approach which I can follow.
My .travis.yml file:
sudo: true
dist: trusty
language: php
php:
- 7.3
addons:
chrome: stable
apt:
sources:
- mysql-5.7-trusty
packages:
- mysql-server
- mysql-client
services:
- mysql
install:
- composer self-update
- travis_retry composer install --no-interaction --prefer-dist --no-suggest
before_script:
- rm composer.lock
- echo -e "[server]\nmax_allowed_packet=64M" | sudo tee -a /etc/mysql/conf.d/drupal.cnf
- sudo service mysql restart
- mysql -e 'CREATE DATABASE testing;'
- mysql -e 'CREATE DATABASE business_external;'
- mysql business_external < /home/travis/build/StanBarrows/business/database/data/business_external
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
- cp .env.travis .env
- cp phpunit.travis.xml phpunit.xml
- php artisan key:generate
- php artisan storage:link
- php artisan serve &
script:
- vendor/bin/phpunit
- php artisan dusk
notifications:
email: false

Laravel 4.2 + MySQL Running phpunit on Codeship says '.. access denied for user root#localhost ..'

I have a Laravel 4.2 with MySQL web application integrated on bitbucket and decided to use Codeship for continuous integration.
When build executes on Codeship it says, '.. access denied for user root#localhost ..'
Here's my Codeship commands:
# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.4
# Install extensions through Pecl
# yes yes | pecl install memcache
# Install dependencies through Composer
composer install --prefer-source --no-interaction
Here's the Codeship test command:
phpunit
Thanks!
SOLVED:
Setup Commands
# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.4
# Install extensions through Pecl
# yes yes | pecl install memcache
# Install dependencies through Composer
composer install --prefer-source --no-interaction
php artisan migrate
php artisan db:seed
Test Command(s)
phpunit
Environment Variables
APP_ENV = codeship
APP_HOST = localhost
APP_DB = test

Resources