.gitlab-ci.yml 1.46 KB
Newer Older
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
1
2
3
4
5
6
7
image: docker:latest


# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
  DOCKER_DRIVER: overlay
8
  DOCKERFILE: Dockerfile
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
9
10
11

stages:
  - test
12
  - images
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
13
14
15
16
17
18
19
20
21
22
  - release

.test: &test_definition
  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
  cache:
    paths:
      - .venv/
      - pip-cache/
    key: "$CI_PROJECT_NAME"
23
  stage: test
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
24
25
26
27
28
29
30
31
  script:
    - pip install virtualenv
    - virtualenv -q .venv
    - source .venv/bin/activate
    - python setup.py test
  
test-3.5:
  <<: *test_definition
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
32
  image: "python:3.5"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
33
34
35

test-3.4:
  <<: *test_definition
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
36
  image: "python:3.4"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
37
38
39

test-2.7:
  <<: *test_definition
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
40
  image: "python:2.7"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
41

42

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
43
.image: &image_definition
44
45
  variables:
    PYTHON_VERSION: "3.5"
46
47
  before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
48
  script:
49
50
51
    - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION
    - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION
  stage: images
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
52
  only:
53
54
    - tags
    - triggers
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
55
56
57
58

image-3.5:
  <<: *image_definition
  variables:
59
    PYTHON_VERSION: "3.5"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
60
61
62
63

image-2.7:
  <<: *image_definition
  variables:
64
65
66
67
68
69
70
71
72
73
74
75
    PYTHON_VERSION: "2.7"

image-latest:
  stage: release
  script:
    - docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE
    - docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
    - docker push $IMAGE_NAME
    - docker push $IMAGE_NAME:$CI_BUILD_REF_SLUG
  only:
    - master
    - triggers