image: gsiupm/dockermake:latest


# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
  DOCKER_DRIVER: overlay
  DOCKERFILE: Dockerfile
  VERSION: $CI_BUILD_REF

stages:
  - test
  - images
  - release
  - clean

.test: &test_definition
  stage: test
  script:
    - make -e test-$PYTHON_VERSION
    
test-3.5:
  <<: *test_definition
  variables:
    PYTHON_VERSION: "3.5"

test-2.7:
  <<: *test_definition
  variables:
    PYTHON_VERSION: "2.7"


.image: &image_definition
  stage: images
  before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
  script:
    - make -e push-$PYTHON_VERSION
  only:
    - tags
    - master
    - triggers

image-3.5:
  <<: *image_definition
  variables:
    PYTHON_VERSION: "3.5"
    VERSION: $CI_BUILD_TAG
    IMAGENAME: $CI_REGISTRY_IMAGE

image-2.7:
  <<: *image_definition
  variables:
    PYTHON_VERSION: "2.7"
    VERSION: $CI_BUILD_TAG
    IMAGENAME: $CI_REGISTRY_IMAGE

image-latest:
  stage: release
  variables:
    IMAGENAME: $CI_REGISTRY_IMAGE
  before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
  script:
    - make -e push-latest
  only:
    - master
    - triggers

clean :
  stage: clean
  script:
    - make -e clean