forked from nasa/cumulus-message-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
135 lines (128 loc) · 4.61 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
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
references:
container_python310: &container_python310
docker:
- image: cimg/python:3.10.11
- name: localstack
image: localstack/localstack:2.0.2
working_directory: ~/repo
container_lambda_python310: &container_lambda_python310
docker:
- image: amazon/aws-lambda-python:3.10
working_directory: ~/repo
restore_cache_python310: &restore_cache_python310
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_python310: &save_cache_python310
save_cache:
paths:
- ~/venv310
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
jobs:
build_python310:
<<: *container_python310
steps:
- checkout
- *restore_cache_python310
- run:
name: install dependencies
command: |
virtualenv ~/venv310
. ~/venv310/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install .
- *save_cache_python310
- run:
name: run tests
environment:
LOCALSTACK_HOST: localstack
command: |
. ~/venv310/bin/activate
pylint_runner
CUMULUS_ENV=testing nose2 -v
publish_github:
<<: *container_lambda_python310
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: |
yum update && yum install -y zip openssh-clients git curl make jq binutils
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 https://${CUMULUSGIT_GITHUB_API_ACCESS_TOKEN}@github.com/nasa/cumulus-message-adapter.git --tags
# 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 etcart:$CUMULUSGIT_GITHUB_API_ACCESS_TOKEN \
$GIT_API_URL/$GIT_PATH/releases \
--data $CREATE_RELEASE_REQUEST_BODY | jq .
echo "Building ${ZIPFILENAME}"
pip install --user virtualenv
~/.local/bin/virtualenv ~/venv310
. ~/venv310/bin/activate
pip install .
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 etcart:$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_lambda_python310
steps:
- checkout
- *restore_cache_python310
- run:
name: Deploy to PyPi
command: |
pip install --user virtualenv
~/.local/bin/virtualenv ~/venv310
. ~/venv310/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_publish:
jobs:
- build_python310
- publish_github:
requires:
- build_python310
filters:
branches:
only: master
- publish_pypi:
requires:
- publish_github
filters:
branches:
only: master