.gitlab-ci.yml 3.5 KB
Newer Older
1
2
variables:
  GIT_STRATEGY: fetch
3
4
  DOCKER_FILE: ${CI_PROJECT_DIR}/gitlab-utils/Dockerfile
  DOCKER_IMAGE_DEV: pycity_scheduling_ci
5
6
7


stages:
8
  - build
9
  - test
10
  - deploy
11
  - release
12

13

14
prepare:
15
16
  variables:
    GIT_SUBMODULE_STRATEGY: none
17
  stage: build
18
  script:
Sebastian Schwarz's avatar
Sebastian Schwarz committed
19
    - mkdir -p /.docker
20
21
    - docker -build
       --file ${DOCKER_FILE}
Sebastian Schwarz's avatar
Sebastian Schwarz committed
22
       --tag ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME} /.docker
23
24
  tags:
   - docker
25
26


27
28
test-prerequisites:
  stage: test
Sebastian Schwarz's avatar
Sebastian Schwarz committed
29
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
30
31
32
  script:
    - python3.6 -m pytest -q /opt/richardsonpy/.
    - python3.6 -m pytest -q /opt/pycity_base/.
33
34
  tags:
   - docker
35
36
37
38


unittest:
  stage: test
Sebastian Schwarz's avatar
Sebastian Schwarz committed
39
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
40
41
42
43
44
  script:
    - ln -s $CI_PROJECT_DIR/LICENSE.txt $CI_PROJECT_DIR/src/LICENSE.txt
    - ln -s $CI_PROJECT_DIR/README.md $CI_PROJECT_DIR/src/README.md
    - python3.6 -m pip install --no-cache-dir $CI_PROJECT_DIR/src/.
    - python3.6 -m unittest discover -s $CI_PROJECT_DIR/src/testing/unit_tests -v
45
46
  tags:
   - docker
47
48


49
50
lint:
  stage: test
Sebastian Schwarz's avatar
Sebastian Schwarz committed
51
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
52
  script:
53
    - mkdir -p lint
54
55
    - ln -s $CI_PROJECT_DIR/LICENSE.txt $CI_PROJECT_DIR/src/LICENSE.txt
    - ln -s $CI_PROJECT_DIR/README.md $CI_PROJECT_DIR/src/README.md
56
    - python3.6 -m pip install --no-cache-dir $CI_PROJECT_DIR/src/.
57
    - pylint --rcfile=$CI_PROJECT_DIR/gitlab-utils/.pylintrc pycity_scheduling > $CI_PROJECT_DIR/gitlab-utils/pylint_report.txt || true
58
    - tail -n 2 $CI_PROJECT_DIR/gitlab-utils/pylint_report.txt
59
    - mv $CI_PROJECT_DIR/gitlab-utils/pylint_report.txt lint
60
  artifacts:
61
    name: "pylint-report"
62
    paths:
63
      - lint
64
    expire_in: 4 weeks
65
    when: always
66
67
  tags:
   - docker
68

69

70
doc:
71
72
  stage: deploy
  rules:
Sebastian Schwarz's avatar
Sebastian Schwarz committed
73
    - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG =~ /^v/'
Sebastian Schwarz's avatar
Sebastian Schwarz committed
74
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
75
  script:
76
    - mkdir -p doc
77
78
    - ln -s $CI_PROJECT_DIR/LICENSE.txt $CI_PROJECT_DIR/src/LICENSE.txt
    - ln -s $CI_PROJECT_DIR/README.md $CI_PROJECT_DIR/src/README.md
79
80
81
    - python3.6 -m pip install --no-cache-dir $CI_PROJECT_DIR/src/.
    - bash $CI_PROJECT_DIR/gitlab-utils/sphinx_doc/docu.sh
    - mv $CI_PROJECT_DIR/gitlab-utils/sphinx_doc/_build/html/* doc
82
  artifacts:
83
    name: "pycity_scheduling-documentation-sphinx"
84
    paths:
85
      - doc
86
    expire_in: 365 days
87
    when: always
88
89


90
91
pages:
  stage: deploy
92
  rules:
Sebastian Schwarz's avatar
Sebastian Schwarz committed
93
94
95
    - if: '$CI_COMMIT_TAG =~ /^v/'
      when: delayed
      start_in: '60 minutes'
Sebastian Schwarz's avatar
Sebastian Schwarz committed
96
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
97
  script:
98
    - mkdir -p public
99
    - mv $CI_PROJECT_DIR/docs/* public
100
101
102
  artifacts:
    paths:
      - public
103
104
  tags:
   - docker
105
106


107
pypi-release:
108
109
  stage: release
  rules:
Sebastian Schwarz's avatar
Sebastian Schwarz committed
110
    - if: '$CI_COMMIT_TAG =~ /^v/'
111
      when: delayed
112
      start_in: '120 minutes'
Sebastian Schwarz's avatar
Sebastian Schwarz committed
113
  image: ${DOCKER_IMAGE_DEV}:${CI_COMMIT_REF_NAME}
114
  script:
115
    - mkdir -p release
116
117
    - ln -s $CI_PROJECT_DIR/LICENSE.txt $CI_PROJECT_DIR/src/LICENSE.txt
    - ln -s $CI_PROJECT_DIR/README.md $CI_PROJECT_DIR/src/README.md
118
119
    - mkdir -p $CI_PROJECT_DIR/_release
    - cp -ar $CI_PROJECT_DIR/src/. $CI_PROJECT_DIR/_release/
120
121
    - python3.6 $CI_PROJECT_DIR/_release/setup.py sdist -d $CI_PROJECT_DIR/_release/dist
    - python3.6 $CI_PROJECT_DIR/_release/setup.py bdist_wheel -d $CI_PROJECT_DIR/_release/dist
Sebastian Schwarz's avatar
Sebastian Schwarz committed
122
    - TWINE_PASSWORD=${CI_PYPI_TOKEN} TWINE_USERNAME=__token__ python3.6 -m twine upload $CI_PROJECT_DIR/_release/dist/*
123
    - mv $CI_PROJECT_DIR/_release/dist/* release
124
125
126
  artifacts:
    name: "pycity_scheduling-release-$CI_COMMIT_TAG"
    paths:
127
      - release
128
129
130
  tags:
   - docker