Skip to content

Commit

Permalink
chore: Automate package build process (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rai200890 committed Nov 20, 2018
1 parent 44f8629 commit 230158f
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 71 deletions.
70 changes: 51 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,73 @@ version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.1
- image: circleci/python:3.7.1
environment:
CC_TEST_REPORTER_ID: 9f8a5da723397006023534dc6c5e32fc95d38bf7a92ae0e43530dba2a726722e
steps:
- checkout
- run:
command: |
sudo apt install python-pip
sudo pip install -U pip pipenv
name: Install OS dependencies
command: make setup-os
- run:
name: Install Code Climate Test Reporter Tool
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
command: |
pipenv --python python3.6
pipenv install --dev
- run:
command: |
pipenv run pytest
./cc-test-reporter format-coverage coverage/coverage.xml -t coverage.py
./cc-test-reporter upload-coverage
name: Install package dependencies
command: make setup
- run:
command: |
./cc-test-reporter before-build
- run:
command: |
pipenv run pytest
name: Run unit tests
command: make test
- run:
name: Upload test coverage to Code Climate
command: |
pipenv run flake8
./cc-test-reporter format-coverage coverage.xml -t coverage.py
./cc-test-reporter upload-coverage
- run:
command: |
pipenv run safety check
command: |
./cc-test-reporter after-build -t coverage.py
- run:
command: make check
- store_artifacts:
path: htmlcov
destination: htmlcov

path: htmlcov
deploy:
docker:
- image: circleci/python:3.7.1
steps:
- checkout
- run:
name: Install OS dependencies
command: make setup-os
- run:
name: Install package dependencies
command: make setup
- run:
name: init .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "repository = https://upload.pypi.org/legacy/"
- run:
name: Publish Package on Pypi
command: make release
workflows:
version: 2
build_and_deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- deploy:
requires:
- build
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: setup-os
setup-os:
sudo apt install python-pip
sudo pip install -U pip pipenv

.PHONY: setup
setup:
pipenv --rm || true
pipenv --python python3.7
pipenv install --dev

.PHONY: test
test:
pipenv run pytest

.PHONY: check
check:
pipenv run flake8
pipenv run safety check

.PHONY: build
build:
rm -rf dist
pipenv run python setup.py sdist bdist_wheel

.PHONY: release
release: build
pipenv run twine upload dist/* || true
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ flake8 = "~=3.6.0"
yapf = "~=0.24.0"
ipdb = "~=0.11"
safety = "~=1.8.4"
twine = "~=1.12.1"

[requires]
python_version = "3.6"
python_version = "3.7"
143 changes: 99 additions & 44 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
addopts = -v -s --cov=google_cloud_logger --cov-report html:coverage --cov-report term --cov-report=xml:coverage/coverage.xml
addopts = -v -s --cov=google_cloud_logger --cov-report html --cov-report term --cov-report=xml
Loading

0 comments on commit 230158f

Please sign in to comment.