Skip to content

Commit 029f04e

Browse files
committed
run integ tests only when secrets are available
1 parent 1f1a0b7 commit 029f04e

File tree

5 files changed

+61
-39
lines changed

5 files changed

+61
-39
lines changed

.github/workflows/build_release.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,50 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
strategy:
15-
max-parallel: 3
16-
matrix:
17-
python-version: [3.5, 3.6, 3.7]
1814
steps:
19-
- name: Check Environment
20-
run: |
21-
if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY ]]; then
22-
echo "Missing required environment variables."
23-
echo "If this a pull request check your fork's action history."
24-
exit 1
25-
fi
26-
env:
27-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
28-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2915
- uses: actions/checkout@v1
30-
- name: Setup Python ${{matrix.python-version}}
16+
- name: Setup Python 3.5
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: 3.5
20+
- name: Setup Python 3.6
3121
uses: actions/setup-python@v1
3222
with:
33-
python-version: ${{ matrix.python-version }}
23+
python-version: 3.6
24+
- name: Setup Python 3.7
25+
uses: actions/setup-python@v1
26+
with:
27+
python-version: 3.7
3428
- name: Install Dependencies
35-
run: pip install tox tox-gh-actions
29+
run: pip install tox
3630
- name: Flake8
3731
run: tox -e flake8
3832
- name: Black Check
3933
run: tox -e black-check
4034
- name: Pylint
4135
run: tox -e pylint
42-
# starts 3 jobs, 1 for each python version
43-
- name: Test
44-
run: tox
36+
# runs unit tests for each python version
37+
- name: Unit Tests
38+
run: tox -- tests/unit
39+
env:
40+
AWS_DEFAULT_REGION: us-west-2
41+
- name: Integration Tests
42+
# pull requests are untrusted and do not have access to secrets needed for integ tests
43+
if: github.event_name != 'pull_request'
44+
run: tox -e py36 -- tests/integ
4545
env:
4646
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
4747
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4848
AWS_DEFAULT_REGION: us-west-2
49-
CODECOV_UPLOAD_TOKEN: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
49+
COVERAGE_FILE: .coverage.integ
50+
IGNORE_COVERAGE: '-'
51+
- name: Upload Code Coverage
52+
if: github.event_name == 'release'
53+
run: |
54+
coverage combine .coverage*
55+
codecov -t {env:CODECOV_UPLOAD_TOKEN}
56+
env:
57+
CODECOV_UPLOAD_TOKEN: ${{ secrets.AWS_ACCESS_KEY_ID }}
5058

5159
release:
5260
needs: build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pip-delete-this-directory.txt
2828
# Unit test / coverage reports
2929
.tox/
3030
.coverage
31+
.coverage.integ
3132
.cache
3233
nosetests.xml
3334
coverage.xml

docs/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import os
1717
import sys
1818

19-
sys.path.insert(0, os.path.abspath('..'))
19+
sys.path.insert(0, os.path.abspath(".."))
2020

2121
# -- Project information -----------------------------------------------------
2222

23-
project = 'sagemaker-experiments'
23+
project = "sagemaker-experiments"
2424
copyright = u"%s, Amazon" % datetime.now().year
25-
author = 'Amazon Web Services'
25+
author = "Amazon Web Services"
2626
version = pkg_resources.require(project)[0].version
2727

2828
# -- General configuration ---------------------------------------------------
@@ -42,7 +42,7 @@
4242
]
4343

4444
# Add any paths that contain templates here, relative to this directory.
45-
templates_path = ['_templates']
45+
templates_path = ["_templates"]
4646

4747
source_suffix = ".rst" # The suffix of source filenames.
4848
master_doc = "index" # The master toctree document.
@@ -59,7 +59,7 @@
5959

6060
pygments_style = "default"
6161
autoclass_content = "both"
62-
#autodoc_default_options = {"show-inheritance", "members", "undoc-members"}
62+
# autodoc_default_options = {"show-inheritance", "members", "undoc-members"}
6363
autodoc_member_order = "bysource"
6464
if "READTHEDOCS" in os.environ:
6565
html_theme = "default"
@@ -75,4 +75,4 @@
7575
autosummary_generate = True
7676

7777
# autosectionlabel
78-
autosectionlabel_prefix_document = True
78+
autosectionlabel_prefix_document = True

tests/unit/test_tracker.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ def test_log_metric(under_test):
196196
under_test._metrics_writer.log_metric.assert_called_with("foo", 1.0, 1, now)
197197

198198

199+
def test_log_metric_attribute_error(under_test):
200+
now = datetime.datetime.now()
201+
202+
exception = AttributeError
203+
204+
under_test._metrics_writer.log_metric.side_effect = exception
205+
206+
with pytest.raises(AttributeError):
207+
under_test.log_metric("foo", 1.0, 1, now)
208+
209+
210+
def test_log_metric_attribute_error_warned(under_test):
211+
now = datetime.datetime.now()
212+
213+
under_test._metrics_writer = None
214+
under_test._warned_on_metrics = None
215+
216+
under_test.log_metric("foo", 1.0, 1, now)
217+
218+
assert under_test._warned_on_metrics == True
219+
220+
199221
def test_log_artifact(under_test):
200222
under_test.log_artifact("foo.txt", "name", "whizz/bang")
201223
under_test._artifact_uploader.upload_artifact.assert_called_with("foo.txt")

tox.ini

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{35,36,37},flake8,black-format,black-check,pylint
2+
envlist = py{35,36,37}
33

44
skip_missing_interpreters = False
55
ignore_basepython_conflict = True
@@ -50,8 +50,7 @@ passenv =
5050
AWS_DEFAULT_REGION
5151
SAGEMAKER_ENDPOINT
5252
CODECOV_UPLOAD_TOKEN
53-
# used by codecov
54-
GITHUB_*
53+
COVERAGE_FILE
5554
whitelist_externals =
5655
echo
5756
codecov
@@ -61,7 +60,6 @@ commands =
6160
echo running env: {envname}
6261
coverage run --source smexperiments -m pytest {posargs} -m "not slow"
6362
{env:IGNORE_COVERAGE:} coverage report --fail-under=95
64-
codecov -e {envname} -t {env:CODECOV_UPLOAD_TOKEN}
6563
extras = test
6664
deps =
6765
boto3 >= 1.10.32
@@ -80,12 +78,6 @@ deps =
8078
flake8-future-import
8179
commands = flake8
8280

83-
[gh-actions]
84-
python =
85-
3.5: py35
86-
3.6: py36
87-
3.7: py37
88-
8981
[testenv:black-format]
9082
# Used during development (before committing) to format .py files.
9183
deps = black
@@ -114,7 +106,6 @@ passenv =
114106
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
115107
AWS_DEFAULT_REGION
116108
SAGEMAKER_ENDPOINT
117-
118109
# {posargs} can be passed in by additional arguments specified when invoking tox.
119110
# Can be used to specify which tests to run, e.g.: tox -- -s
120111
commands =
@@ -138,4 +129,4 @@ deps =
138129
sphinx-rtd-theme
139130
readthedocs-sphinx-ext
140131
commands =
141-
sphinx-build -T -W -b html -d _build/doctrees-readthedocs -D language=en . _build/html
132+
sphinx-build -T -W -b html -d _build/doctrees-readthedocs -D language=en . _build/html

0 commit comments

Comments
 (0)