-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish Python 3 compatible packages and migrate to CircleCI 2.0 #41
Changes from all commits
7e99528
9a13841
f989ab3
e1e9f3d
e1e4598
78c7ab4
006273d
5846f05
9c2153d
96d7dae
e959284
9c09dd0
266dd14
86886c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# CircleCI 2.0 configuration file. See <https://circleci.com/docs/2.0/language-python/>. | ||
version: 2 | ||
jobs: | ||
build_python2: | ||
docker: | ||
- image: python:2.7.14 | ||
|
||
steps: | ||
- checkout | ||
|
||
- restore_cache: | ||
key: v1-py2-{{ checksum "setup.py" }} | ||
|
||
- run: | ||
name: Create a virtualenv | ||
command: | | ||
mkdir -p /tmp/venv/country_template | ||
virtualenv /tmp/venv/country_template | ||
echo "source /tmp/venv/country_template/bin/activate" >> $BASH_ENV | ||
|
||
- run: | ||
name: Install dependencies | ||
command: | | ||
pip install --upgrade pip twine wheel | ||
pip install --editable .[test] --upgrade | ||
# pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH_NAME#egg=OpenFisca-Core # use a specific branch of OpenFisca-Core | ||
|
||
- save_cache: | ||
key: v1-py2-{{ checksum "setup.py" }} | ||
paths: | ||
- /tmp/venv/country_template | ||
|
||
- run: | ||
name: Run tests | ||
command: make test | ||
|
||
- run: | ||
name: Check version number has been properly updated | ||
command: | | ||
git fetch | ||
.circleci/is-version-number-acceptable.sh | ||
|
||
deploy_python2: | ||
docker: | ||
- image: python:2.7.14 | ||
environment: | ||
PYPI_USERNAME: openfisca-bot # Edit this value to replace it by your Pypi username | ||
# PYPI_PASSWORD: this value is set in CircleCI's web interface; do not set it here, it is a secret! | ||
|
||
steps: | ||
- checkout | ||
|
||
- restore_cache: | ||
key: v1-py2-{{ checksum "setup.py" }} | ||
|
||
- run: | ||
name: Check for functional changes | ||
command: if .circleci/detect-functional-changes.sh ; then circleci step halt ; fi | ||
|
||
- run: | ||
name: Upload a Python package to Pypi | ||
command: | | ||
source /tmp/venv/country_template/bin/activate | ||
.circleci/publish-python-package.sh | ||
|
||
- run: | ||
name: Publish a git tag | ||
command: .circleci/publish-git-tag.sh | ||
|
||
build_python3: | ||
docker: | ||
- image: python:3.6 | ||
|
||
steps: | ||
- checkout | ||
|
||
- restore_cache: | ||
key: v1-py3-{{ checksum "setup.py" }} | ||
|
||
- run: | ||
name: Create a virtualenv | ||
command: | | ||
mkdir -p /tmp/venv/country_template | ||
python -m venv /tmp/venv/country_template | ||
echo "source /tmp/venv/country_template/bin/activate" >> $BASH_ENV | ||
|
||
- run: | ||
name: Install dependencies | ||
command: | | ||
pip install --upgrade pip twine wheel | ||
pip install --editable .[test] --upgrade | ||
# pip install --editable git+https://github.com/openfisca/country-template.git@BRANCH_NAME#egg=OpenFisca-Country-Template # use a specific branch of OpenFisca-Country-Template | ||
|
||
- save_cache: | ||
key: v1-py3-{{ checksum "setup.py" }} | ||
paths: | ||
- /tmp/venv/country_template | ||
|
||
- run: | ||
name: Run tests | ||
command: make test | ||
|
||
- run: | ||
name: Check version number has been properly updated | ||
command: | | ||
git fetch | ||
.circleci/is-version-number-acceptable.sh | ||
|
||
deploy_python3: | ||
docker: | ||
- image: python:3.6 | ||
environment: | ||
PYPI_USERNAME: openfisca-bot # Edit this value to replace it by your Pypi username | ||
# PYPI_PASSWORD: this value is set in CircleCI's web interface; do not set it here, it is a secret! | ||
|
||
steps: | ||
- checkout | ||
|
||
- restore_cache: | ||
key: v1-py3-{{ checksum "setup.py" }} | ||
|
||
- run: | ||
name: Check for functional changes | ||
command: if .circleci/detect-functional-changes.sh ; then circleci step halt ; fi | ||
|
||
- run: | ||
name: Upload a Python package to Pypi | ||
command: | | ||
source /tmp/venv/country_template/bin/activate | ||
.circleci/publish-python-package.sh | ||
|
||
workflows: | ||
version: 2 | ||
build_and_deploy: | ||
jobs: | ||
- build_python2 | ||
- build_python3 | ||
- deploy_python2: | ||
requires: | ||
- build_python2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want to publish a Python2 package that does not pass Python3 builds. How would we manage a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I misinterpreted a previous comment. |
||
- build_python3 | ||
filters: | ||
branches: | ||
only: master | ||
- deploy_python3: | ||
requires: | ||
- build_python2 | ||
- build_python3 | ||
filters: | ||
branches: | ||
only: master |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /usr/bin/env bash | ||
|
||
VERSION_CHANGE_TRIGGERS="setup.py MANIFEST.in openfisca_country_template" | ||
|
||
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit | ||
|
||
if git diff-index --shortstat $last_tagged_commit -- $VERSION_CHANGE_TRIGGERS ":(exclude)*.md" | ||
then echo "No functional changes detected." | ||
else exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add that usually |
||
|
||
git tag `python setup.py --version` | ||
git push --tags # update the repository version |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /usr/bin/env bash | ||
|
||
python setup.py bdist_wheel # build this package in the dist directory | ||
twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD # publish |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
setup( | ||
name='OpenFisca-Country-Template', | ||
version='3.0.2', | ||
version='3.1.0', | ||
author='OpenFisca Team', | ||
author_email='contact@openfisca.fr', | ||
description=u'OpenFisca tax and benefit system for Country-Template', | ||
|
@@ -16,7 +16,7 @@ | |
url='https://github.com/openfisca/openfisca-country-template', | ||
include_package_data = True, # Will read MANIFEST.in | ||
install_requires=[ | ||
'OpenFisca-Core >= 23, < 24.0', | ||
'OpenFisca-Core >= 23.1, < 24.0', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changelog claims that we are making this package compatible with python 3. |
||
], | ||
extras_require = { | ||
'api': [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just
.circleci/detect-functional-changes.sh
? Shouldn't deployment fail?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I understood. No, it should not fail, it should be green but not do anything. Gotcha.