1
- version : 2
2
- jobs :
3
- test-cpython :
4
- docker :
5
- - image : chrisrink10/pyenv:3.6-3.7-3.8-0.0.1
6
- user : pyenv
1
+ version : 2.1
2
+
3
+ commands :
4
+ setup_tests :
5
+ description : " Check out code, install Tox, and prepare the test environment."
6
+ parameters :
7
+ python_version :
8
+ description : " Required. Python version as `major.minor`."
9
+ type : string
10
+ cache_key_prefix :
11
+ description : " Required. Prefix used for the CircleCI cache key."
12
+ type : string
7
13
steps :
8
14
- checkout
15
+ - run : sudo chown -R circleci:circleci /usr/local/bin
16
+ - run : sudo chown -R circleci:circleci /usr/local/lib/python<< parameters.python_version >>/site-packages
9
17
- restore_cache :
10
- key : deps-{{ .Branch }} -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
18
+ key : << parameters.cache_key_prefix >>1 -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
11
19
- run :
12
20
name : Install tox
13
21
shell : /bin/bash -leo pipefail
14
22
command : |
23
+ pip install -U pip
15
24
pip install tox
25
+
26
+ teardown_tests :
27
+ description : " Store the cache for the current run."
28
+ parameters :
29
+ python_version :
30
+ description : " Required. Python version as `major.minor`."
31
+ type : string
32
+ cache_key_prefix :
33
+ description : " Required. Prefix used for the CircleCI cache key."
34
+ type : string
35
+ steps :
36
+ - save_cache :
37
+ key : << parameters.cache_key_prefix >>1-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
38
+ paths :
39
+ - " /home/circleci/project/.tox"
40
+ - " /usr/local/bin"
41
+ - " /usr/local/lib/python<< parameters.python_version >>/site-packages"
42
+
43
+ run_cpython_tests :
44
+ description : " Install Tox and run tests."
45
+ parameters :
46
+ python_version :
47
+ description : " Required. Python version as `major.minor`."
48
+ type : string
49
+ tox_envs :
50
+ description : " Required. Set of Tox environments to run on this node."
51
+ type : string
52
+ tox_parallel :
53
+ description : " Optional. Number of parallel workers spawned by Tox."
54
+ type : integer
55
+ default : 2
56
+ steps :
57
+ - setup_tests :
58
+ python_version : << parameters.python_version >>
59
+ cache_key_prefix : py<< parameters.python_version >>-deps
16
60
- run :
17
61
name : Run Tests
18
62
shell : /bin/bash -leo pipefail
19
63
environment :
20
- TOX_NUM_CORES : 2
21
64
TOX_PARALLEL_NO_SPINNER : 1
22
65
TOX_SHOW_OUTPUT : " True"
23
- TOX_SKIP_ENV : pypy3
24
66
command : |
25
- tox -p $TOX_NUM_CORES
26
- - save_cache :
27
- key : deps9-{{ .Branch }}-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
28
- paths :
29
- - " /home/pyenv/.tox"
30
- - " /usr/local/bin"
31
- - " /usr/local/lib/python3.6/site-packages"
67
+ tox -p << parameters.tox_parallel >> -e << parameters.tox_envs >>
68
+ mkdir coverage
69
+ mv .coverage.* "coverage/.coverage.py<< parameters.python_version >>"
70
+ - teardown_tests :
71
+ python_version : << parameters.python_version >>
72
+ cache_key_prefix : py<< parameters.python_version >>-deps
73
+ - store_artifacts :
74
+ path : coverage
32
75
- store_test_results :
33
76
path : junit
34
77
78
+ jobs :
79
+ test-cpython-36 :
80
+ docker :
81
+ - image : circleci/python:3.6-buster
82
+ steps :
83
+ - run_cpython_tests :
84
+ python_version : " 3.6"
85
+ tox_envs : py36,py36-mypy,py36-lint,safety
86
+
87
+ test-cpython-37 :
88
+ docker :
89
+ - image : circleci/python:3.7-buster
90
+ steps :
91
+ - run_cpython_tests :
92
+ python_version : " 3.7"
93
+ tox_envs : py37,py37-mypy,py37-lint,safety
94
+
95
+ test-cpython-38 :
96
+ docker :
97
+ - image : circleci/python:3.8-buster
98
+ steps :
99
+ - run_cpython_tests :
100
+ python_version : " 3.8"
101
+ tox_envs : py38,py38-mypy,py38-lint,format,safety
102
+
103
+ report-coverage :
104
+ docker :
105
+ - image : circleci/python:3.8-buster
106
+ steps :
107
+ - setup_tests :
108
+ python_version : " 3.8"
109
+ cache_key_prefix : report-coverage-deps
110
+ - run :
111
+ name : Report Coverage
112
+ command : |
113
+ # Fetch the build numbers for this Workflow UUID
114
+ RECENT_BUILDS_URL="https://circleci.com/api/v1.1/project/github/basilisp-lang/basilisp/tree/$CIRCLE_BRANCH"
115
+ BUILD_NUMS=$(curl -H "Circle-Token: $CIRCLECI_API_TOKEN" "$RECENT_BUILDS_URL" | \
116
+ jq -r "map(select(.workflows.workflow_id == \"$CIRCLE_WORKFLOW_ID\")) | map(.build_num) | .[]")
117
+ echo "CircleCI build URL: $RECENT_BUILDS_URL"
118
+ echo "CircleCI build numbers: $(echo "$BUILD_NUMS" | tr '\n' ' ')"
119
+
120
+ # Fetch all of the artifacts for the build numbers
121
+ for build_num in $BUILD_NUMS
122
+ do
123
+ ARTIFACT_META_URL="https://circleci.com/api/v1.1/project/github/basilisp-lang/basilisp/$build_num/artifacts"
124
+ echo "Fetching artifacts for CircleCI build from: $ARTIFACT_META_URL"
125
+ ARTIFACT_URLS=$(curl -H "Circle-Token: $CIRCLECI_API_TOKEN" "$ARTIFACT_META_URL" | jq -r '.[].url')
126
+ if [ -n "$ARTIFACT_URLS" ]; then
127
+ echo "Found artifact URLs: $(echo "$ARTIFACT_URLS" | tr '\n' ' ')"
128
+ curl -L --remote-name-all $ARTIFACT_URLS
129
+ fi
130
+ done
131
+ tox -v -e coverage
132
+ - teardown_tests :
133
+ python_version : " 3.8"
134
+ cache_key_prefix : report-coverage-deps
135
+
35
136
test-pypy :
36
137
docker :
37
138
- image : pypy:3.6-7-slim-buster
38
139
parallelism : 3
39
140
steps :
40
141
- checkout
41
142
- restore_cache :
42
- key : deps-{{ .Branch }} -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
143
+ key : pypy-deps2 -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
43
144
- run :
44
145
name : Install tox
45
146
command : |
147
+ pip install -U pip
46
148
pip install tox
47
149
- run :
48
150
name : Run Tests
49
151
command : |
50
- # Split tests by timing and print out the test files on each node
51
152
CCI_NODE_TESTS=$(circleci tests glob "tests/**/*_test.py" "tests/**/test_*.py" | circleci tests split --split-by=timings)
52
153
printf "Test files:\n"
53
154
echo "$CCI_NODE_TESTS"
54
155
printf "\n"
55
-
56
- # Run the tests on the subset defined for this node
57
156
tox -e pypy3 -- $CCI_NODE_TESTS
58
157
- save_cache :
59
- key : deps9-{{ .Branch }} -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
158
+ key : pypy-deps2 -{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
60
159
paths :
61
- - " /home/pyenv /.tox"
160
+ - " /root/project /.tox"
62
161
- " /usr/local/bin"
63
162
- " /usr/local/lib/python3.6/site-packages"
64
163
- store_test_results :
@@ -68,5 +167,12 @@ workflows:
68
167
version : 2
69
168
test :
70
169
jobs :
71
- - test-cpython
170
+ - test-cpython-36
171
+ - test-cpython-37
172
+ - test-cpython-38
72
173
- test-pypy
174
+ - report-coverage :
175
+ requires :
176
+ - test-cpython-36
177
+ - test-cpython-37
178
+ - test-cpython-38
0 commit comments