Last active
July 23, 2024 07:47
-
-
Save iWader/6e2f81e6147676c3a7fd36a1c1e7ea3e to your computer and use it in GitHub Desktop.
Laravel Unit and Dusk tests on CircleCI 2.0 https://iwader.co.uk/post/laravel-unit-dusk-tests-circleci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
mv composer.phar /usr/bin/composer | |
chmod +x /usr/bin/composer | |
exit $RESULT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
build: | |
working_directory: /var/www | |
environment: | |
BASH_ENV: ~/.bashrc | |
docker: | |
- image: php:7.1-cli | |
environment: | |
APP_ENV=testing | |
- image: circleci/mysql:5.7 | |
environment: | |
MYSQL_ALLOW_EMPTY_PASSWORD=true | |
MYSQL_ROOT_HOST="%" | |
MYSQL_USER=root | |
steps: | |
- run: | |
name: Install System Dependencies | |
command: | | |
apt-get update | |
apt-get install -y libmcrypt-dev git unzip wget libpng-dev | |
# These are required for e2e tests | |
apt-get install -y libsqlite3-dev libnss3 libgconf-2-4 libfontconfig1 chromium xvfb | |
- run: | |
name: Install PHP Extensions | |
command: docker-php-ext-install -j$(nproc) mcrypt pdo_mysql pdo_sqlite gd zip | |
- checkout | |
- run: | |
name: Install NVM | |
command: bash .circleci/nvm.sh | |
- run: | |
name: Install Composer | |
command: bash .circleci/composer.sh | |
- run: | |
name: Install Composer Dependencies | |
command: composer install --no-progress --no-suggest | |
- run: | |
name: PHPCS | |
command: ./vendor/bin/phpcs --standard=PSR2 -p app config | |
- run: | |
name: Setup Environment | |
command: | | |
cp .env.dusk.testing .env | |
php artisan key:generate | |
php artisan passport:keys | |
- run: | |
name: Unit Tests | |
command: APP_ENV=testing DB_DATABASE=circle_test ./vendor/bin/phpunit | |
- run: | |
name: Install Node Dependencies | |
command: | | |
node --version | |
npm --version | |
npm install | |
- run: | |
name: Webpack | |
command: npm run prod | |
- run: | |
name: Start xvfb | |
background: true | |
command: /usr/bin/Xvfb :0 -screen 0 1280x720x24 | |
- run: | |
name: Open Browsers | |
background: true | |
command: DISPLAY=:0 ./vendor/laravel/dusk/bin/chromedriver-linux | |
- run: | |
name: Serve Application | |
background: true | |
command: APP_ENV=testing DB_DATABASE=circle_test php artisan serve | |
- run: | |
name: e2e Tests | |
command: php artisan dusk | |
- store_artifacts: | |
path: ./tests/Browser/console | |
destination: console | |
- store_artifacts: | |
path: ./tests/Browser/screenshots | |
destination: screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export NVM_DIR="$HOME/.nvm" | |
mv .nvmrc .nvmrc.bak \ | |
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash \ | |
&& source $NVM_DIR/nvm.sh \ | |
&& mv .nvmrc.bak .nvmrc \ | |
&& nvm install \ | |
&& npm install -g npm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment