.gitlab-ci-15-bluegreen.yml 1.57 KB
Newer Older
Rémi Cailletaud's avatar
Rémi Cailletaud committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.job_template: &deploy_job
  stage: deploy
  when: manual
  image: docker
  before_script:
    - cd python-dice
  script:
    - docker pull ciformation/dice-server:latest 
    - if [ "$(docker ps -q -f name=dice-$CI_JOB_NAME)" ]; then docker stop dice-$CI_JOB_NAME; fi;
    - docker run --name dice-$CI_JOB_NAME -d --rm -p $PORT:8081 ciformation/dice-server:latest 


image : python:3

stages :
  - test
  - doc
  - pypi
  - build
  - deploy

before_script:
  - cd python-dice
  - python setup.py install

job_test:
  stage : test
  script: 
    - python setup.py test
    - pip install coverage
    - coverage run -m unittest discover
    - coverage report

pages:
  stage : deploy
  only:
    variables:
      - $CI_COMMIT_MESSAGE =~ /^\[doc\].*/i
  script:
    - pip install sphinx
    - python setup.py build_sphinx
    - mv build/sphinx/html ../public
  artifacts:
    paths:
      - public

pypi:
  stage : deploy
  only:
    - /^version-.*$/
  script:
    - pip install twine
    - pip wheel . -w wheelhouse
    - twine upload --repository-url https://test.pypi.org/legacy/ wheelhouse/*
  
build:
  stage : build
  image: docker
  services:
    - docker:dind
  before_script:
    - docker info
    - cd python-dice
  script:
    - docker build -t $DOCKER_LOGIN/dice-server . 
    - echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin
    - docker push $DOCKER_LOGIN/dice-server

blue:
  <<: *deploy_job
  variables:
    DOCKER_HOST: "osug-docker-ci.u-ga.fr:2376"
    PORT: 8090

green:
  <<: *deploy_job
  variables:
    DOCKER_HOST: "osug-docker-ci.u-ga.fr:2376"
    PORT: 8091