-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.yml
150 lines (147 loc) · 5.58 KB
/
config.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Python CircleCI 2.1 configuration file for coverlovin2
#
# environment variable CACHE_VERSION value is set at
# https://circleci.com/gh/jtmoon79/coverlovin2/edit#env-vars
#
---
version: 2.1
jobs:
prep_workspace_cache:
docker:
# see https://circleci.com/docs/2.0/circleci-images/
- image: circleci/python:3.7
steps:
- checkout
- run:
name: prepare a Circle CI workspace, prepare a Circle CI cache, save environment variables for pipenv in the workspace
command: |
set -x
echo -e "\n\n### record information about the shell context\n\n"
pwd
shopt
env | sort
uname -a
ls -la
which python
python --version
if which pipenv 2>/dev/null; then pipenv --version; fi
echo -e "\n\n### prepare the jobs workspace\n\n"
chmod -vR +x,-w -- ./tools/
echo -e "\n\n### prepare the cache\n\n"
python -m pip install --user --upgrade pip
# pipenv is not available by default. Some amount of work has to be
# done to install it into the Circle CI cache and then re-use it in later jobs
# 1. install pipenv on the system
# 2. create pipenv envionment vars including WORKON_HOME=~/.pipenv-venv
# 3. use pipenv to install pipenv into the pipenv $WORKON_HOME location (also to be cached by Circle CI)
# 4. save $WORKON_HOME to a file
# 5. save path of pipenv within pipenv virtual environment via shell environment variable $PIPENV
# 6. save $PIPENV to a file
# 7. save that file within the workspace
# 8. during later jobs,
# a. source the file within the reloaded workspace
# b. call the pipenv at $PIPENV which resides in the reloaded Circle CI cache
python -m pip install --user pipenv
pipenv --version
export PIPENV_CACHE_DIR=~/.pipenv-cache
export PIPENV_VIRTUALENV=~/.pipenv-venv
export WORKON_HOME=~/.pipenv-venv
mkdir -vp -- "${PIPENV_CACHE_DIR}" "${PIPENV_VIRTUALENV}" "${WORKON_HOME}"
SHELL_ENV=.shell-env
echo -e 'export PIPENV_CACHE_DIR="'"${PIPENV_CACHE_DIR}"'"' >> "${SHELL_ENV}"
echo -e 'export PIPENV_VIRTUALENV="'"${PIPENV_VIRTUALENV}"'"' >> "${SHELL_ENV}"
echo -e 'export WORKON_HOME="'"${WORKON_HOME}"'"' >> "${SHELL_ENV}"
# install all dependencies (which should include pipenv)
pipenv install --dev
# upgrade pipenv to latest within the virtualenv
pipenv run pip install --upgrade pipenv
export PIPENV=$(pipenv run which pipenv)
echo -e 'export PIPENV="'"${PIPENV}"'"' >> "${SHELL_ENV}"
# make really sure setuptools and wheel is the latest
pipenv run pip install --upgrade setuptools wheel
# log contents of shell environment file
cat -- "${SHELL_ENV}"
- save_cache:
name: cache of pipenv installs
key: cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}-{{ checksum "Pipfile.lock" }}
paths:
- ~/.pipenv
- ~/.pipenv-venv
- persist_to_workspace:
root: ~/
paths:
- project
test_python36:
docker:
- image: circleci/python:3.6
steps:
- attach_workspace:
at: ~/
- restore_cache:
key: cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}-{{ checksum "Pipfile.lock" }}
- run:
name: test coverlovin2 refuses to run under python 3.6
command: |
set -e
set -u
set -o pipefail
set -x
if ! python --version | grep -qFe ' 3.6'; then
echo 'ERROR: wrong python version' "$(python --version)" >&2
exit 1
fi
[ -f coverlovin2/app.py ]
# this should fail to run
if ! python coverlovin2/app.py --version &>/dev/null; then
exit 0
fi
echo 'ERROR: python version' "$(python --version)" 'should not have run successfully' >&2
exit 1
test_pytest:
docker:
- image: circleci/python:3.7
steps:
- attach_workspace:
at: ~/
- restore_cache:
key: cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}-{{ checksum "Pipfile.lock" }}
- run:
name: test coverlovin2 pytests
command: |
set -x
pwd
SHELL_ENV=.shell-env
source "${SHELL_ENV}"
"${PIPENV}" run pytest -vv coverlovin2/test
build_pypi:
docker:
- image: circleci/python:3.7
steps:
- attach_workspace:
at: ~/
- restore_cache:
key: cache-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}-{{ checksum "Pipfile.lock" }}
- run:
name: create a wheels build that is suitable for pypi, test it can install and run
command: |
set -x
pwd
SHELL_ENV=.shell-env
source "${SHELL_ENV}"
"${PIPENV}" run bash -- tools/build-install-test.sh --uninstall
workflows:
version: 2
workflow_prep_test_build:
jobs:
- prep_workspace_cache
- test_python36:
requires:
- prep_workspace_cache
- test_pytest:
requires:
- prep_workspace_cache
- build_pypi:
requires:
- prep_workspace_cache
- test_python36
- test_pytest