forked from nasa/cumulus-message-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
173 lines (163 loc) · 5.51 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
references:
container_python27: &container_python27
docker:
- image: circleci/python:2.7.13
- name: localstack
image: localstack/localstack
working_directory: ~/repo
container_python36: &container_python36
docker:
- image: circleci/python:3.6.2
- name: localstack
image: localstack/localstack
working_directory: ~/repo
# Download and cache dependencies
restore_cache_python27: &restore_cache_python27
restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
restore_cache_python36: &restore_cache_python36
restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
save_cache_python27: &save_cache_python27
save_cache:
paths:
- ~/venv27
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
save_cache_python36: &save_cache_python36
save_cache:
paths:
- ~/venv36
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
jobs:
build_python27:
<<: *container_python27
steps:
- checkout
- *restore_cache_python27
- run:
name: install dependencies
command: |
pip install virtualenv
virtualenv ~/venv27
. ~/venv27/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install .
- *save_cache_python27
- run:
name: run tests
environment:
LOCALSTACK_HOST: localstack
command: |
. ~/venv27/bin/activate
pylint __main__.py -E
CUMULUS_ENV=testing nosetests -v -s
build_python36:
<<: *container_python36
steps:
- checkout
- *restore_cache_python36
- run:
name: install dependencies
command: |
pip install --user virtualenv
~/.local/bin/virtualenv ~/venv36
. ~/venv36/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install .
- *save_cache_python36
- run:
name: run tests
environment:
LOCALSTACK_HOST: localstack
command: |
. ~/venv36/bin/activate
pylint __main__.py -E
CUMULUS_ENV=testing nosetests -v -s
publish_github:
<<: *container_python27
steps:
- checkout
- add_ssh_keys
- run:
name: Tag, release, deploy release asset
environment:
GIT_PATH: nasa/cumulus-message-adapter
GIT_API_URL: https://api.github.com/repos
ZIPFILENAME: cumulus-message-adapter.zip
command: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
VERSION=`awk -F\' '{print $2,$4}' message_adapter/version.py`
# Only tag and release if the version doesn't already exist
if [ -z $(git ls-remote --tags origin | grep $VERSION) ]; then
git tag $VERSION
echo "Pushing tag ${VERSION}"
git push origin $VERSION
# strip white space from create release request body
CREATE_RELEASE_REQUEST_BODY=$(echo '{"tag_name": "'$VERSION'", "name": "'$VERSION'"}' | tr -d '[:space:]')
echo "Creating release for tag ${VERSION}"
curl -X POST -u cumulusgit:$CUMULUSGIT_GITHUB_API_ACCESS_TOKEN \
$GIT_API_URL/$GIT_PATH/releases \
--data $CREATE_RELEASE_REQUEST_BODY | jq .
echo "Building ${ZIPFILENAME}"
make clean
make $ZIPFILENAME
if [ -f $ZIPFILENAME ]; then
UPLOAD_URL_TEMPLATE=$(curl $GIT_API_URL/$GIT_PATH/releases/tags/$VERSION | jq '.upload_url' --raw-output)
UPLOAD_URL=${UPLOAD_URL_TEMPLATE//{?name,label\}/?name=$ZIPFILENAME}
echo "Uploading release to ${UPLOAD_URL}"
curl -X POST -u cumulusgit:$CUMULUSGIT_GITHUB_API_ACCESS_TOKEN \
-H "Content-Type: application/zip" \
$UPLOAD_URL \
--data-binary @./$ZIPFILENAME | jq .
else
echo "$ZIPFILENAME does not exist."
exit 1
fi
fi
publish_pypi:
<<: *container_python27
steps:
- checkout
- *restore_cache_python27
- run:
name: Deploy to PyPi
command: |
virtualenv ~/venv27
. ~/venv27/bin/activate
pip install twine
python setup.py sdist
twine upload --skip-existing --username "${PYPI_USER}" --password "${PYPI_PASS}" dist/*
workflows:
version: 2
build_test_27_publish:
jobs:
- build_python27
- publish_github:
requires:
- build_python27
filters:
branches:
only: master
- publish_pypi:
requires:
- publish_github
filters:
branches:
only: master
build_test_36:
jobs:
- build_python36