Skip to content

Commit d88d1dc

Browse files
committed
chore: Automate package build on circleci (#2)
1 parent 8983e12 commit d88d1dc

File tree

6 files changed

+191
-67
lines changed

6 files changed

+191
-67
lines changed

.circleci/config.yml

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,73 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/python:3.6.1
5+
- image: circleci/python:3.7.1
66
environment:
77
CC_TEST_REPORTER_ID: 183b3f0cc4e8fcd87c0395a30578d3d4211441cbf90f7704ba2dce64fa7774be
88
steps:
99
- checkout
1010
- run:
11-
command: |
12-
sudo apt install python-pip
13-
sudo pip install -U pip pipenv
11+
name: Install OS dependencies
12+
command: make setup-os
1413
- run:
14+
name: Install Code Climate Test Reporter Tool
1515
command: |
1616
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
1717
chmod +x ./cc-test-reporter
1818
- run:
19-
command: |
20-
pipenv --python python3.6
21-
pipenv install --dev
19+
name: Install package dependencies
20+
command: make setup
2221
- run:
2322
command: |
24-
./cc-test-reporter before-build
23+
./cc-test-reporter before-build
2524
- run:
25+
name: Run unit tests
26+
command: make test
27+
- run:
28+
name: Upload test coverage to Code Climate
2629
command: |
27-
pipenv run pytest
28-
./cc-test-reporter format-coverage coverage/coverage.xml -t coverage.py
30+
./cc-test-reporter format-coverage coverage.xml -t coverage.py
2931
./cc-test-reporter upload-coverage
3032
- run:
3133
command: |
32-
pipenv run flake8
33-
- run:
34-
command: |
35-
pipenv run safety check
34+
./cc-test-reporter after-build -t coverage.py
35+
- run:
36+
command: make check
3637
- store_artifacts:
37-
path: coverage
38-
destination: coverage
39-
38+
destination: htmlcov
39+
path: htmlcov
40+
deploy:
41+
docker:
42+
- image: circleci/python:3.7.1
43+
steps:
44+
- checkout
45+
- run:
46+
name: Install OS dependencies
47+
command: make setup-os
48+
- run:
49+
name: Install package dependencies
50+
command: make setup
51+
- run:
52+
name: init .pypirc
53+
command: |
54+
echo -e "[pypi]" >> ~/.pypirc
55+
echo -e "repository = https://upload.pypi.org/legacy/"
56+
- run:
57+
name: Publish Package on Pypi
58+
command: make release
59+
workflows:
60+
version: 2
61+
build_and_deploy:
62+
jobs:
63+
- build:
64+
filters:
65+
tags:
66+
only: /.*/
67+
- deploy:
68+
requires:
69+
- build
70+
filters:
71+
tags:
72+
only: /[0-9]+(\.[0-9]+)*/
73+
branches:
74+
ignore: /.*/

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: setup-os
2+
setup-os:
3+
sudo apt install python-pip
4+
sudo pip install -U pip pipenv
5+
6+
.PHONY: setup
7+
setup:
8+
pipenv --rm || true
9+
pipenv --python python3.7
10+
pipenv install --dev
11+
12+
.PHONY: test
13+
test:
14+
pipenv run pytest
15+
16+
.PHONY: check
17+
check:
18+
pipenv run flake8
19+
pipenv run safety check
20+
21+
.PHONY: build
22+
build:
23+
rm -rf dist
24+
pipenv run python setup.py sdist bdist_wheel
25+
26+
.PHONY: release
27+
release: build
28+
pipenv run twine upload dist/* || true

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ yapf = "~=0.24.0"
1515
ipdb = "~=0.11"
1616
safety = "~=1.8.4"
1717
python-json-logger = "~= 0.1.9"
18-
18+
twine = "~=1.12.1"
1919
[requires]
20-
python_version = "3.6"
20+
python_version = "3.7"

Pipfile.lock

Lines changed: 99 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts = -v -s --cov=python_log_sanitizer --cov-report html:coverage --cov-report term --cov-report xml:coverage/coverage.xml
2+
addopts = -v -s --cov=python_log_sanitizer --cov-report html --cov-report term --cov-report xml

setup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
from setuptools import setup
1+
from setuptools import setup, find_packages
22

3-
__VERSION__ = "0.0.1"
3+
with open("README.md", "r") as output:
4+
long_description = output.read()
5+
6+
7+
__VERSION__ = "0.0.2"
48

59
setup(
610
name="python_log_sanitizer",
711
version=__VERSION__,
812
description="Log Sanitizer",
13+
long_description=long_description,
14+
long_description_content_type="text/markdown",
915
url="http://github.com/rai200890/python_log_sanitizer",
1016
author="Raissa Ferreira",
1117
author_email="[email protected]",
1218
license="MIT",
13-
packages=["python_log_sanitizer"],
19+
packages=find_packages(),
1420
python_requires=">=3.4.*",
1521
install_requires=[],
1622
classifiers=[

0 commit comments

Comments
 (0)