haase.dev/ blog

Laravel Basic Drone CI

August 8, 2020

The pipeline executes PHPUnit to run all your tests and caches composer's vendor directory to a S3 compatible storage in order to reduce build time.

---
kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
  - name: restore
    pull: if-not-exists
    image: plugins/s3-cache:1.4.0
    settings:
      endpoint: https://s3.gernox.de
      access_key:
        from_secret: s3_access_key
      secret_key:
        from_secret: s3_secret_key
      restore: true
    when:
      event:
        exclude:
          - pull_request
  - name: build
    pull: if-not-exists
    image: laradock/workspace:2.6.1-7.4
    commands:
      - php -v
      - composer -V
      - cp .env.example .env
      - composer install --prefer-dist
      - php artisan key:generate
      - php artisan app:test-database
      - ./vendor/bin/phpunit
  - name: rebuild
    pull: if-not-exists
    image: plugins/s3-cache:1.4.0
    settings:
      endpoint: https://s3.gernox.de
      access_key:
        from_secret: s3_access_key
      secret_key:
        from_secret: s3_secret_key
      rebuild: true
      mount:
        - vendor
    when:
      event: push
  - name: flush
    pull: if-not-exists
    image: plugins/s3-cache:1.4.0
    settings:
      endpoint: https://s3.gernox.de
      access_key:
        from_secret: s3_access_key
      secret_key:
        from_secret: s3_secret_key
      flush: true
      flush_age: 14
    when:
      event:
        exclude:
          - pull_request