image: registry.gitlab.tugraz.at/dbp/middleware/dbp-api/api-starter-bundle:v1

before_script:
  - "sed -i 's|git@gitlab.tugraz.at:|https://gitlab.tugraz.at/|g' composer.*"

variables:
  COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/_composer_cache"

cache:
  key: ${CI_PROJECT_PATH}
  paths:
    - _composer_cache

stages:
  - test

.test_defaults: &test_defaults
  script:
    - sudo update-alternatives --set php "/usr/bin/${PHP}"
    - composer install
    - composer test

test-php7.3:
  stage: test
  variables:
    PHP: "php7.3"
  <<: *test_defaults

test-php7.4:
  stage: test
  variables:
    PHP: "php7.4"
  <<: *test_defaults

lint:
  stage: test
  allow_failure: true
  script:
    - sudo update-alternatives --set php /usr/bin/php7.3
    - composer run lint