diff --git a/.env.testing b/.env.testing new file mode 100644 index 0000000..b415448 --- /dev/null +++ b/.env.testing @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a965b9..e3f94a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: