Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery mqtt5 sample #492

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 14 additions & 169 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,165 +34,6 @@ env:

jobs:

al2:
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-al2-x64 build -p ${{ env.PACKAGE_NAME }}

raspberry:
runs-on: ubuntu-latest # latest
permissions:
id-token: write # This is required for requesting the JWT
strategy:
fail-fast: false
matrix:
image:
- raspbian-bullseye
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
# set arm arch
- name: Install qemu/docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}

windows:
runs-on: windows-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Build ${{ env.PACKAGE_NAME }}
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }}
- name: Running samples in CI setup
run: |
python -m pip install boto3
- name: configure AWS credentials (PubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_PUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run PubSub sample
run: |
python ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_cfg.json
# The electron app in CI would not perform any IoT operations. The CI only verify the app is launched correctly.
# This is because electron requires manually input for pwd while processing the credentials. Currently we don't have a good way to workaround it.
- name: run PubSub Electron sample
run: |
python ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_electron_cfg.json
- name: run Windows Certificate Connect sample
run: |
python ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_windows_cert_connect_cfg.json
- name: configure AWS credentials (Device Advisor)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_DEVICE_ADVISOR }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run DeviceAdvisor
run: |
cd ./aws-iot-device-sdk-js-v2
python ./deviceadvisor/script/DATestRun.py

osx:
runs-on: macos-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Build ${{ env.PACKAGE_NAME }}
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }}
- name: Running samples in CI setup
run: |
python3 -m pip install boto3
- name: configure AWS credentials (PubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_PUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run PubSub sample
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_cfg.json

# The electron app in CI would not perform any IoT operations. The CI only verify the app is launched correctly.
# This is because electron requires manually input for pwd while processing the credentials. Currently we don't have a good way to workaround it.
- name: run PubSub Electron sample
run: |
python ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_electron_cfg.json
- name: run PKCS12 sample
run: |
cert=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem
key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem
pkcs12_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key_pkcs12_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\")
openssl pkcs12 -export -in /tmp/certificate.pem -inkey /tmp/privatekey.pem -out /tmp/pkcs12-key.p12 -name PubSub_Thing_Alias -password pass:$pkcs12_password
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pkcs12_connect_cfg.json
- name: configure AWS credentials (Device Advisor)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_DEVICE_ADVISOR }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run DeviceAdvisor
run: |
cd ./aws-iot-device-sdk-js-v2
python3 ./deviceadvisor/script/DATestRun.py

linux:
runs-on: ubuntu-20.04 # latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Build ${{ env.PACKAGE_NAME }}
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }}
- name: Running samples in CI setup
run: |
python3 -m pip install boto3
- name: configure AWS credentials (PubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_PUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run PubSub sample
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_cfg.json

# Electron requires X11 on linux, while github actions does not have X11 support. We work around it using XVFB.
- name: run PubSub Electron sample
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
python ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_pubsub_electron_cfg.json
- name: configure AWS credentials (Device Advisor)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_DEVICE_ADVISOR }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run DeviceAdvisor
run: |
cd ./aws-iot-device-sdk-js-v2
python3 ./deviceadvisor/script/DATestRun.py

# Runs the samples and ensures that everything is working
linux-smoke-tests:
runs-on: ubuntu-latest
Expand All @@ -210,6 +51,17 @@ jobs:
sudo apt-get update -y
sudo apt-get install softhsm -y
softhsm2-util --version
- name: configure AWS credentials (Greengrass) # TODO Remove
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_GREENGRASS_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run Greengrass Discovery sample # TODO Remove
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_greengrass_discovery_cfg.json
- name: run Greengrass Discovery MQTT5 sample # TODO Remove
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_greengrass_discovery_mqtt5_cfg.json
- name: configure AWS credentials (Shadow)
uses: aws-actions/configure-aws-credentials@v2
with:
Expand Down Expand Up @@ -381,16 +233,9 @@ jobs:
- name: run Greengrass Discovery sample
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_greengrass_discovery_cfg.json

# check that docs can still build
check-docs:
runs-on: ubuntu-20.04 # latest
steps:
- uses: actions/checkout@v2
- name: Check docs
run: |
npm ci
./make-docs.sh
- name: run Greengrass Discovery MQTT5 sample
run: |
python3 ./aws-iot-device-sdk-js-v2/utils/run_in_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_greengrass_discovery_mqtt5_cfg.json

check-codegen-edits:
runs-on: ubuntu-20.04 # latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_run_greengrass_discovery_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"data": "true"
},
{
"name": "--print_discover_resp_only",
"data": ""
"name": "--verbose",
"data": "info"
}
]
}
40 changes: 40 additions & 0 deletions .github/workflows/ci_run_greengrass_discovery_mqtt5_cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"language": "Javascript",
"runnable_file": "./aws-iot-device-sdk-js-v2/samples/node/basic_discovery_mqtt5",
"runnable_region": "us-east-1",
"runnable_main_class": "",

"arguments": [
{
"name": "--cert",
"secret": "ci/Greengrass/cert",
"filename": "tmp_certificate.pem"
},
{
"name": "--key",
"secret": "ci/Greengrass/key",
"filename": "tmp_key.pem"
},
{
"name": "--ca_file",
"secret": "ci/Greengrass/ca",
"filename": "tmp_ca.pem"
},
{
"name": "--region",
"data": "us-east-1"
},
{
"name": "--thing_name",
"data": "CI_GreenGrass_Thing"
},
{
"name": "--is_ci",
"data": "true"
},
{
"name": "--print_discover_resp_only",
"data": ""
}
]
}
2 changes: 2 additions & 0 deletions samples/node/basic_discovery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ async function main(argv: Args) {
// force node to wait 60 seconds before killing itself, promises do not keep node alive
const timer = setTimeout(() => { }, 60 * 1000);

console.log('Starting discovery');

await discovery.discover(argv.thing_name)
.then(async (discovery_response: greengrass.model.DiscoverResponse) => {
console.log("Discovery Response:");
Expand Down
9 changes: 9 additions & 0 deletions samples/node/basic_discovery_mqtt5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Node: Greengrass Discovery

[**Return to main sample list**](../../README.md)

This sample is intended for use with the following tutorials in the AWS IoT Greengrass documentation:

* [MQTT5 User Guide](https://github.com/awslabs/aws-crt-nodejs/blob/main/MQTT5-UserGuide.md)
* [Connect and test client devices](https://docs.aws.amazon.com/greengrass/v2/developerguide/client-devices-tutorial.html) (Greengrass V2)
* [Test client device communications](https://docs.aws.amazon.com/greengrass/v2/developerguide/test-client-device-communications.html) (Greengrass V2)
Loading
Loading