From a09b436dc55ac61fb77b46a0ea5ccdc5065210b0 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 11:17:56 -0700 Subject: [PATCH 01/21] add continuous-delivery --- continuous-delivery/pip-install-with-retry.py | 39 +++++++++++++++++++ continuous-delivery/publish_to_prod_pypi.yml | 25 ++++++++++++ continuous-delivery/publish_to_test_pypi.yml | 25 ++++++++++++ continuous-delivery/test_prod_pypi.yml | 28 +++++++++++++ continuous-delivery/test_test_pypi.yml | 30 ++++++++++++++ continuous-delivery/test_version_exists | 22 +++++++++++ continuous-delivery/test_version_exists.yml | 21 ++++++++++ 7 files changed, 190 insertions(+) create mode 100644 continuous-delivery/pip-install-with-retry.py create mode 100644 continuous-delivery/publish_to_prod_pypi.yml create mode 100644 continuous-delivery/publish_to_test_pypi.yml create mode 100644 continuous-delivery/test_prod_pypi.yml create mode 100644 continuous-delivery/test_test_pypi.yml create mode 100644 continuous-delivery/test_version_exists create mode 100644 continuous-delivery/test_version_exists.yml diff --git a/continuous-delivery/pip-install-with-retry.py b/continuous-delivery/pip-install-with-retry.py new file mode 100644 index 0000000..347e0dc --- /dev/null +++ b/continuous-delivery/pip-install-with-retry.py @@ -0,0 +1,39 @@ +import time +import sys +import subprocess + +DOCS = """Given cmdline args, executes: python3 -m pip install [args...] +Keeps retrying until the new version becomes available in pypi (or we time out)""" +if len(sys.argv) < 2: + sys.exit(DOCS) + +RETRY_INTERVAL_SECS = 10 +GIVE_UP_AFTER_SECS = 60 * 15 + +pip_install_args = [sys.executable, '-m', 'pip', 'install'] + sys.argv[1:] + +start_time = time.time() +while True: + print(subprocess.list2cmdline(pip_install_args)) + result = subprocess.run(pip_install_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + stdout = result.stdout.decode().strip() + if stdout: + print(stdout) + + if result.returncode == 0: + # success + sys.exit(0) + + if "could not find a version" in stdout.lower(): + elapsed_secs = time.time() - start_time + if elapsed_secs < GIVE_UP_AFTER_SECS: + # try again + print("Retrying in", RETRY_INTERVAL_SECS, "secs...") + time.sleep(RETRY_INTERVAL_SECS) + continue + else: + print("Giving up on retries after", int(elapsed_secs), "total secs.") + + # fail + sys.exit(result.returncode) diff --git a/continuous-delivery/publish_to_prod_pypi.yml b/continuous-delivery/publish_to_prod_pypi.yml new file mode 100644 index 0000000..c8d7885 --- /dev/null +++ b/continuous-delivery/publish_to_prod_pypi.yml @@ -0,0 +1,25 @@ +version: 0.2 +# this image assumes Ubuntu 14.04 base image +phases: + install: + commands: + - sudo apt-get update -y + - sudo apt-get install python3 python3-pip -y + - export PATH=$PATH:$HOME/.local/bin + - python3 -m pip install --user --upgrade pip + - python3 -m pip install --user --upgrade twine setuptools wheel awscli PyOpenSSL six + pre_build: + commands: + - cd aws-iot-device-sdk-python-v2 + - pypirc=$(aws secretsmanager get-secret-value --secret-id "prod/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc + - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) + - echo "Updating package version to ${PKG_VERSION}" + - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" awsiot/__init__.py + build: + commands: + - echo Build started on `date` + - python3 setup.py sdist bdist_wheel + - python3 -m twine upload -r pypi dist/* + post_build: + commands: + - echo Build completed on `date` diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml new file mode 100644 index 0000000..86cde41 --- /dev/null +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -0,0 +1,25 @@ +version: 0.2 +# this image assumes Ubuntu 14.04 base image +phases: + install: + commands: + - sudo apt-get update -y + - sudo apt-get install python3 python3-pip -y + - export PATH=$PATH:$HOME/.local/bin + - python3 -m pip install --user --upgrade pip + - python3 -m pip install --user --upgrade twine setuptools wheel awscli PyOpenSSL six + pre_build: + commands: + - pypirc=$(aws secretsmanager get-secret-value --secret-id "alpha/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc + - cd aws-iot-device-sdk-python-v2 + - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) + - echo "Updating package version to ${PKG_VERSION}" + - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" awsiot/__init__.py + build: + commands: + - echo Build started on `date` + - python3 setup.py sdist bdist_wheel + - python3 -m twine upload -r testpypi dist/* + post_build: + commands: + - echo Build completed on `date` diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml new file mode 100644 index 0000000..181c074 --- /dev/null +++ b/continuous-delivery/test_prod_pypi.yml @@ -0,0 +1,28 @@ +version: 0.2 +# this image assumes Ubuntu 14.04 base image +phases: + install: + commands: + - sudo apt-get update -y + - sudo apt-get install python3 python3-pip -y + - python3 -m pip install --upgrade pip + - python3 -m pip install --upgrade setuptools + + pre_build: + commands: + - curl https://www.amazontrust.com/repository/AmazonRootCA1.pem --output /tmp/AmazonRootCA1.pem + - cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$cert" > /tmp/certificate.pem + - key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$key" > /tmp/privatekey.pem + - ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') + build: + commands: + - echo Build started on `date` + - cd aws-iot-device-sdk-python-v2 + - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) + - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION + - python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace + + post_build: + commands: + - echo Build completed on `date` + diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml new file mode 100644 index 0000000..1fd0e51 --- /dev/null +++ b/continuous-delivery/test_test_pypi.yml @@ -0,0 +1,30 @@ +version: 0.2 +# this image assumes Ubuntu 14.04 base image +phases: + install: + commands: + - sudo apt-get update -y + - sudo apt-get install python3 python3-pip -y + - python3 -m pip install --upgrade pip + - python3 -m pip install --upgrade setuptools + + pre_build: + commands: + - curl https://www.amazontrust.com/repository/AmazonRootCA1.pem --output /tmp/AmazonRootCA1.pem + - cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$cert" > /tmp/certificate.pem + - key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$key" > /tmp/privatekey.pem + - ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') + build: + commands: + - echo Build started on `date` + - cd aws-iot-device-sdk-python-v2 + - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) + # this is here because typing isn't in testpypi, so pull it from prod instead + - python3 -m pip install typing + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user awsiotsdk==$CURRENT_TAG_VERSION + - python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace + + post_build: + commands: + - echo Build completed on `date` + diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists new file mode 100644 index 0000000..3579dbc --- /dev/null +++ b/continuous-delivery/test_version_exists @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e +set -x +# force a failure if there's no tag +git describe --tags +# now get the tag +CURRENT_TAG=$(git describe --tags | cut -f2 -dv) +# convert v0.2.12-2-g50254a9 to 0.2.12 +CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) +# if there's a hash on the tag, then this is not a release tagged commit +if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then + echo "Current tag version is not a release tag, cut a new release if you want to publish." + exit 1 +fi + +if python3 -m pip install --no-cache-dir -vvv AWSIoTPythonSDK==$CURRENT_TAG_VERSION; then + echo "$CURRENT_TAG_VERSION is already in pypi, cut a new tag if you want to upload another version." + exit 1 +fi + +echo "$CURRENT_TAG_VERSION currently does not exist in pypi, allowing pipeline to continue." +exit 0 diff --git a/continuous-delivery/test_version_exists.yml b/continuous-delivery/test_version_exists.yml new file mode 100644 index 0000000..ca67e64 --- /dev/null +++ b/continuous-delivery/test_version_exists.yml @@ -0,0 +1,21 @@ +version: 0.2 +#this build spec assumes the ubuntu 14.04 trusty image +#this build run simply verifies we haven't published something at this tag yet. +#if we have we fail the build and stop the pipeline, if we haven't we allow the pipeline to run. +phases: + install: + commands: + - sudo apt-get update -y + - sudo apt-get install python3 python3-pip -y + - pip3 install --upgrade setuptools + pre_build: + commands: + build: + commands: + - echo Build started on `date` + - cd aws-iot-device-sdk-python-v2 + - bash ./continuous-delivery/test_version_exists + post_build: + commands: + - echo Build completed on `date` + From bf9c0d1b2e0b154a226f9dc4bc932b41a83d4e5f Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 13:50:02 -0700 Subject: [PATCH 02/21] update test_version_exists --- continuous-delivery/test_version_exists.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/continuous-delivery/test_version_exists.yml b/continuous-delivery/test_version_exists.yml index ca67e64..2704ba7 100644 --- a/continuous-delivery/test_version_exists.yml +++ b/continuous-delivery/test_version_exists.yml @@ -10,10 +10,10 @@ phases: - pip3 install --upgrade setuptools pre_build: commands: + - echo Build start on `date` build: commands: - - echo Build started on `date` - - cd aws-iot-device-sdk-python-v2 + - cd aws-iot-device-sdk-python - bash ./continuous-delivery/test_version_exists post_build: commands: From 7657abd2e0e563ea9964f30892543e39ea044f22 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 14:28:27 -0700 Subject: [PATCH 03/21] update deployment script --- continuous-delivery/publish_to_prod_pypi.yml | 2 +- continuous-delivery/test_prod_pypi.yml | 2 +- continuous-delivery/test_test_pypi.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/continuous-delivery/publish_to_prod_pypi.yml b/continuous-delivery/publish_to_prod_pypi.yml index c8d7885..a3d739f 100644 --- a/continuous-delivery/publish_to_prod_pypi.yml +++ b/continuous-delivery/publish_to_prod_pypi.yml @@ -14,7 +14,7 @@ phases: - pypirc=$(aws secretsmanager get-secret-value --secret-id "prod/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" awsiot/__init__.py + - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml index 181c074..5897f38 100644 --- a/continuous-delivery/test_prod_pypi.yml +++ b/continuous-delivery/test_prod_pypi.yml @@ -17,7 +17,7 @@ phases: build: commands: - echo Build started on `date` - - cd aws-iot-device-sdk-python-v2 + - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION - python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 1fd0e51..84830c1 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -17,7 +17,7 @@ phases: build: commands: - echo Build started on `date` - - cd aws-iot-device-sdk-python-v2 + - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing From d08006aa2f8c5c5356f9becfbac08c7e671a9ef2 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 15:12:27 -0700 Subject: [PATCH 04/21] update deployment test and scripts --- continuous-delivery/publish_to_prod_pypi.yml | 2 +- continuous-delivery/publish_to_test_pypi.yml | 4 ++-- continuous-delivery/test_prod_pypi.yml | 2 +- continuous-delivery/test_test_pypi.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/continuous-delivery/publish_to_prod_pypi.yml b/continuous-delivery/publish_to_prod_pypi.yml index a3d739f..b6c63a4 100644 --- a/continuous-delivery/publish_to_prod_pypi.yml +++ b/continuous-delivery/publish_to_prod_pypi.yml @@ -10,7 +10,7 @@ phases: - python3 -m pip install --user --upgrade twine setuptools wheel awscli PyOpenSSL six pre_build: commands: - - cd aws-iot-device-sdk-python-v2 + - cd aws-iot-device-sdk-python - pypirc=$(aws secretsmanager get-secret-value --secret-id "prod/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 86cde41..ede62b8 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -11,10 +11,10 @@ phases: pre_build: commands: - pypirc=$(aws secretsmanager get-secret-value --secret-id "alpha/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc - - cd aws-iot-device-sdk-python-v2 + - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" awsiot/__init__.py + - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml index 5897f38..da416bd 100644 --- a/continuous-delivery/test_prod_pypi.yml +++ b/continuous-delivery/test_prod_pypi.yml @@ -20,7 +20,7 @@ phases: - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION - - python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test post_build: commands: diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 84830c1..5b8adc5 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -21,8 +21,8 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user awsiotsdk==$CURRENT_TAG_VERSION - - python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test post_build: commands: From bece8387e2d2f15f7e9702e8f9119ffd744b402d Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 15:17:05 -0700 Subject: [PATCH 05/21] add --universal option for python2&3 --- continuous-delivery/publish_to_prod_pypi.yml | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/continuous-delivery/publish_to_prod_pypi.yml b/continuous-delivery/publish_to_prod_pypi.yml index b6c63a4..e2fd958 100644 --- a/continuous-delivery/publish_to_prod_pypi.yml +++ b/continuous-delivery/publish_to_prod_pypi.yml @@ -18,7 +18,7 @@ phases: build: commands: - echo Build started on `date` - - python3 setup.py sdist bdist_wheel + - python3 setup.py sdist bdist_wheel --universal - python3 -m twine upload -r pypi dist/* post_build: commands: diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index ede62b8..d8ab916 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -18,7 +18,7 @@ phases: build: commands: - echo Build started on `date` - - python3 setup.py sdist bdist_wheel + - python3 setup.py sdist bdist_wheel --universal - python3 -m twine upload -r testpypi dist/* post_build: commands: From a5e922a45ff788fb5871d5ecf8a3e1f835d9df75 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 11 Apr 2022 15:19:04 -0700 Subject: [PATCH 06/21] remove version check for test --- continuous-delivery/test_version_exists | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists index 3579dbc..6d9bcb8 100644 --- a/continuous-delivery/test_version_exists +++ b/continuous-delivery/test_version_exists @@ -8,10 +8,10 @@ CURRENT_TAG=$(git describe --tags | cut -f2 -dv) # convert v0.2.12-2-g50254a9 to 0.2.12 CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) # if there's a hash on the tag, then this is not a release tagged commit -if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then - echo "Current tag version is not a release tag, cut a new release if you want to publish." - exit 1 -fi +# if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then +# echo "Current tag version is not a release tag, cut a new release if you want to publish." +# exit 1 +# fi if python3 -m pip install --no-cache-dir -vvv AWSIoTPythonSDK==$CURRENT_TAG_VERSION; then echo "$CURRENT_TAG_VERSION is already in pypi, cut a new tag if you want to upload another version." From 533b588a0a5a806bb9c614305b4bf9fd65e7556f Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 11:13:16 -0700 Subject: [PATCH 07/21] update package name --- continuous-delivery/test_prod_pypi.yml | 2 +- setup_test.py | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 setup_test.py diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml index da416bd..fa49265 100644 --- a/continuous-delivery/test_prod_pypi.yml +++ b/continuous-delivery/test_prod_pypi.yml @@ -19,7 +19,7 @@ phases: - echo Build started on `date` - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION + - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test post_build: diff --git a/setup_test.py b/setup_test.py new file mode 100644 index 0000000..f9d2a64 --- /dev/null +++ b/setup_test.py @@ -0,0 +1,34 @@ +import sys +sys.path.insert(0, 'AWSIoTPythonSDK') +import AWSIoTPythonSDK +currentVersion = AWSIoTPythonSDK.__version__ + +from distutils.core import setup +setup( + name = 'AWSIoTPythonSDK-V1', + packages=['AWSIoTPythonSDK', 'AWSIoTPythonSDK.core', + 'AWSIoTPythonSDK.core.util', 'AWSIoTPythonSDK.core.shadow', 'AWSIoTPythonSDK.core.protocol', + 'AWSIoTPythonSDK.core.jobs', + 'AWSIoTPythonSDK.core.protocol.paho', 'AWSIoTPythonSDK.core.protocol.internal', + 'AWSIoTPythonSDK.core.protocol.connection', 'AWSIoTPythonSDK.core.greengrass', + 'AWSIoTPythonSDK.core.greengrass.discovery', 'AWSIoTPythonSDK.exception'], + version = currentVersion, + description = 'SDK for connecting to AWS IoT using Python.', + author = 'Amazon Web Service', + author_email = '', + url = 'https://github.com/aws/aws-iot-device-sdk-python.git', + download_url = 'https://s3.amazonaws.com/aws-iot-device-sdk-python/aws-iot-device-sdk-python-latest.zip', + keywords = ['aws', 'iot', 'mqtt'], + classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Natural Language :: English", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5" + ] +) From cd8b757e4922d521c84799f4589dcacb8c278bfd Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 11:14:08 -0700 Subject: [PATCH 08/21] update test setup --- continuous-delivery/publish_to_test_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index d8ab916..6a1db5c 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -18,7 +18,7 @@ phases: build: commands: - echo Build started on `date` - - python3 setup.py sdist bdist_wheel --universal + - python3 setup_test.py sdist bdist_wheel --universal - python3 -m twine upload -r testpypi dist/* post_build: commands: From 24e1a4d0048864d0e441b0962817e14e385142da Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 12:01:51 -0700 Subject: [PATCH 09/21] add logs flag for test-pypi --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 1ad354e..5b60188 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.9" +__version__ = "1.5.0" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 6a1db5c..c8f610b 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -19,7 +19,7 @@ phases: commands: - echo Build started on `date` - python3 setup_test.py sdist bdist_wheel --universal - - python3 -m twine upload -r testpypi dist/* + - python3 -m twine upload -r testpypi dist/* --verbose post_build: commands: - echo Build completed on `date` From 3d48971f26bcbaf482980128f0b0316dbe3b119e Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 12:57:33 -0700 Subject: [PATCH 10/21] update test test-pypi for new package name --- continuous-delivery/test_test_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 5b8adc5..7552e79 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -21,7 +21,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test post_build: From 04ad731a947ea149a963366d08c77bc59ceb04ec Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 13:13:49 -0700 Subject: [PATCH 11/21] update set command for version number update --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_prod_pypi.yml | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 5b60188..1ad354e 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.5.0" +__version__ = "1.4.9" diff --git a/continuous-delivery/publish_to_prod_pypi.yml b/continuous-delivery/publish_to_prod_pypi.yml index e2fd958..d911029 100644 --- a/continuous-delivery/publish_to_prod_pypi.yml +++ b/continuous-delivery/publish_to_prod_pypi.yml @@ -14,7 +14,7 @@ phases: - pypirc=$(aws secretsmanager get-secret-value --secret-id "prod/aws-crt-python/.pypirc" --query "SecretString" | cut -f2 -d\") && echo "$pypirc" > ~/.pypirc - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" AWSIoTPythonSDK/__init__.py + - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index c8f610b..49a69c9 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -14,7 +14,7 @@ phases: - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = '.+'/__version__ = '${PKG_VERSION}'/" AWSIoTPythonSDK/__init__.py + - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` From d908131009cf59ae259de4f945febbc5bb49f1a9 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 13:21:17 -0700 Subject: [PATCH 12/21] hard code the version number for test --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 1ad354e..0f228f2 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.9" +__version__ = "1.5.1" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 49a69c9..32317d4 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -14,7 +14,7 @@ phases: - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py + #- sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` From 0738f24b039ecf76a67170dad58c630b8f7b3a58 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 13:35:26 -0700 Subject: [PATCH 13/21] hard code the version number for test --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/test_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 0f228f2..4963389 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.5.1" +__version__ = "1.4.8" diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 7552e79..295731a 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -21,7 +21,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==1.4.8 - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test post_build: From 5d989a16287eef624e56682b473d01294ea1bb4e Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 15:04:52 -0700 Subject: [PATCH 14/21] fix test command --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/test_test_pypi.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 4963389..ac329c9 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.8" +__version__ = "1.4.7" diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 295731a..c358c75 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -12,7 +12,9 @@ phases: commands: - curl https://www.amazontrust.com/repository/AmazonRootCA1.pem --output /tmp/AmazonRootCA1.pem - cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$cert" > /tmp/certificate.pem + - echo /tmp/certificate.pem - key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$key" > /tmp/privatekey.pem + - echo /tmp/certificate.pem - ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') build: commands: @@ -22,7 +24,7 @@ phases: # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==1.4.8 - - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem post_build: commands: From 244e2df48ae572c7bfd687c5e91998e2b66aee32 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 16:07:29 -0700 Subject: [PATCH 15/21] clean up and revert test changes --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- continuous-delivery/test_prod_pypi.yml | 2 +- continuous-delivery/test_test_pypi.yml | 5 ++--- continuous-delivery/test_version_exists | 10 +++++----- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index ac329c9..1ad354e 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.7" +__version__ = "1.4.9" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 32317d4..49a69c9 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -14,7 +14,7 @@ phases: - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - #- sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py + - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml index fa49265..6c1a817 100644 --- a/continuous-delivery/test_prod_pypi.yml +++ b/continuous-delivery/test_prod_pypi.yml @@ -20,7 +20,7 @@ phases: - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION - - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem -n aws-sdk-crt-unit-test + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem post_build: commands: diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index c358c75..deec2a4 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -12,9 +12,7 @@ phases: commands: - curl https://www.amazontrust.com/repository/AmazonRootCA1.pem --output /tmp/AmazonRootCA1.pem - cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$cert" > /tmp/certificate.pem - - echo /tmp/certificate.pem - key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo "$key" > /tmp/privatekey.pem - - echo /tmp/certificate.pem - ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') build: commands: @@ -23,7 +21,8 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==1.4.8 + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION + # The greengrass test failed for no discover the correct thing. However it is good enough to test if the AWSIoTPythonSDK installed successfully or not. - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem post_build: diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists index 6d9bcb8..eaed9c7 100644 --- a/continuous-delivery/test_version_exists +++ b/continuous-delivery/test_version_exists @@ -7,11 +7,11 @@ git describe --tags CURRENT_TAG=$(git describe --tags | cut -f2 -dv) # convert v0.2.12-2-g50254a9 to 0.2.12 CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) -# if there's a hash on the tag, then this is not a release tagged commit -# if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then -# echo "Current tag version is not a release tag, cut a new release if you want to publish." -# exit 1 -# fi +if there's a hash on the tag, then this is not a release tagged commit +if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then + echo "Current tag version is not a release tag, cut a new release if you want to publish." + exit 1 +fi if python3 -m pip install --no-cache-dir -vvv AWSIoTPythonSDK==$CURRENT_TAG_VERSION; then echo "$CURRENT_TAG_VERSION is already in pypi, cut a new tag if you want to upload another version." From e8fca898fc7dbeb5646ea6a75af51e661b0dda81 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 12 Apr 2022 17:01:53 -0700 Subject: [PATCH 16/21] add print_only mode for deployment test --- continuous-delivery/test_prod_pypi.yml | 2 +- continuous-delivery/test_test_pypi.yml | 3 +-- samples/greengrass/basicDiscovery.py | 8 +++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/continuous-delivery/test_prod_pypi.yml b/continuous-delivery/test_prod_pypi.yml index 6c1a817..4575306 100644 --- a/continuous-delivery/test_prod_pypi.yml +++ b/continuous-delivery/test_prod_pypi.yml @@ -20,7 +20,7 @@ phases: - cd aws-iot-device-sdk-python - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION - - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only post_build: commands: diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index deec2a4..c3aa47d 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -22,8 +22,7 @@ phases: # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION - # The greengrass test failed for no discover the correct thing. However it is good enough to test if the AWSIoTPythonSDK installed successfully or not. - - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem + - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only post_build: commands: diff --git a/samples/greengrass/basicDiscovery.py b/samples/greengrass/basicDiscovery.py index cd73e43..a6fcd61 100644 --- a/samples/greengrass/basicDiscovery.py +++ b/samples/greengrass/basicDiscovery.py @@ -47,6 +47,8 @@ def customOnMessage(message): help="Operation modes: %s"%str(AllowedActions)) parser.add_argument("-M", "--message", action="store", dest="message", default="Hello World!", help="Message to publish") +#--print_discover_resp_only used for delopyment testing. The test run will return 0 as long as the SDK installed correctly. +parser.add_argument("-p", "--print_discover_resp_only", action="store_true", dest="print_only", default=False) args = parser.parse_args() host = args.host @@ -56,6 +58,7 @@ def customOnMessage(message): clientId = args.thingName thingName = args.thingName topic = args.topic +print_only = args.print_only if args.mode not in AllowedActions: parser.error("Unknown --mode option %s. Must be one of %s" % (args.mode, str(AllowedActions))) @@ -94,7 +97,7 @@ def customOnMessage(message): discoveryInfoProvider.configureCredentials(rootCAPath, certificatePath, privateKeyPath) discoveryInfoProvider.configureTimeout(10) # 10 sec -retryCount = MAX_DISCOVERY_RETRIES +retryCount = MAX_DISCOVERY_RETRIES if not print_only else 1 discovered = False groupCA = None coreInfo = None @@ -136,6 +139,9 @@ def customOnMessage(message): backOffCore.backOff() if not discovered: + # With print_discover_resp_only flag, we only woud like to check if the API get called correctly. + if print_only: + sys.exit(0) print("Discovery failed after %d retries. Exiting...\n" % (MAX_DISCOVERY_RETRIES)) sys.exit(-1) From 55526970e6a97fea0c690e303f2c551b2b885d8c Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Apr 2022 09:19:58 -0700 Subject: [PATCH 17/21] setup a fake version number for testing --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- continuous-delivery/test_version_exists | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 1ad354e..bde0031 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.9" +__version__ = "1.4.6" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 49a69c9..32317d4 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -14,7 +14,7 @@ phases: - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py + #- sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists index eaed9c7..6d9bcb8 100644 --- a/continuous-delivery/test_version_exists +++ b/continuous-delivery/test_version_exists @@ -7,11 +7,11 @@ git describe --tags CURRENT_TAG=$(git describe --tags | cut -f2 -dv) # convert v0.2.12-2-g50254a9 to 0.2.12 CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) -if there's a hash on the tag, then this is not a release tagged commit -if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then - echo "Current tag version is not a release tag, cut a new release if you want to publish." - exit 1 -fi +# if there's a hash on the tag, then this is not a release tagged commit +# if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then +# echo "Current tag version is not a release tag, cut a new release if you want to publish." +# exit 1 +# fi if python3 -m pip install --no-cache-dir -vvv AWSIoTPythonSDK==$CURRENT_TAG_VERSION; then echo "$CURRENT_TAG_VERSION is already in pypi, cut a new tag if you want to upload another version." From 2f237bd555ee281730e875d448a711f9437d8e7a Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Apr 2022 09:41:22 -0700 Subject: [PATCH 18/21] setup a fake version number for testing --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/test_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index bde0031..56dadec 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.6" +__version__ = "1.4.5" diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index c3aa47d..42310e4 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -21,7 +21,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==1.4.5 - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only post_build: From 04432b1d20e43a9f4d0418290ca5e4dd8401c414 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Apr 2022 10:02:42 -0700 Subject: [PATCH 19/21] revert testing changes --- AWSIoTPythonSDK/__init__.py | 2 +- continuous-delivery/publish_to_test_pypi.yml | 2 +- continuous-delivery/test_test_pypi.yml | 2 +- continuous-delivery/test_version_exists | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AWSIoTPythonSDK/__init__.py b/AWSIoTPythonSDK/__init__.py index 56dadec..1ad354e 100755 --- a/AWSIoTPythonSDK/__init__.py +++ b/AWSIoTPythonSDK/__init__.py @@ -1 +1 @@ -__version__ = "1.4.5" +__version__ = "1.4.9" diff --git a/continuous-delivery/publish_to_test_pypi.yml b/continuous-delivery/publish_to_test_pypi.yml index 32317d4..49a69c9 100644 --- a/continuous-delivery/publish_to_test_pypi.yml +++ b/continuous-delivery/publish_to_test_pypi.yml @@ -14,7 +14,7 @@ phases: - cd aws-iot-device-sdk-python - export PKG_VERSION=$(git describe --tags | cut -f2 -dv) - echo "Updating package version to ${PKG_VERSION}" - #- sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py + - sed --in-place -E "s/__version__ = \".+\"/__version__ = \"${PKG_VERSION}\"/" AWSIoTPythonSDK/__init__.py build: commands: - echo Build started on `date` diff --git a/continuous-delivery/test_test_pypi.yml b/continuous-delivery/test_test_pypi.yml index 42310e4..c3aa47d 100644 --- a/continuous-delivery/test_test_pypi.yml +++ b/continuous-delivery/test_test_pypi.yml @@ -21,7 +21,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) # this is here because typing isn't in testpypi, so pull it from prod instead - python3 -m pip install typing - - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==1.4.5 + - python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION - python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only post_build: diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists index 6d9bcb8..eaed9c7 100644 --- a/continuous-delivery/test_version_exists +++ b/continuous-delivery/test_version_exists @@ -7,11 +7,11 @@ git describe --tags CURRENT_TAG=$(git describe --tags | cut -f2 -dv) # convert v0.2.12-2-g50254a9 to 0.2.12 CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) -# if there's a hash on the tag, then this is not a release tagged commit -# if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then -# echo "Current tag version is not a release tag, cut a new release if you want to publish." -# exit 1 -# fi +if there's a hash on the tag, then this is not a release tagged commit +if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then + echo "Current tag version is not a release tag, cut a new release if you want to publish." + exit 1 +fi if python3 -m pip install --no-cache-dir -vvv AWSIoTPythonSDK==$CURRENT_TAG_VERSION; then echo "$CURRENT_TAG_VERSION is already in pypi, cut a new tag if you want to upload another version." From ce1b26adaa38cb1b0cd6f85dbb7638bacc942607 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Apr 2022 10:05:26 -0700 Subject: [PATCH 20/21] revert test changes --- continuous-delivery/test_version_exists | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/continuous-delivery/test_version_exists b/continuous-delivery/test_version_exists index eaed9c7..3579dbc 100644 --- a/continuous-delivery/test_version_exists +++ b/continuous-delivery/test_version_exists @@ -7,7 +7,7 @@ git describe --tags CURRENT_TAG=$(git describe --tags | cut -f2 -dv) # convert v0.2.12-2-g50254a9 to 0.2.12 CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) -if there's a hash on the tag, then this is not a release tagged commit +# if there's a hash on the tag, then this is not a release tagged commit if [ "$CURRENT_TAG" != "$CURRENT_TAG_VERSION" ]; then echo "Current tag version is not a release tag, cut a new release if you want to publish." exit 1 From 6a7da4ea321a3b7007e34cf926cad8b0185d25c6 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Apr 2022 10:09:05 -0700 Subject: [PATCH 21/21] add comments to explain about test pypi package name --- setup_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup_test.py b/setup_test.py index f9d2a64..820d715 100644 --- a/setup_test.py +++ b/setup_test.py @@ -1,3 +1,7 @@ +# For test deployment with package AWSIoTPythonSDK. The package name has already taken. Therefore we used an +# alternative name for test pypi. +# prod_pypi : AWSIoTPythonSDK +# test_pypi : AWSIoTPythonSDK-V1 import sys sys.path.insert(0, 'AWSIoTPythonSDK') import AWSIoTPythonSDK