Skip to content

Commit 230158f

Browse files
committed
chore: Automate package build process (#2)
1 parent 44f8629 commit 230158f

File tree

6 files changed

+196
-71
lines changed

6 files changed

+196
-71
lines changed

.circleci/config.yml

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +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: 9f8a5da723397006023534dc6c5e32fc95d38bf7a92ae0e43530dba2a726722e
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
22-
- run:
23-
command: |
24-
pipenv run pytest
25-
./cc-test-reporter format-coverage coverage/coverage.xml -t coverage.py
26-
./cc-test-reporter upload-coverage
19+
name: Install package dependencies
20+
command: make setup
2721
- run:
2822
command: |
2923
./cc-test-reporter before-build
3024
- run:
31-
command: |
32-
pipenv run pytest
25+
name: Run unit tests
26+
command: make test
3327
- run:
28+
name: Upload test coverage to Code Climate
3429
command: |
35-
pipenv run flake8
30+
./cc-test-reporter format-coverage coverage.xml -t coverage.py
31+
./cc-test-reporter upload-coverage
3632
- run:
37-
command: |
38-
pipenv run safety check
33+
command: |
34+
./cc-test-reporter after-build -t coverage.py
35+
- run:
36+
command: make check
3937
- store_artifacts:
40-
path: htmlcov
4138
destination: htmlcov
42-
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ flake8 = "~=3.6.0"
1414
yapf = "~=0.24.0"
1515
ipdb = "~=0.11"
1616
safety = "~=1.8.4"
17+
twine = "~=1.12.1"
18+
1719
[requires]
18-
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=google_cloud_logger --cov-report html:coverage --cov-report term --cov-report=xml:coverage/coverage.xml
2+
addopts = -v -s --cov=google_cloud_logger --cov-report html --cov-report term --cov-report=xml

0 commit comments

Comments
 (0)