lorisleiva / laravel-docker

🐳 Generic docker image for Laravel Applications
MIT License
934 stars 314 forks source link

PHPUNIT #24

Closed tiagoadp closed 5 years ago

tiagoadp commented 5 years ago

Hello i am setting up a new project for build:test:deploy using your deployer and docker image, but i fount a problem and i am struggling with it ,the problem is with phpunit, my CI on gitlab is running until this ste p.

chrome_qo0tjgqgmp

And i really wanna setup the unit tests... its a must have for me... any help will be most wellcome.

My CI Pipeline file is:

image: lorisleiva/laravel-docker:latest

.init_ssh: &init_ssh | eval $(ssh-agent -s) echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null mkdir -p ~/.ssh chmod 700 ~/.ssh [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config

.change_file_permissions: &change_file_permissions | find . -type f -not -path "./vendor/" -exec chmod 664 {} \;
find . -type d -not -path "./vendor/
" -exec chmod 775 {} \;

cache: key: ${CI_COMMIT_REF_SLUG} paths:

  • vendor/

composer: stage: build cache: key: ${CI_COMMIT_REF_SLUG}-composer paths:

  • vendor/ script:
  • composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
  • cp .env.example .env
  • php artisan key:generate artifacts: expire_in: 1 month paths:
  • vendor/
  • .env

npm: stage: build cache: key: ${CI_COMMIT_REF_SLUG}-npm paths:

  • node_modules/ script:
  • npm install
  • npm run production artifacts: expire_in: 1 month paths:
  • node_modules/
  • public_html/css/
  • public_html/js/

codestyle: stage: test cache: {} dependencies: [] script:

  • phpcs --standard=PSR2 --extensions=php --ignore=app/Support/helpers.php app

phpunit: stage: test dependencies:

  • composer script:
  • composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
  • cp .env.example .env
  • php artisan key:generate
  • phpunit --coverage-text --colors=never

production: stage: deploy script:

  • *init_ssh
  • *change_file_permissions
  • cp .env.production .env
  • php artisan deploy .com.br -s upload environment: name: production url: http://.com.br when: manual only:
    • master
lorisleiva commented 5 years ago

Hi there 👋

I never came across this issue before. However, having a quick look at your gitlab-ci file I can see that you're using a cache for building composer dependencies but then run composer install again on the phpunit job.

I suggest you take a look at the final code from the article to make sure you're using the caching system properly.

I hope this helps. Good luck. 🍀

tiagoadp commented 5 years ago

I got it, it was an error with my gitignore, i uploaded the vendor on one of the firsts commits, and so the composer was not being correctly installed... :(