Skip to content

Commit fb1753d

Browse files
authored
Update docs and tests to indicate Python3.5 support. (#106)
* Update docs and tests to indicate Python3.5 support. * Disable Lint tests for Python3.5 since black doesn't support it. * Syntax in YAML. * Comprimise test requirements for Py3.5 * json.loads does NOT support bytes in Python3.5. * Explicitly define the codecov tagets.
1 parent b88255b commit fb1753d

File tree

7 files changed

+81
-39
lines changed

7 files changed

+81
-39
lines changed

.github/workflows/pr-tests.yml

+37-31
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,46 @@ jobs:
1313
strategy:
1414
max-parallel: 16
1515
matrix:
16-
python-version: [ '3.6', '3.7' ]
17-
os: [ ubuntu-latest, macos-latest ]
16+
python-version: ["3.6", "3.7", "3.5"]
17+
os: [ubuntu-latest, macos-latest]
1818
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v2
21-
with:
22-
ref: ${{ github.event.pull_request.head.sha }}
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
ref: ${{ github.event.pull_request.head.sha }}
2323

24-
- name: Setup Python env
25-
uses: actions/setup-python@v1
26-
with:
27-
python-version: ${{ matrix.python-version }}
28-
architecture: x64
24+
- name: Setup Python env
25+
uses: actions/setup-python@v1
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
architecture: x64
2929

30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install -r requirements-test.txt -r requirements.txt
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -r requirements-test.txt -r requirements.txt
3434
35-
- name: Lint Tests
36-
run: |
37-
# Check Black code style compliance
38-
black ./ --skip-string-normalization --check
39-
# Check PEP-8 compliance
40-
flake8
35+
- name: Lint Tests
36+
# Black does not support Python3.5
37+
# It will run on 3.6+, so we can
38+
# safely disable it for 3.5 env
39+
if: matrix.python-version != '3.5'
40+
run: |
41+
# Install black only for Py3.6+
42+
pip install black==19.10b0
43+
# Check Black code style compliance
44+
black ./ --skip-string-normalization --check
45+
# Check PEP-8 compliance
46+
flake8
4147
42-
- name: Unit Tests
43-
run: |
44-
pytest --cov=cromwell_tools --cov-report=xml cromwell_tools/tests
48+
- name: Unit Tests
49+
run: |
50+
pytest --cov=cromwell_tools --cov-report=xml cromwell_tools/tests
4551
46-
- name: Upload coverage to Codecov
47-
uses: codecov/codecov-action@v1
48-
with:
49-
token: ${{ secrets.CODECOV_TOKEN }}
50-
flags: unittests
51-
name: Cromwell-tools Test Coverage
52-
fail_ci_if_error: false # See https://github.com/codecov/codecov-action/issues/29
52+
- name: Upload coverage to Codecov
53+
uses: codecov/codecov-action@v1
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}
56+
flags: unittests
57+
name: Cromwell-tools Test Coverage
58+
fail_ci_if_error: false # See https://github.com/codecov/codecov-action/issues/29

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ repos:
33
rev: 19.10b0
44
hooks:
55
- id: black
6+
# Note: this does NOT support Python3.5!
67
language_version: python3
78
# Using args here is not recommended by Black:
89
# https://black.readthedocs.io/en/stable/version_control_integration.html

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Cromwell-tools
2121
:target: https://img.shields.io/github/license/broadinstitute/cromwell-tools.svg?style=flat-square
2222
:alt: License
2323

24-
.. image:: https://img.shields.io/badge/python-3.6|3.7-green.svg?style=flat-square&logo=python&colorB=blue
25-
:target: https://img.shields.io/badge/python-3.6|3.7-green.svg?style=flat-square&logo=python&colorB=blue
24+
.. image:: https://img.shields.io/badge/python-3.5|3.6|3.7-green.svg?style=flat-square&logo=python&colorB=blue
25+
:target: https://img.shields.io/badge/python-3.5|3.6|3.7-green.svg?style=flat-square&logo=python&colorB=blue
2626
:alt: Language
2727

2828
.. image:: https://img.shields.io/badge/Code%20Style-black-000000.svg?style=flat-square

codecov.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
status:
10+
project: # settings affecting project coverage
11+
default:
12+
target: auto # auto % coverage target
13+
threshold: 5% # allow for 5% reduction of coverage without failing
14+
15+
# do not run coverage on patch nor changes
16+
patch: false
17+
18+
parsers:
19+
gcov:
20+
branch_detection:
21+
conditional: yes
22+
loop: yes
23+
method: no
24+
macro: no
25+
26+
comment:
27+
layout: "reach,diff,flags,tree"
28+
behavior: default
29+
require_changes: no

cromwell_tools/tests/test_utilities.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,15 @@ def test_compose_oauth_options_for_jes_backend_cromwell_add_required_fields_to_w
450450
result_options = utils.compose_oauth_options_for_jes_backend_cromwell(
451451
test_auth, self.options_file_BytesIO
452452
)
453-
result_options_in_dict = json.loads(result_options.getvalue())
453+
# use .decode('utf-8') for Python3.5 compatibility
454+
result_options_in_dict = json.loads(result_options.getvalue().decode('utf-8'))
454455

455456
assert (
457+
# use .decode('utf-8') for Python3.5 compatibility
456458
result_options_in_dict['read_from_cache']
457-
== json.loads(self.options_file_BytesIO.getvalue())['read_from_cache']
459+
== json.loads(self.options_file_BytesIO.getvalue().decode('utf-8'))[
460+
'read_from_cache'
461+
]
458462
)
459463
assert (
460464
result_options_in_dict['google_project']
@@ -484,7 +488,8 @@ def test_if_compose_oauth_options_for_jes_backend_cromwell_can_deal_with_null_wo
484488
)
485489

486490
result_options = utils.compose_oauth_options_for_jes_backend_cromwell(test_auth)
487-
result_options_in_dict = json.loads(result_options.getvalue())
491+
# use .decode('utf-8') for Python3.5 compatibility
492+
result_options_in_dict = json.loads(result_options.getvalue().decode('utf-8'))
488493

489494
assert (
490495
result_options_in_dict['google_project']

cromwell_tools/utilities.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ def validate_cromwell_label(
245245
elif isinstance(label_object, bytes):
246246
label_object = json.loads(label_object.decode('utf-8'))
247247
elif isinstance(label_object, io.BytesIO):
248-
label_object = json.loads(label_object.getvalue())
248+
# use .decode('utf-8') for Python3.5 compatibility
249+
label_object = json.loads(label_object.getvalue().decode('utf-8'))
249250

250251
for label_key, label_value in label_object.items():
251252
err_msg += _content_checker(_CROMWELL_LABEL_KEY_REGEX, label_key)
@@ -399,7 +400,8 @@ def compose_oauth_options_for_jes_backend_cromwell(
399400
cromwell_options_file = io.BytesIO(json.dumps({}).encode())
400401

401402
# using `getvalue()` here so we don't have to seek back to the beginning if we need the value again
402-
options_json = json.loads(cromwell_options_file.getvalue())
403+
# use .decode('utf-8') for Python3.5 compatibility
404+
options_json = json.loads(cromwell_options_file.getvalue().decode('utf-8'))
403405
google_project = auth.service_key_content['project_id']
404406

405407
options_json.update(

requirements-test.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
black==19.10b0
21
flake8==3.7.7
32
mock>=2.0.0
43
pre-commit==1.14.4

0 commit comments

Comments
 (0)