-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconfig.yml
More file actions
127 lines (124 loc) · 4.44 KB
/
config.yml
File metadata and controls
127 lines (124 loc) · 4.44 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
# 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
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: small
parallelism: 6
steps:
- checkout # checkout source code to working directory
- run:
name: Install Environment Dependencies
command: | # install dependencies
apt-get update
apt-get -y install curl libgeos-dev
pip install --upgrade pip
pip install poetry
poetry install -E shapely
- 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
workflows:
nightly_build_test:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- build_test:
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]