Skip to content

Commit 51d300d

Browse files
authored
Merge pull request #27 from Workable/feature/multi_py3_test_env
[circle] Add py3.5 and py3.6 test jobs and build workflow
2 parents 14bbe42 + 19bbc24 commit 51d300d

File tree

2 files changed

+83
-36
lines changed

2 files changed

+83
-36
lines changed

.circleci/config.yml

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,103 @@
1-
# Python CircleCI 2.0 configuration file
2-
#
3-
# Check https://circleci.com/docs/2.0/language-python/ for more details
4-
#
51
version: 2
2+
63
jobs:
7-
build:
4+
test-3.6: &test-template
5+
# Job to run tests test on python 3.6
86
docker:
9-
# specify the version you desire here
10-
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
117
- image: circleci/python:3.6
128

13-
# Specify service dependencies here if necessary
14-
# CircleCI maintains a library of pre-built images
15-
# documented at https://circleci.com/docs/2.0/circleci-images/
16-
# - image: circleci/postgres:9.4
17-
18-
working_directory: ~/repo
9+
environment:
10+
PYTHON_BIN: python3
11+
PYTHON_VERSION: 3.6
1912

2013
steps:
2114
- checkout
2215

2316
# Download and cache dependencies
2417
- restore_cache:
2518
keys:
26-
- v1-dependencies-{{ checksum "setup.py" }}
27-
# fallback to using the latest cache if no exact match is found
28-
- v1-dependencies-
19+
- v2-test-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}
2920

3021
- run:
31-
name: install dependencies
22+
name: Install test dependencies
3223
command: |
33-
python3 -m venv venv
24+
${PYTHON_BIN} -m venv venv
3425
. venv/bin/activate
3526
pip install -U pip
3627
pip install -U setuptools
37-
pip install .
28+
# Install package with dependencies
29+
pip install .[test]
3830
3931
- save_cache:
4032
paths:
4133
- ./venv
42-
key: v1-dependencies-{{ checksum "setup.py" }}
34+
key: v2-test-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}
35+
36+
# run Flake8!
37+
- run:
38+
name: Flake8 Compliance
39+
command: |
40+
. venv/bin/activate
41+
${PYTHON_BIN} setup.py flake8
4342
4443
# run tests!
4544
- run:
4645
name: Unit-Tests
4746
command: |
4847
. venv/bin/activate
49-
python setup.py test
48+
pip install
49+
${PYTHON_BIN} setup.py nosetests
5050
51-
# run Flake8!
51+
test-3.5:
52+
# Clone-job to run tests test on python 3.6
53+
<<: *test-template
54+
docker:
55+
- image: circleci/python:3.5
56+
57+
environment:
58+
PYTHON_BIN: python3
59+
PYTHON_VERSION: 3.5
60+
61+
build:
62+
# Build and store artifacts
63+
64+
docker:
65+
- image: circleci/python:3.6
66+
67+
68+
steps:
69+
- checkout
5270
- run:
53-
name: Flake8 Compliance
71+
name: Create environment
5472
command: |
73+
python3 -m venv venv
5574
. venv/bin/activate
56-
python setup.py flake8
75+
pip install -U pip setuptools wheel
76+
77+
- run:
78+
name: Build Source and Wheel distribution files
79+
command: |
80+
. venv/bin/activate
81+
python setup.py sdist bdist_wheel
82+
python setup.py --version > version.txt
83+
84+
- store_artifacts:
85+
path: dist
86+
destination: dist
87+
88+
- persist_to_workspace:
89+
root: .
90+
paths:
91+
- dist
92+
- version.txt
5793

58-
# # Build
59-
# - store_artifacts:
60-
# path: test-reports
61-
# destination: test-reports
94+
workflows:
95+
version: 2
96+
test_build_deploy:
97+
jobs:
98+
- test-3.6
99+
- test-3.5
100+
- build:
101+
requires:
102+
- test-3.6
103+
- test-3.5

setup.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,18 @@ def index():
8787
import ast
8888
from setuptools import setup
8989

90-
9190
_version_re = re.compile(r'__version__\s+=\s+(.*)')
9291

9392
with open('flask_log_request_id/__init__.py', 'rb') as f:
9493
version = str(ast.literal_eval(_version_re.search(
9594
f.read().decode('utf-8')).group(1)))
9695

96+
test_requirements = [
97+
'nose',
98+
'mock==2.0.0',
99+
'coverage~=4.3.4',
100+
'celery~=4.1.0'
101+
]
97102

98103
setup(
99104
name='Flask-Log-Request-ID',
@@ -117,15 +122,15 @@ def index():
117122
install_requires=[
118123
'Flask>=0.8',
119124
],
120-
tests_require=[
121-
'nose',
122-
'mock==2.0.0',
123-
'coverage~=4.3.4',
124-
'celery~=4.1.0'
125-
],
125+
tests_require=test_requirements,
126126
setup_requires=[
127-
"flake8"
127+
"flake8",
128+
"nose"
128129
],
130+
extras_require={
131+
'test': test_requirements,
132+
'celery': ["celery~=4.1.0"],
133+
},
129134
test_suite='nose.collector',
130135
classifiers=[
131136
'Environment :: Web Environment', 'Intended Audience :: Developers',

0 commit comments

Comments
 (0)