File: D:/HostingSpaces/SBogers10/base.komma.pro/.github/workflows/quality_assurance.yml
name: Quality assurance
on:
push:
branches:
- development
- master
jobs:
Tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_USER: Willie
MYSQL_PASSWORD: password12$
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: kms_base_testing
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Verify MySQL connection
run: |
printf installing mysql-client to be able to verify the connection:\n
sudo apt-get install -y mysql-client
printf \n
printf Databases in MySQL instance:\n
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uWillie -ppassword12$ -e "SHOW DATABASES"
- name: Setup PHP with some tools
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
tools: composer, phpunit
extensions: zip, dom, gd, mbstring, pdo_sqlite, pdo_mysql
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Checkout project
uses: actions/checkout@v2
- name: Create .env files
run: |
php -r "file_exists('.env') || copy('.env.ci.example', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install composer packages
run: |
composer config -g github-oauth.github.com ${{ secrets.ACCESS_TOKEN }}
composer install --no-interaction --no-suggest
- name: Show installed private packages
run: composer show | grep kms
- name: Generate key
run: php artisan key:generate
- name: Setup directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Setup testing database
env:
DB_HOST: 127.0.0.1
DB_DATABASE: kms_base_testing
DB_USERNAME: Willie
DB_PASSWORD: password12$
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
php artisan config:clear
php -r "echo 'Database user to use: '.getenv('DB_USERNAME').PHP_EOL;";
php -r "echo 'Database to use: '.getenv('DB_DATABASE').PHP_EOL;";
php -r "echo 'Host to use: '.getenv('DB_HOST').PHP_EOL;";
php -r "echo 'Port to use: '.getenv('DB_PORT').PHP_EOL;";
php artisan migrate:fresh
php artisan kms:seed
php artisan db:seed
# - name: List all registered routes
# run: |
# php artisan route:list
# env:
# DB_HOST: 127.0.0.1
# DB_DATABASE: kms_base_testing
# DB_USERNAME: Willie
# DB_PASSWORD: password12$
# DB_PORT: ${{ job.services.mysql.ports[3306] }}
- name: Get node.js cache directory
id: node-cache-dir
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.node-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node-
- name: Install node packages and transpile assets
run: |
npm install
npm run prod
- name: Publish kms assets to boilerplate
run: php artisan vendor:publish --tag=kms-core-public --force
- name: Run Laravel Server & phpunit
run: |
nohup php artisan serve >> /dev/null 2>&1 &
vendor/bin/phpunit -c ./phpunit_ci.xml
env:
DB_HOST: 127.0.0.1
DB_DATABASE: kms_base_testing
DB_USERNAME: Willie
DB_PASSWORD: password12$
DB_PORT: ${{ job.services.mysql.ports[3306] }}
- name: Upload laravel logs if testing failed
uses: actions/upload-artifact@v1
if: failure()
with:
name: Laravel logs
path: ./storage/logs