Skip to content

Commit c9c1fbd

Browse files
committed
added release workflow
1 parent 634b665 commit c9c1fbd

File tree

5 files changed

+92
-42
lines changed

5 files changed

+92
-42
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
release:
8+
types: [published]
9+
push:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
max-parallel: 3
16+
matrix:
17+
python-version: [3.5, 3.6, 3.7]
18+
steps:
19+
- uses: actions/checkout@v1
20+
- name: Setup Python ${{matrix.python-version}}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install Dependencies
25+
run: pip install tox tox-gh-actions
26+
- name: Flake8
27+
run: tox -e flake8
28+
- name: Black Check
29+
run: tox -e black-check
30+
- name: Pylint
31+
run: tox -e pylint
32+
# starts 3 jobs, 1 for each python version
33+
- name: Test
34+
run: tox
35+
env:
36+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
37+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38+
AWS_DEFAULT_REGION: us-west-2
39+
CODECOV_UPLOAD_TOKEN: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
40+
release:
41+
needs: build
42+
if: github.event_name == 'release' && github.repository == 'aws/sagemaker-experiments'
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v1
46+
- name: Setup Python
47+
uses: actions/setup-python@v1
48+
with:
49+
python-version: '3.x'
50+
- name: Install Dependencies
51+
run: pip install setuptools wheel twine tox
52+
- name: Create Distribution
53+
run: python setup.py bdist_wheel
54+
- name: Sign Release
55+
run: |
56+
echo "${{ secrets.PYPI_SIGN_PRIVATE_KEY }}" | gpg --batch --import --no-default-keyring --keyring ./sessionring.gpg
57+
gpg --no-default-keyring --keyring ./sessionring.gpg --pinentry-mode loopback --passphrase ""${{ secrets.PYPI_SIGN_PASSPHRASE }}"" --detach-sign -ao /dev/null dist/*
58+
- name: Twine Check
59+
run: twine check dist/*
60+
- name: Publish to PyPi
61+
uses: pypa/gh-action-pypi-publish@master
62+
with:
63+
user: ${{ secrets.PYPI_USERNAME }}
64+
password: ${{ secrets.PYPI_PASSWORD }}
65+
repository_url: https://test.pypi.org/legacy/

.github/workflows/main.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ See: `sagemaker-experiments <https://github.com/awslabs/amazon-sagemaker-example
110110

111111
License
112112
-------
113-
This library is licensed under the Apache 2.0 License.
113+
This library is licensed under the Apache 2.0 License.
114114

115115
Running Tests
116116
-------------

tests/conftest.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def boto_model_file(request):
4343

4444
@pytest.fixture
4545
def sagemaker_boto_client():
46-
return boto3.client("sagemaker", endpoint_url=os.environ.get("SAGEMAKER_ENDPOINT"))
46+
if os.environ.get("SAGEMAKER_ENDPOINT", "").strip():
47+
return boto3.client("sagemaker", endpoint_url=os.environ.get("SAGEMAKER_ENDPOINT"))
48+
else:
49+
return boto3.client("sagemaker")
4750

4851

4952
@pytest.fixture(scope="session")
@@ -108,10 +111,14 @@ def trials(experiment_obj, sagemaker_boto_client):
108111

109112
@pytest.fixture
110113
def experiments(sagemaker_boto_client):
111-
experiment_objs = [
112-
experiment.Experiment.create(experiment_name=experiment_name, sagemaker_boto_client=sagemaker_boto_client)
113-
for experiment_name in names()
114-
]
114+
experiment_objs = []
115+
116+
for experiment_name in names():
117+
experiment_objs.append(
118+
experiment.Experiment.create(experiment_name=experiment_name, sagemaker_boto_client=sagemaker_boto_client)
119+
)
120+
time.sleep(1)
121+
115122
yield experiment_objs
116123
for experiment_obj in experiment_objs:
117124
experiment_obj.delete()
@@ -282,6 +289,7 @@ def docker_image(boto_model_file):
282289
# pull existing image for layer cache
283290
try:
284291
client.images.pull(tag, auth_config={"username": username, "password": password})
292+
print("Docker image with tag {} already exists.".format(tag))
285293
# the image with this tag already exists
286294
return tag
287295
except docker.errors.NotFound:

tox.ini

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,25 @@ require-code = True
4343

4444
[testenv]
4545
passenv =
46-
TOXENV
4746
AWS_ACCESS_KEY_ID
4847
AWS_SECRET_ACCESS_KEY
4948
AWS_SESSION_TOKEN
5049
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
5150
AWS_DEFAULT_REGION
5251
SAGEMAKER_ENDPOINT
5352
CODECOV_UPLOAD_TOKEN
54-
53+
# used by codecov
54+
GITHUB_*
55+
whitelist_externals =
56+
echo
57+
codecov
5558
# {posargs} can be passed in by additional arguments specified when invoking tox.
5659
# Can be used to specify which tests to run, e.g.: tox -- -s
5760
commands =
61+
echo running env: {envname}
5862
coverage run --source smexperiments -m pytest {posargs} -m "not slow"
5963
{env:IGNORE_COVERAGE:} coverage report --fail-under=95
60-
codecov -e TOXENV -t {env:CODECOV_UPLOAD_TOKEN:}
64+
codecov -e {envname} -t {env:CODECOV_UPLOAD_TOKEN}
6165
extras = test
6266
deps =
6367
boto3 >= 1.10.32
@@ -76,6 +80,12 @@ deps =
7680
flake8-future-import
7781
commands = flake8
7882

83+
[gh-actions]
84+
python =
85+
3.5: py35
86+
3.6: py36
87+
3.7: py37
88+
7989
[testenv:black-format]
8090
# Used during development (before committing) to format .py files.
8191
deps = black

0 commit comments

Comments
 (0)