Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Forked from zanechua/azure-pipelines.yml
Last active October 9, 2023 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nasrulhazim/7106de99d3365f717eff23a106a986d2 to your computer and use it in GitHub Desktop.
Save nasrulhazim/7106de99d3365f717eff23a106a986d2 to your computer and use it in GitHub Desktop.
Azure Pipeline + Laravel + PHPUnit + Laravel Dusk

Azure Pipeline Sample YML File

What the script does

  • Install NodeJS v11.x
  • Install necessary packages, screen;nodejs;google-chrome-stable
  • Setting up PHP
  • Installing System Dependencies
  • Installing Package Dependencies
  • Setting Up Application Environment
  • Starting Chrome and the Web Server
  • Running Unit Test
  • Running Browser Tests

For database, I'm using SQLite instead of MySQL.

# PHP
# Test and package your PHP project.
# Add steps that run tests, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/php
trigger:
- develop
pool:
vmImage: 'Ubuntu-16.04'
variables:
phpVersion: 7.2
steps:
- script: |
sudo update-alternatives --set php /usr/bin/php$(phpVersion)
sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
sudo apt-get install php$(phpVersion)-imagick php$(phpVersion)-bcmath php$(phpVersion)-mbstring php$(phpVersion)-curl php$(phpVersion)-gd php$(phpVersion)-zip php$(phpVersion)-dom
php -version
displayName: 'Setting up PHP, version $(phpVersion)'
- script: |
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y build-essential debconf-utils screen nodejs google-chrome-stable
displayName: 'Installing System Dependencies'
- script: |
sudo apt-get -y remove composer
sudo wget https://getcomposer.org/composer.phar -O /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
export PATH=$PATH:~/usr/local/bin/
sudo composer self-update
composer --version
composer install --no-interaction --prefer-dist --no-suggest
displayName: 'Installing Package Dependencies'
- script: |
touch database/database.sqlite
cp .env.example .env && php artisan key:generate
displayName: 'Setting Up Application Environment'
- script: |
screen -d -m google-chrome-stable --headless --disable-gpu --disable-dev-shm-usage --disable-software-rasterizer --remote-debugging-port=9222 http://localhost &
screen -d -m php artisan serve &
displayName: 'Starting Chrome and the Web Server'
- script: vendor/bin/phpunit --testdox --verbose
displayName: 'Running Unit Test'
- script: |
php artisan dusk:update 74
php artisan dusk
displayName: 'Running Browser Tests'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment