Skip to content

Commit

Permalink
Fix bumpversion, updates CI/CD (#3)
Browse files Browse the repository at this point in the history
* Updates CircleCI config
* Updates setup.* with refactored config and bumpversion fixes
* Adds missing version file, updates docs config
  • Loading branch information
ravenoak committed Aug 28, 2019
1 parent 0885f05 commit 1ed7616
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 111 deletions.
210 changes: 150 additions & 60 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,118 @@
version: 2.1

workflows:
version: 2
commands:

bumpversion:
description: "Uses bump2version to increase version number"
parameters:
version_part:
type: enum
enum: ['major', 'minor', 'patch', 'pre_release', 'pre_release_num']
bump_options:
type: string
default: '--no-tag --commit -m "Bump version: {current_version} → {new_version} [ci skip]"'
steps:
- restore_cache:
key: v1-bumpversion
- run:
name: Install/Upgrade bumpversion
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -U bump2version
- save_cache:
key: v1-bumpversion
paths:
- "venv"
- run:
name: Bumpversion
command: |
git config --global user.email "git-robot@virtualxistenz.com"
git config --global user.name "Git Robot"
. venv/bin/activate
python3 setup.py --version
bumpversion << parameters.bump_options >> << parameters.version_part >>
python3 setup.py --version
git log -n 1
- run:
name: Push version bump
command: |
git push -u origin $CIRCLE_BRANCH
build_and_deploy:
jobs:
- deps-py37:
filters:
tags:
only: /.*/
- test-py37:
requires:
- deps-py37
- pypi:
requires:
- deps-py37
- test-py37
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
publish:
description: "Uses twine to publish packages to PyPI"
parameters:
verify_tag:
type: boolean
default: false
steps:
- restore_cache:
keys:
- v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
- v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
- run:
name: Install/Upgrade release requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -U -r requirements.txt
pip3 install -U wheel
pip3 install -U twine
- save_cache:
key: v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- when:
condition: << parameters.verify_tag >>
steps:
- run:
name: Verify git tag vs. package version
command: |
. venv/bin/activate
python setup.py verify
- run:
name: Publish to PyPI
command: |
. venv/bin/activate
python3 setup.py sdist
python3 setup.py bdist_wheel
twine upload dist/*
jobs:

deps-py37:
install_deps_py37:
docker:
- image: circleci/python:3.7
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: install python dependencies
name: Install package dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -r requirements.txt
pip3 install -U -r requirements.txt
- save_cache:
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
paths:
- "venv"

test-py37:
unittest_py37:
docker:
- image: circleci/python:3.7
environment:
PYTEST_ADDOPTS: --cov-report=xml:test-reports/coverage.xml --junitxml=test-reports/junit.xml
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
- run:
name: run tests
name: Run tests
command: |
. venv/bin/activate
python setup.py test
python3 setup.py test
- store_test_results:
path: test-reports
- store_artifacts:
Expand All @@ -62,41 +121,72 @@ jobs:
name: Smoke Test Install
command: |
. venv/bin/activate
python --version
python setup.py install
python3 --version
python3 setup.py install
pypi:
bump_publish_dev:
docker:
- image: circleci/python:3.7
environment:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
- run:
name: install python dependencies
command: |
python3 -m venv venv
. venv/bin/activate
python setup.py build
- run:
name: verify git tag vs. version
command: |
python3 -m venv venv
. venv/bin/activate
python setup.py verify
- run:
name: init .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = ravenoak" >> ~/.pypirc
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- run:
name: create packages
command: |
python setup.py sdist
python setup.py bdist_wheel
- run:
name: upload to pypi
command: |
. venv/bin/activate
twine upload dist/*
- publish
- bumpversion:
version_part: pre_release_num

bump_publish_release:
docker:
- image: circleci/python:3.7
steps:
- checkout
- publish
- bumpversion:
version_part: pre_release_num

publish_prod_tag:
docker:
- image: circleci/python:3.7
steps:
- checkout
- publish:
verify_tag: true

workflows:
version: 2

build_test_publish_py37:
jobs:
- install_deps_py37:
filters:
tags:
only: /.*/
- unittest_py37:
requires:
- install_deps_py37
filters:
tags:
only: /.*/
- bump_publish_dev:
context: Test PyPI
requires:
- unittest_py37
filters:
branches:
only: develop
- bump_publish_release:
context: Prod PyPI
requires:
- unittest_py37
filters:
branches:
only: /^release\/.*/
- publish_prod_tag:
context: Prod PyPI
requires:
- unittest_py37
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)+$/
branches:
ignore: /.*/
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1.dev0
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
#
import os
import sys

sys.path.insert(0, os.path.abspath('..'))

def get_version():
with open('../VERSION') as f:
return f.readline().strip()

# -- Project information -----------------------------------------------------

project = 'Flask-arango-orm'
copyright = '2019, Caitlyn O\'Hanna'
author = 'Caitlyn O\'Hanna'
copyright = "2019, Caitlyn O'Hanna"
author = "Caitlyn O'Hanna"

# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = get_version()
# The short X.Y version
version = '.'.join(release.split('.')[:2])

Expand Down
59 changes: 24 additions & 35 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,64 +1,57 @@
[metadata]
author = Caitlyn O'Hanna
author_email = ravenoak@virtualxistenz.com
description = Flask connector for ArangoDB using arango-orm
long_description = file: README.rst
classifiers =
Development Status :: 2 - Pre-Alpha
Environment :: Plugins
Environment :: Web Environment
Framework :: Flask
Intended Audience :: Developers
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Development Status :: 2 - Pre-Alpha
Environment :: Plugins
Environment :: Web Environment
Framework :: Flask
Intended Audience :: Developers
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Operating System :: OS Independent
Programming Language :: Python :: 3 :: Only
Topic :: Database
Topic :: Internet :: WWW/HTTP :: WSGI
Topic :: Software Development :: Libraries :: Python Modules
license = LGPLv3+
license_file = LICENSE.txt
project_urls =
Documentation = http://flask-arango-orm.readthedocs.io/
Source Code = https://github.com/QuaererePlatform/Flask-arango-orm
url = https://github.com/QuaererePlatform/Flask-arango-orm
[bumpversion]
commit = True
tag = True
current_version = 0.1.1.dev0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)((?P<pre_release>a|b|rc)(?P<pre_release_num>\d+))?(\.dev(?P<dev_num>\d+))?
serialize =
{major}.{minor}.{micro}{pre_release}{pre_release_num}.dev{dev_num}
{major}.{minor}.{micro}{pre_release}{pre_release_num}
{major}.{minor}.{micro}.dev{dev_num}
{major}.{minor}.{micro}
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<pre_release>\.dev|a|b|rc)(?P<pre_release_num>\d+))?
serialize =
{major}.{minor}.{patch}{pre_release}{pre_release_num}
{major}.{minor}.{patch}
[aliases]
test = pytest
[bdist_wheel]
universal = True
[options]
python_requires = ~= 3.6
[bumpversion:file:setup.py]
search = {current_version}
replace = {new_version}
python_requires = >= 3.6
packages = find:
[bumpversion:file:docs/conf.py]
search = {current_version}
[bumpversion:file:VERSION]
search = ^{current_version}$
replace = {new_version}
[bumpversion:part:pre_release]
first_value = .dev
optional_value = b
values =
a
b
rc
[build_sphinx]
values =
.dev
a
b
rc
[tool:pytest]
testpaths = tests
addopts = --cov=flask_arango_orm --flake8 --junitxml=test-reports/junit.xml
addopts = --cov=flask_arango_orm --flake8
[coverage:run]
branch = True
Expand All @@ -67,7 +60,3 @@ branch = True
show_missing = True
skip_covered = True
[coverage:html]
[coverage:xml]

0 comments on commit 1ed7616

Please sign in to comment.