stages:
  - test
  - deploy

## Cache composer packages between all jobs and all branches
## of this project...
cache:
  key: one-key-to-rull-them-all
  paths:
    - composer-cache/


# Test with PHP7.2 
test:php72:
  stage: test
  image: cylab/php72
  services:
    - mongo
  before_script:
    # Install all project dependencies
    - COMPOSER_CACHE_DIR=./composer-cache composer install
    # setup Laravel
    - cp env.test .env
    - touch storage/app/db.sqlite
    - php artisan migrate
  script:
    - vendor/bin/phpunit --coverage-text
    - vendor/bin/phpcs

test:gitleaks:
  stage: test
  image: 
    name: "zricethezav/gitleaks"
    entrypoint: [""]
  script:
    - gitleaks -v --repo-path=./ --config=gitleaks.toml
    
# deploy only when pushed to branch master
# and tests succeeded
deploy:
  stage: deploy
  image: alpine
  only:
    - master
  script:
    - apk add wget
    - wget "http://deployer.web-d.be/projects/19/deploy/CnyUff07McfEi7hQtHND7JWALkzKCmf4b4ddREUE"
    
