-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconfig.yml
More file actions
189 lines (187 loc) · 6.32 KB
/
config.yml
File metadata and controls
189 lines (187 loc) · 6.32 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# CircleCI jobs are only enabled to on Pull Requests and commits to master branch.
# "Only build pull requests" enabled in Project's Advanced Settings.
version: 2.1
orbs:
slack: circleci/slack@4.4.2
python: circleci/python@2.0.3
jobs:
build_test:
docker:
# Important: Don't change this otherwise we will stop testing the earliest
# python version we have to support.
- image: python:3.6-buster
resource_class: medium
parallelism: 6
steps:
- checkout # checkout source code to working directory
- run:
name: Install Basic Environment Dependencies
command: | # install dependencies
echo $PWD
apt-get update
apt-get -y install curl libgeos-dev
pip install --upgrade pip
pip install poetry
- python/install-packages:
include-python-in-cache-key: false
pkg-manager: poetry
- run:
name: Test Imports (extras need to be guarded!)
command: | # Make sure that importing works without extras installed
poetry run python -c 'import nucleus'
- run:
name: Install Extra Dependencies
command: | # install dependencies
poetry install -E metrics -E launch
- run:
name: Black Formatting Check # Only validation, without re-formatting
command: |
poetry run black --check -t py36 .
- run:
name: Flake8 Lint Check # Uses setup.cfg for configuration
command: |
poetry run flake8 . --count --statistics
- run:
name: Pylint Lint Check # Uses .pylintrc for configuration
command: |
poetry run pylint nucleus
- run :
name: MyPy typing check
command: |
poetry run mypy --ignore-missing-imports nucleus
- run :
name: Isort Import Formatting Check # Only validation, without re-formatting
command: |
poetry run isort --check-only .
- run:
name: Pytest Test Cases
command: | # Run test suite, uses NUCLEUS_TEST_API_KEY env variable
mkdir test_results
set -e
TEST_FILES=$(circleci tests glob "tests/**/test_*.py" | circleci tests split --split-by=timings)
poetry run coverage run --include=nucleus/* -m pytest -s -v --junitxml=test_results/junit.xml $TEST_FILES
poetry run coverage report
poetry run coverage html
- store_test_results:
path: htmlcov
- store_test_results:
path: test_results
- store_artifacts:
path: test_results
- slack/notify:
branch_pattern: master
event: fail
template: basic_fail_1
pypi_publish:
docker:
- image: cimg/python:3.6
steps:
- checkout # checkout source code to working directory
- run:
name: Validate Tag Version # Check if the tag name matches the package version
command: |
PKG_VERSION=$(sed -n 's/^version = //p' pyproject.toml | sed -e 's/^"//' -e 's/"$//')
if [[ "$CIRCLE_TAG" != "v${PKG_VERSION}" ]]; then
echo "ERROR: Tag name ($CIRCLE_TAG) must match package version (v${PKG_VERSION})."
exit 1;
fi
- run:
name: Validate SDK Version Increment # Check if the version is already on PyPI
command: |
PKG_VERSION=$(sed -n 's/^version = //p' pyproject.toml | sed -e 's/^"//' -e 's/"$//')
if pip install "scale-nucleus>=${PKG_VERSION}" > /dev/null 2>&1;
then
echo "ERROR: You need to increment to a new version before publishing!"
echo "Version (${PKG_VERSION}) already exists on PyPI."
exit 1;
fi
- run:
name: Build
command: | # install env dependencies
poetry build
- run:
name: Publish to PyPI
command: |
if test -z "${PYPI_USERNAME}" || test -z "${PYPI_PASSWORD}" ; then
echo "ERROR: Please assign PYPI_USERNAME and PYPI_PASSWORD as environment variables"
exit 1
fi
poetry publish --username=$PYPI_USERNAME --password=$PYPI_PASSWORD
test_poetry_installation:
parameters:
python_version:
type: string
docker:
- image: cimg/python:<<parameters.python_version>>
steps:
- checkout
- run:
command: |
pip install --upgrade pip
name: Upgrade pip
- python/install-packages:
pkg-manager: poetry
- run:
command: |
poetry run python -c 'import nucleus'
name: Test import nucleus
test_client_installation:
parameters:
python_version:
type: string
docker:
- image: cimg/python:<<parameters.python_version>>
steps:
- checkout
- run:
command: |
pip install --upgrade pip
name: Upgrade pip
- run:
command: |
poetry build
name: Build the package
- run:
command: |
export FOUND_PKG=$(find ./dist -name "*.tar.gz")
pip install $FOUND_PKG
name: Install with Python Version
workflows:
nightly_build_test:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- build_test:
context: Nucleus
installation_matrix:
jobs:
- test_poetry_installation:
matrix:
parameters:
python_version: ['3.6', '3.7', '3.8', '3.9'] #, '3.10'] Haven't gotten the 3.10 poetry install test to work
context: Nucleus
- test_client_installation:
matrix:
parameters:
python_version: ['3.6', '3.7', '3.8', '3.9', '3.10']
context: Nucleus
build_test_publish:
jobs:
- build_test:
context: Nucleus
filters:
tags:
only: /^v\d+\.\d+\.\d+$/ # Runs only for tags with the format [v1.2.3]
- pypi_publish:
requires:
- build_test
filters:
branches:
ignore: /.*/ # Runs for none of the branches
tags:
only: /^v\d+\.\d+\.\d+$/ # Runs only for tags with the format [v1.2.3]