# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.29
options:
  docker: true
  size: 2x

clone:
  depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
  services:
    docker:
      memory: 4096
  caches:
    sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        services:
          - docker
        size: 2x
        caches:
          #- **************************           # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
          - sonar
        script:
          #- **************************           # Build your project and run
          - pipe: sonarsource/sonarcloud-scan:2.0.0
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
  pull-requests:
    "**":
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
