.gitlab-ci.yml 1.76 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
  - release

.test: &test_definition
  variables:
17
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
18
19
  cache:
    paths:
20
      - .eggs/
21
22
      - "$CI_PROJECT_DIR/pip-cache"
      - .venv
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
23
    key: "$CI_PROJECT_NAME"
24
  stage: test
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
25
  script:
26
27
28
29
30
    - pip install --use-wheel -U pip setuptools virtualenv
    - virtualenv .venv/$PYTHON_VERSION
    - source .venv/$PYTHON_VERSION/bin/activate
    - pip install --use-wheel -r requirements.txt
    - pip install --use-wheel -r test-requirements.txt
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
31
    - python setup.py test
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
32
 
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
33
34
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"
49
50
  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
51
  script:
52
53
    - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION
    - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION
54
  stage: images
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
55
  only:
56
57
    - tags
    - triggers
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
58
59
60
61

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

image-2.7:
  <<: *image_definition
  variables:
67
68
69
70
    PYTHON_VERSION: "2.7"

image-latest:
  stage: release
71
72
  before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
73
74
75
  script:
    - docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE
    - docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
76
77
    - docker push $CI_REGISTRY_IMAGE
    - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
78
79
  only:
    - master
80
    - triggers