1
1
version : 2.1
2
2
3
+ parameters :
4
+ run_integration_tests :
5
+ type : boolean
6
+ default : false
7
+
8
+ run_unit_tests :
9
+ type : boolean
10
+ default : true
11
+
12
+
3
13
executors :
4
14
app :
5
- working_directory : ~/app
15
+ working_directory : /mnt/ramdisk
6
16
docker :
7
- - image : circleci/python:3.8.1
17
+ - image : circleci/python:3.9
8
18
environment :
9
19
PIPENV_VENV_IN_PROJECT : true
10
20
DATABASE_URL : postgres://root:@localhost/alvinchow_backend_test
11
21
REDIS_URL : redis://localhost:6379
12
22
13
- - image : circleci/postgres:11 -alpine-ram
23
+ - image : circleci/postgres:12 -alpine-ram
14
24
environment :
15
25
POSTGRES_USER : root
16
26
POSTGRES_DB : alvinchow_backend_test
17
- - image : circleci/redis:5.0.3
27
+ - image : circleci/redis:6-alpine
18
28
19
29
20
30
commands :
21
- unit_tests_build :
31
+ build :
22
32
description : " Install and build the app, anything common for all unit test runs"
23
33
steps :
24
34
- checkout # checkout source code to working directory
35
+ - run :
36
+ name : Install submodules
37
+ command : git submodule update --init
25
38
- run :
26
39
name : Install dockerize
27
40
command : wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
@@ -36,17 +49,21 @@ commands:
36
49
37
50
- restore_cache :
38
51
keys :
39
- - pip-packages-v1-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
40
- - pip-packages-v1-{{ .Branch }}-
41
- - pip-packages-v1-
52
+ - pip-packages-v1-{{ checksum "Pipfile.lock" }}
42
53
- run :
43
54
name : Install dependencies
44
55
command : |
45
56
pipenv sync --dev
57
+ source /mnt/ramdisk/.venv/bin/activate
58
+ pip install -e alvin-python-lib -e alvin-grpc-py -e .
46
59
- save_cache :
47
60
paths :
48
- - ~/app/.venv
49
- key : pip-packages-v3-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
61
+ - /mnt/ramdisk/.venv
62
+ key : pip-packages-v1-{{ checksum "Pipfile.lock" }}
63
+
64
+
65
+ lint :
66
+ steps :
50
67
- run :
51
68
name : Linting
52
69
command :
@@ -57,41 +74,56 @@ jobs:
57
74
unit-tests :
58
75
executor : app
59
76
steps :
60
- - unit_tests_build
77
+ - build
78
+ - lint
61
79
- run :
62
- name : Run tests
80
+ name : Run unit tests
63
81
command : |
64
- pipenv run python runtests.py --coverage
82
+ pipenv run python runtests.py --coverage
65
83
66
- unit-tests-with-coverage -html :
84
+ unit-tests-with-cov -html :
67
85
executor : app
68
86
steps :
69
- - unit_tests_build
87
+ - build
88
+ - lint
70
89
- run :
71
- name : Run tests
90
+ name : Run unit tests with coverage html
72
91
command : |
73
92
pipenv run python runtests.py --coverage-html
74
- pipenv run coverage-badge -o coverage.svg
75
- - store_artifacts :
76
- path : ~/app/htmlcov
93
+ # pipenv run coverage-badge -o coverage.svg
77
94
- store_artifacts :
78
- path : ~/app/coverage.svg
79
-
95
+ path : /mnt/ramdisk/htmlcov
96
+ # - store_artifacts:
97
+ # path: ~/app/coverage.svg
80
98
99
+ integration-tests :
100
+ executor : app
101
+ steps :
102
+ - build
103
+ - run :
104
+ name : Run integration tests
105
+ command : |
106
+ pipenv run python runtests.py --integration-only -vs
81
107
82
108
workflows :
83
109
version : 2
84
- test :
110
+ unit-tests :
111
+ when : << pipeline.parameters.run_unit_tests >>
85
112
jobs :
86
113
# Run normal tests for normal branches
87
114
- unit-tests :
88
115
filters :
89
116
branches :
90
117
ignore : master
91
118
92
- # Also generate HTML coverage report for master commits
93
- - unit-tests-with-coverage -html :
119
+ # Also run integration tests generate HTML coverage report for master commits
120
+ - unit-tests-with-cov -html :
94
121
filters :
95
122
branches :
96
123
only :
97
124
- master
125
+
126
+ integration-tests :
127
+ when : << pipeline.parameters.run_integration_tests >>
128
+ jobs :
129
+ - integration-tests
0 commit comments