.gitlab-ci.yml 3.44 KB
Newer Older
1
2
# In CI we use the latest docker images.

3
stages:
4
  - check_and_lint
5
  - test
Florent Chehab's avatar
Florent Chehab committed
6
  - svg-gen-docu # required to be done before documentation and in separate stages
7
  - documentation
8

9
10
11
.only-default: &only-default
  only:
    - merge_requests
12
13
    - dev
    - master
Florent Chehab's avatar
Florent Chehab committed
14
15

check_back:
16
  <<: *only-default
17
  stage: check_and_lint
18
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1
Florent Chehab's avatar
Florent Chehab committed
19
  before_script:
20
    - sh ./backend/init_logs.sh
Florent Chehab's avatar
Florent Chehab committed
21
    - make setup
Florent Chehab's avatar
Florent Chehab committed
22
  script:
Florent Chehab's avatar
Florent Chehab committed
23
    - cd backend && ./manage.py check
24
    - cd ../documentation && make extract_django # Try to generate .dot files for the system architecture
Florent Chehab's avatar
Florent Chehab committed
25
26
27
28
  artifacts:
    paths:
      - documentation/generated/
    expire_in: 1 hour
29
30
31
  variables:
    FIXER_API_TOKEN: 91ed43e97a55f9ed9a501cc005c15e9c
    UTC_API_ENDPOINT: http://192.168.122.1:8083/api
Florent Chehab's avatar
Florent Chehab committed
32
33
34
35
  tags:
    - docker

check_front:
36
  <<: *only-default
37
  stage: check_and_lint
38
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0
Florent Chehab's avatar
Florent Chehab committed
39
  before_script:
40
    - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/
Florent Chehab's avatar
Florent Chehab committed
41
  script:
42
    - yarn build
43
44
45
46
  artifacts:
    paths:
      - frontend/webpack-stats.json
    expire_in: 1 hour
Florent Chehab's avatar
Florent Chehab committed
47
48
49
  tags:
    - docker

Maxime Emschwiller's avatar
Maxime Emschwiller committed
50
lint_backend:
51
52
53
54
  <<: *only-default
  stage: check_and_lint
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1
  script:
Maxime Emschwiller's avatar
Maxime Emschwiller committed
55
56
57
    - cd backend
    - black --check . 
    - flake8
58
59
60
  tags:
    - docker

61
lint_frontend_and_documentation:
62
63
64
65
66
67
68
  <<: *only-default
  stage: check_and_lint
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0
  before_script:
    - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/
  script:
    - yarn lint
69
    - yarn lint-doc
70
71
72
  tags:
    - docker

Florent Chehab's avatar
Florent Chehab committed
73
test_back:
74
  <<: *only-default
Florent Chehab's avatar
Florent Chehab committed
75
  stage: test
76
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1
Florent Chehab's avatar
Florent Chehab committed
77
78
79
80
81
  variables:
    POSTGRES_DB: postgres
    POSTGRES_USER: postgres
    POSTGRES_PASSWORD: postgres
    POSTGRES_HOST: postgres
82
    POSTGRES_PORT: 5432 # We absolutely need this one since a gitlab runner will inject a similar variable; will cause tests to fail.
83
84
    FIXER_API_TOKEN: 91ed43e97a55f9ed9a501cc005c15e9c
    UTC_API_ENDPOINT: http://192.168.122.1:8083/api
Florent Chehab's avatar
Florent Chehab committed
85
  services:
Florent Chehab's avatar
Florent Chehab committed
86
    - postgres:10.5
Florent Chehab's avatar
Florent Chehab committed
87
  before_script:
88
    - sh ./backend/init_logs.sh
Florent Chehab's avatar
Florent Chehab committed
89
    - make setup
Florent Chehab's avatar
Florent Chehab committed
90
  script:
Florent Chehab's avatar
Florent Chehab committed
91
    - cd backend
92
    - pytest base_app/ backend_app/ stats_app/ --cov --cov-config .coveragerc --cov-report term --cov-report html
Florent Chehab's avatar
Florent Chehab committed
93
94
  artifacts:
    paths:
95
      - backend/htmlcov/
Florent Chehab's avatar
Florent Chehab committed
96
    expire_in: 1 hour
Florent Chehab's avatar
Florent Chehab committed
97
98
99
  tags:
    - docker

100
test_frontend:
101
  <<: *only-default
102
  stage: test
103
  image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0
104
  before_script:
105
    - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/
106
  script:
107
    - yarn test
108
109
110
  tags:
    - docker

Florent Chehab's avatar
Florent Chehab committed
111
generate_UML_svg:
112
  <<: *only-default
Florent Chehab's avatar
Florent Chehab committed
113
114
115
116
117
118
119
120
121
122
123
124
  stage: svg-gen-docu
  image: floawfloaw/plantuml
  script: cd documentation && make convert_to_svg
  dependencies:
    - check_back
  artifacts:
    paths:
      - documentation/generated/
    expire_in: 1 hour
  tags:
    - docker

Florent Chehab's avatar
Florent Chehab committed
125
pages:
126
  stage: documentation
127
  image: floawfloaw/plantuml
Florent Chehab's avatar
Florent Chehab committed
128
  dependencies:
Florent Chehab's avatar
Florent Chehab committed
129
    - test_back
Florent Chehab's avatar
Florent Chehab committed
130
    - generate_UML_svg
Florent Chehab's avatar
Florent Chehab committed
131
  script:
132
    - mkdir .public
133
    - mv backend/htmlcov/ .public/coverage
134
    - mv documentation/ .public/documentation
135
    - mv .public public
Florent Chehab's avatar
Florent Chehab committed
136
137
138
139
  artifacts:
    paths:
      - public
    expire_in: 1 month
Florent Chehab's avatar
Florent Chehab committed
140
  only:
141
    - dev
Florent Chehab's avatar
Florent Chehab committed
142
143
  tags:
    - docker