stages:
  - test

image: docker:23.0.3

variables:
  # When using dind service, you must instruct docker to talk with the
  # daemon started inside of the service. The daemon is available with
  # a network connection instead of the default /var/run/docker.sock socket.
  #
  # The 'docker' hostname is the alias of the service container as described at
  # https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services
  #
  # If you're using GitLab Runner 12.7 or earlier with the Kubernetes executor and Kubernetes 1.6 or earlier,
  # the variable must be set to tcp://localhost:2375 because of how the
  # Kubernetes executor connects services to the job container
  # DOCKER_HOST: tcp://localhost:2375
  #
  DOCKER_HOST: tcp://docker:2375
  #
  # This instructs Docker not to start over TLS.
  DOCKER_TLS_CERTDIR: ""

services:
  - docker:23.0.3-dind

before_script:
  - docker info

test:
  stage: test
  script:
    - docker build --target test --build-arg QGIS_VERSION=$QGIS_VERSION --tag camptocamp/edf-precourlis-builder ./docker
    - docker-compose run --rm --user `id -u` builder make -f docker.mk build
    - docker-compose run --rm --user `id -u` builder make -f docker.mk check
    - docker-compose run --rm --user `id -u` builder make -f docker.mk pytest
  parallel:
    matrix:
      - QGIS_VERSION:
        - release-3_22
        - release-3_28
        - release-3_34