Merge branch '2-gitlab-ci-cd-pipeline-does-not-do-any-linting-or-testing' into 'master'

Resolve "Gitlab CI/CD Pipeline does not do any linting or testing"

Closes #2

See merge request daniel/personal-website!3
This commit is contained in:
Daniel_I_Am 2021-09-04 13:05:44 +00:00
commit 99166666a3
2 changed files with 80 additions and 0 deletions

15
.env.testing Normal file
View File

@ -0,0 +1,15 @@
APP_NAME=Laravel
APP_ENV=testing
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

View File

@ -1,7 +1,70 @@
stages:
- build
- test
- docker
- deploy
variables:
MYSQL_DATABASE: portfolio
MYSQL_ROOT_PASSWORD: password
php-build-job:
stage: build
image: composer:2
script:
- composer install
- php artisan key:generate
artifacts:
paths:
- .env.testing
- vendor/
cache:
paths:
- vendor/
node-build-job:
stage: build
image: node:16
script:
- yarn
- yarn dev
artifacts:
paths:
- public/js
- public/css
- public/fonts
- public/mix-manifest.json
cache:
paths:
- node_modules/
test-job:
stage: test
image: php:8-cli
services:
- mysql:5
needs:
- php-build-job
- node-build-job
dependencies:
- php-build-job
- node-build-job
script:
- pecl install xdebug
- echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini
- echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini
- export DB_CONNECTION=mysql
- export DB_HOST=mysql
- export DB_PORT=3306
- export DB_DATABASE="$MYSQL_DATABASE"
- export DB_USERNAME=root
- export DB_PASSWORD="$MYSQL_ROOT_PASSWORD"
- ./vendor/bin/phpunit --coverage-text --coverage-cobertura php-coverage.xml
artifacts:
reports:
cobertura: php-coverage.xml
coverage: '/^\s*Lines:\s*\d+(.\d+)?\%/'
docker-auth-job:
stage: docker
image: docker:stable
@ -21,6 +84,8 @@ docker-build-job:
only:
refs:
- master
needs:
- test-job
tags:
- docker
script: