Skip to content

Commit b938a13

Browse files
committed
First pass at circleci
1 parent 1b0b24f commit b938a13

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.circleci/config.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CircleCI jobs are only enabled to on Pull Requests and commits to master branch.
2+
# "Only build pull requests" enabled in Project's Advanced Settings.
3+
version: 2.1
4+
jobs:
5+
build_test:
6+
docker:
7+
- image: cimg/python:3.6
8+
resource_class: small
9+
steps:
10+
- checkout # checkout source code to working directory
11+
- run:
12+
name: Install Environment Dependencies
13+
command: | # install env dependencies
14+
pip install poetry
15+
poetry install
16+
- run:
17+
name: Black Formatting Check # Only validation, without re-formatting
18+
command: |
19+
black --check -t py36 .
20+
- run:
21+
name: Flake8 Lint Check # Uses setup.cfg for configuration
22+
command: |
23+
flake8 . --count --statistics
24+
# TODO: fix pylint. and add a mypy check.
25+
# - run:
26+
# name: Pylint Lint Check # Uses .pylintrc for configuration
27+
# command: |
28+
# pylint scaleapi
29+
- run:
30+
name: Pytest Test Cases
31+
command: | # Run test suite, uses SCALE_TEST_API_KEY env variable
32+
poetry run pytest
33+
pypi_publish:
34+
docker:
35+
- image: cimg/python:3.6
36+
steps:
37+
- checkout # checkout source code to working directory
38+
- run:
39+
name: Validate Tag Version # Check if the tag name matches the package version
40+
command: |
41+
PKG_VERSION=$(sed -n 's/^version = //p' pyproject.toml | sed -e 's/^"//' -e 's/"$//')
42+
if [[ "$CIRCLE_TAG" != "v${PKG_VERSION}" ]]; then
43+
echo "ERROR: Tag name ($CIRCLE_TAG) must match package version (v${PKG_VERSION})."
44+
exit 1;
45+
fi
46+
- run:
47+
name: Validate SDK Version Increment # Check if the version is already on PyPI
48+
command: |
49+
PKG_VERSION=$(sed -n 's/^version = //p' pyproject.toml | sed -e 's/^"//' -e 's/"$//')
50+
if pip install "scale-nucleus>=${PKG_VERSION}" > /dev/null 2>&1;
51+
then
52+
echo "ERROR: You need to increment to a new version before publishing!"
53+
echo "Version (${PKG_VERSION}) already exists on PyPI."
54+
exit 1;
55+
fi
56+
- run:
57+
name: Build
58+
command: | # install env dependencies
59+
poetry build
60+
- run:
61+
name: Publish to PyPI
62+
command: |
63+
if test -z "${PYPI_USERNAME}" || test -z "${PYPI_PASSWORD}" ; then
64+
echo "ERROR: Please assign PYPI_USERNAME and PYPI_PASSWORD as environment variables"
65+
exit 1
66+
fi
67+
poetry publish --username=$PYPI_USERNAME --password=$PYPI_PASSWORD
68+
workflows:
69+
build_test_publish:
70+
jobs:
71+
- build_test:
72+
filters:
73+
tags:
74+
only: /^v\d+\.\d+\.\d+$/ # Runs only for tags with the format [v1.2.3]
75+
- pypi_publish:
76+
requires:
77+
- build_test
78+
filters:
79+
branches:
80+
ignore: /.*/ # Runs for none of the branches
81+
tags:
82+
only: /^v\d+\.\d+\.\d+$/ # Runs only for tags with the format [v1.2.3]

0 commit comments

Comments
 (0)