Skip to content

Commit 63af5e0

Browse files
authored
Merge CI/CD changes (#2)
* first draft * update PYTHONPATH * remove mock.assert_called_once() * set env vars * removed 3.7 * removed old doc link * initial draft * deploy to github pages * added stages * order stages * debug * build doc * set python version for sphinx * added before_deploy step * set doc dir * debug * cleanup stages * add .nojekyll * added 3.7 * cache pip packages * test pypi * fixed dict ordering issue * added description * added url * 0.9.1 * trigger build * secure password * codecov * fixed pypi url * 0.9.3. deploy tagged releases only * updated codecov. added GitHub Releases * install requirements for codecov * remove unnecessary test steps * zip source * debug * v0.9.5 * upload documentation * deploy on tags * deploy on tags * fix doc deployment * skip deploy cleanup * separate deployment steps * fix file upload * cleanup
1 parent 5700298 commit 63af5e0

File tree

10 files changed

+170
-15
lines changed

10 files changed

+170
-15
lines changed

.gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## Editor temporary/working/backup files
2+
.#*
3+
*\#*\#
4+
[#]*#
5+
*~
6+
*$
7+
*.bak
8+
*.old
9+
*.log
10+
*.nfs*
11+
*.swo
12+
*.swp
13+
*.pdb
14+
.project
15+
.pydevproject
16+
.settings
17+
.idea
18+
.pytest_cache
19+
.vagrant
20+
.noseids
21+
.ipynb_checkpoints
22+
.tags
23+
*.iml
24+
25+
## Python files
26+
# setup.py working directory
27+
build
28+
# setup.py dist directory
29+
dist
30+
# Egg metadata
31+
*.egg-info
32+
.eggs
33+
.pypirc
34+
35+
## tox testing tool
36+
.tox
37+
# rope
38+
.ropeproject
39+
# wheel files
40+
*.whl
41+
**/wheelhouse/*
42+
# coverage
43+
.coverage
44+
swat.egg-info/
45+
__pycache__/
46+
_stats.txt
47+
cover/
48+
test-reports/
49+
.pytest_cache
50+
51+
## OS generated files
52+
.directory
53+
.gdb_history
54+
.DS_Store
55+
ehthumbs.db
56+
Icon?
57+
Thumbs.db
58+
59+
## Documentation generated files
60+
doc/build
61+
doc/source/generated
62+
doc/_build

.travis.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
dist: xenial # Currently required for Python 3.7
2+
language: python
3+
cache: pip
4+
5+
python:
6+
- "2.7"
7+
- "3.4"
8+
- "3.5"
9+
- "3.7"
10+
# 3.6 handled during code coverage
11+
12+
env:
13+
- PYTHONPATH=$PYTHONPATH:./src
14+
15+
install:
16+
- pip install -r test_requirements.txt
17+
18+
script:
19+
- pytest
20+
21+
jobs:
22+
include:
23+
- stage: upload codecov results
24+
python: 3.6
25+
install:
26+
- pip install pytest pytest-cov codecov
27+
- pip install -r test_requirements.txt
28+
script:
29+
- pytest --cov=./
30+
- codecov
31+
32+
- stage: create release
33+
if: tag is present
34+
python: 3.6
35+
install: pip install sphinx
36+
script:
37+
- sphinx-build -Ean -b html -j auto -D todo_include_todos=0 ./doc ./doc/_build/html
38+
- pushd ./doc/_build/html ; zip -r ../../../${TRAVIS_TAG}-doc.zip . ; popd
39+
deploy:
40+
provider: releases
41+
skip_cleanup: true
42+
api_key: $GITHUB_TOKEN
43+
file: ${TRAVIS_TAG}-doc.zip
44+
draft: true
45+
on:
46+
tags: true
47+
48+
- stage: upload documentation
49+
if: tag is present
50+
python: 3.6
51+
install: pip install sphinx
52+
script:
53+
- sphinx-build -Ean -b html -j auto -D todo_include_todos=0 ./doc ./doc/_build/html
54+
- touch ./doc/_build/html/.nojekyll
55+
deploy:
56+
provider: pages
57+
skip_cleanup: true
58+
github_token: $GITHUB_TOKEN
59+
keep_history: false
60+
local_dir: ./doc/_build/html
61+
on:
62+
tags: true
63+
64+
- stage: deploy to pypi (test)
65+
if: tag is present
66+
script: # Cancel out default script
67+
-
68+
deploy:
69+
provider: pypi
70+
server: https://test.pypi.org/legacy/
71+
user:
72+
secure: uHXdHqYzzi/2Gc9/8kP4nBKAf2zgIOri1bHWnmgNoBNhWJuma4MWMuMUCzQU+QbrMvOiOm+EZRz1+rBXDOsqa7T+22OZRMBIUFfc3BG5ItYm8DXOUznWLy2/32yQngEohpYwn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lUIRRY9ZMivPFuuTevcloKer4423/HaTi7CZU26niBma9UuORdIbc2YDLRc/DIztGBaTp7ZwNXlFfVZ8jkXYHov4aU5xKoehPFLcko1Ltii9BpH8Rv1b7GW09G3QPpB9Mx3RuG9GFQgvkD6nZI/hpyXooBphklPzG88m6EmzfGsojJlDqoPExJs=
75+
distributions: sdist bdist_wheel
76+
on:
77+
tags: true
78+
79+

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<a href="https://www.python.org/">
2+
<img src="https://img.shields.io/badge/Python-3+-blue.svg?&style=for-the-badge&colorA=254f73" alt="Python Version">
3+
</a>
4+
15
# sasctl
26

37
## Overview
@@ -39,8 +43,6 @@ pip install git+https://github.com/sassoftware/python-sasctl
3943

4044
## Getting Started
4145

42-
Read the full documentation here: [http://xeno.glpages.sas.com/python-sasctl](http://xeno.glpages.sas.com/python-sasctl)
43-
4446
Once the sasctl package has been installed and you have a SAS Viya server to connect to,
4547
the first step is to establish a session:
4648
```

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@ def read_dunder(name):
1919
raise RuntimeError('Unable to find __%s__ in __init__.py' % name)
2020

2121

22+
def get_file(filename):
23+
with open(filename, 'r') as f:
24+
return f.read()
25+
2226
setup(
2327
name='sasctl',
28+
description='SAS Viya REST Client',
29+
long_description=get_file('README.md'),
30+
long_description_content_type='text/markdown',
2431
version=read_dunder('version'),
2532
author=read_dunder('author'),
33+
url='https://github.com/sassoftware/python-sasctl/',
2634
packages=find_packages(where="src"),
2735
package_dir={"": "src"},
28-
install_requires = ['requests', 'six >= 1.11'],
36+
install_requires=[
37+
'requests',
38+
'six >= 1.11'
39+
],
2940
extras_require = {
3041
'swat': ['swat'],
3142
'kerberos': ['kerberos ; platform_system != "Windows"',

src/sasctl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
55
# SPDX-License-Identifier: Apache-2.0
66

7-
__version__ = '0.9'
7+
__version__ = '0.9.6'
88
__author__ = 'SAS'
99
__credits__ = ['Lucas De Paula, Peter Tobac, Jon Walker']
1010
__license__ = 'Apache 2.0'

tests/unit/test_core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_request():
1717

1818
resp = request('GET', 'example.com', session=mock_sess)
1919

20-
mock_sess.request.assert_called_once()
20+
assert mock_sess.request.call_count == 1
2121
assert isinstance(resp, RestObj)
2222
assert hasattr(resp, '_headers')
2323

@@ -41,7 +41,7 @@ def test_list_items():
4141

4242
resp = list_items()
4343

44-
request.assert_called_once()
44+
assert request.call_count == 1
4545
assert [RestObj()] == resp
4646

4747

@@ -56,7 +56,7 @@ def test_get_item_by_dict():
5656
resp = get_item(target)
5757

5858
assert target == resp
59-
request.assert_not_called()
59+
assert request.call_count == 0
6060

6161

6262
def test_get_item_by_name():
@@ -86,8 +86,8 @@ def test_get_item_by_id():
8686
request.return_value = target
8787
resp = get_item(12345)
8888

89-
is_uuid.assert_called_once()
90-
request.assert_called_once()
89+
assert is_uuid.call_count == 1
90+
assert request.call_count == 1
9191
assert target == resp
9292

9393

@@ -107,7 +107,7 @@ def test_update_item():
107107

108108
target._headers = {'etag': 'abcd'}
109109
resp = update_item(target)
110-
request.assert_called_once()
110+
assert request.call_count == 1
111111
assert ('put', '/widget/12345') == request.call_args[0]
112112
assert target == resp
113113

tests/unit/test_microanalytic_score.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_create_python_module():
2727
" return out1, out2"))
2828
create_module(source=source)
2929

30-
post.assert_called_once()
30+
assert post.call_count == 1
3131
json = post.call_args[1].get('json', {})
3232
assert 'text/x-python' == json['type']
3333
assert 'public' == json['scope']

tests/unit/test_model_management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_create_performance_definition():
5656
get_project.return_value['predictionVariable'] = 'predicted'
5757
_ = mm.create_performance_definition('model', 'TestLibrary', 'TestData')
5858

59-
post.assert_called_once()
59+
assert post.call_count == 1
6060
url, data = post.call_args
6161

6262
assert PROJECT['id'] == data['json']['projectId']

tests/unit/test_model_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_create_model():
4646
tool=target['tool'],
4747
is_champion=target['champion'],
4848
properties=dict(custom1=123, custom2='somevalue'))
49-
post.assert_called_once()
49+
assert post.call_count == 1
5050
url, data = post.call_args
5151

5252
# dict isn't guaranteed to preserve order
@@ -69,7 +69,7 @@ def test_create_model():
6969
get_project.return_value = {'id': PROJECT_ID}
7070
_ = mr.create_model(copy.deepcopy(target), PROJECT_NAME, description='Updated Model')
7171
target['description'] = 'Updated Model'
72-
post.assert_called_once()
72+
assert post.call_count == 1
7373
url, data = post.call_args
7474

7575
# dicts don't preserve order so property order may not match

tests/unit/test_restobj.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def test_restobj():
3434
def test_repr():
3535
d = dict(a=1, b=2)
3636

37-
assert str(d) in repr(RestObj(d))
37+
assert "'a': 1" in repr(RestObj(d))
38+
assert "'b': 2" in repr(RestObj(d))
3839

3940

4041
def test_str():

0 commit comments

Comments
 (0)