.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
12
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
13
14
stages:
  - test
15
  - images
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
16
17
18
19
20
21
22
23
24
25
  - release

.test: &test_definition
  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
  cache:
    paths:
      - .venv/
      - pip-cache/
    key: "$CI_PROJECT_NAME"
26
  stage: test
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
27
28
29
30
31
32
33
34
  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
35
  image: "python:3.5"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
36
37
38

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

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

45

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
46
.image: &image_definition
47
48
  variables:
    PYTHON_VERSION: "3.5"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
49
  script:
50
51
52
    - 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
53
  only:
54
55
    - tags
    - triggers
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
56
57
58
59

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

image-2.7:
  <<: *image_definition
  variables:
65
66
67
68
69
70
71
72
73
74
75
76
    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