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

Run Greengrass samples in CI #717

Merged
merged 81 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
3f51681
Run example gg component
sfodagain May 14, 2024
45f7f1f
Check log file
sfodagain May 14, 2024
ea0cfc8
Remove java extra test
sfodagain May 14, 2024
04f4034
Working with precompiled binary
sfodagain May 14, 2024
8c3e59c
Use gg ipc sample
sfodagain May 15, 2024
83ab376
Setup gg ipc in sample dir
sfodagain May 16, 2024
4054f8b
Fix policy
sfodagain May 16, 2024
e320c16
Add CI job
sfodagain May 16, 2024
44eb61c
Fix gdk version
sfodagain May 16, 2024
7cb8f76
Another working dir
sfodagain May 16, 2024
40cdcff
Build sources
sfodagain May 16, 2024
4ba3b9a
Add new builder variant for GG only
sfodagain May 16, 2024
e71fcef
Debugging
sfodagain May 16, 2024
a6554ec
Temporary reconfig for builder
sfodagain May 16, 2024
5330622
Fix path
sfodagain May 16, 2024
8c068df
More levels
sfodagain May 16, 2024
b7424bb
fixup
sfodagain May 16, 2024
b0746fe
fixup
sfodagain May 16, 2024
15aa9db
Playing with CI
sfodagain May 16, 2024
3db2490
Do not setup Java
sfodagain May 16, 2024
8917feb
Remove test path
sfodagain May 16, 2024
445f503
Fix path
sfodagain May 16, 2024
9366f3a
Run predefined gg core
sfodagain May 21, 2024
6e192fd
fixup
sfodagain May 21, 2024
3dccd48
Check gg core
sfodagain May 21, 2024
bd6d6c1
Use predefined gg core one more time
sfodagain May 21, 2024
a2e530b
Try to remove gg core from recipe
sfodagain May 21, 2024
05c4d62
Add background
sfodagain May 21, 2024
ee02511
Echo gg core thing
sfodagain May 21, 2024
ea00deb
Roll back gg core creation
sfodagain May 21, 2024
ddebc7d
Increase timeout
sfodagain May 21, 2024
9dde71f
Print test logs
sfodagain May 21, 2024
9ad99af
Remove installing gg core
sfodagain May 21, 2024
687259f
Run test using run_in_ci
sfodagain May 21, 2024
da6094c
fixup
sfodagain May 21, 2024
0ecdc87
Add basic discovery to CI
sfodagain May 21, 2024
7747ff9
Enable gg discovery in CI
sfodagain May 21, 2024
39d5db7
Fix discovery CI
sfodagain May 21, 2024
d876163
fixup
sfodagain May 21, 2024
91a73bb
fixup
sfodagain May 21, 2024
1873232
Show associated devices
sfodagain May 21, 2024
b424777
Associate device with gg core
sfodagain May 21, 2024
fb8eb88
Use startup
sfodagain May 21, 2024
2522862
fixup
sfodagain May 21, 2024
0d96bb5
Add sleep
sfodagain May 22, 2024
4e9f540
fixup
sfodagain May 22, 2024
2380aa3
Try without print_discover_resp_only flag
sfodagain May 22, 2024
e706dae
Revert
sfodagain May 22, 2024
2d14cba
Try topic
sfodagain May 22, 2024
d85cb69
Add component for discovery
sfodagain May 22, 2024
a4e9c45
Run discovery within component
sfodagain May 24, 2024
f901fcc
format
sfodagain May 24, 2024
bb46c89
Missing include
sfodagain May 24, 2024
c52ee96
Add artifact
sfodagain May 24, 2024
c1a602b
Add config to artifacts
sfodagain May 24, 2024
2ab1aca
Fix log filename
sfodagain May 24, 2024
b83e05f
Install awsiotsdk
sfodagain May 24, 2024
01865d9
Add print message
sfodagain May 24, 2024
98b6f9e
Fix log message
sfodagain May 24, 2024
f0cea9e
Use more suitable thing
sfodagain May 24, 2024
ed1449c
fixup
sfodagain May 27, 2024
0d2516a
fixup
sfodagain May 27, 2024
336408c
fixup
sfodagain May 27, 2024
fa15466
Use the right thing
sfodagain May 28, 2024
73a379c
Enable all CI jobs
sfodagain May 28, 2024
1543e0a
Build only GG samples in GG CI job
sfodagain May 28, 2024
79650ea
Add comments
sfodagain May 28, 2024
4a10bff
Increase timeouts
sfodagain May 28, 2024
0c4f49d
Move CI config to github dir
sfodagain May 28, 2024
18bf7d7
Move test into a separate dir
sfodagain May 28, 2024
c46fc23
Move ipc test into a separate dir
sfodagain May 28, 2024
b929c2d
fixup
sfodagain May 28, 2024
a1fc3cf
fixup
sfodagain May 28, 2024
dc75a9b
Disable old sample run
sfodagain May 29, 2024
a89837c
Add readmes, review policies
sfodagain May 29, 2024
168271d
Restrict policy
sfodagain May 29, 2024
c12a37e
Merge branch 'main' into add-gg-ci-job
sfod May 29, 2024
62c4505
Get input from file
sfodagain Jun 3, 2024
bb58a2b
Merge branch 'main' into add-gg-ci-job
sfodagain Jun 3, 2024
bc27500
CLean CI config
sfodagain Jun 3, 2024
0506505
Sync run_in_in_ci.py
sfodagain Jun 5, 2024
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
37 changes: 37 additions & 0 deletions .builder/actions/build_gg_samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

import Builder
import os


class BuildGGSamples(Builder.Action):
"""
Defines a custom build step for Greengrass samples.
It's used via builder.json config file in the project root directory.
"""

def run(self, env):
# parse extra cmake configs
cmd_args = env.args

steps = []
samples = [
'samples/greengrass/ipc',
'samples/greengrass/basic_discovery',
]

for sample_path in samples:
build_path = os.path.join('build', sample_path)
steps.append(['cmake',
f'-B{build_path}',
f'-H{sample_path}',
f'-DCMAKE_PREFIX_PATH={env.install_dir}',
'-DCMAKE_BUILD_TYPE=RelWithDebInfo'])
# append extra cmake configs
steps[-1].extend(cmd_args.cmake_extra)
steps.append(['cmake',
'--build', build_path,
'--config', 'RelWithDebInfo'])

return Builder.Script(steps)
9 changes: 8 additions & 1 deletion .builder/actions/build_samples.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

import Builder
import os
import sys
import argparse


class BuildSamples(Builder.Action):
"""
Defines a custom build step for samples and tests.
It's used via builder.json config file in the project root directory.
"""

def run(self, env):
# parse extra cmake configs
cmd_args = env.args
Expand Down
72 changes: 65 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
CI_X509_ROLE: arn:aws:iam::180635532705:role/CI_X509_Role
CI_MQTT5_ROLE: arn:aws:iam::180635532705:role/CI_MQTT5_Role
CI_GREENGRASS_ROLE: arn:aws:iam::180635532705:role/CI_Greengrass_Role
CI_GREENGRASS_INSTALLER_ROLE: arn:aws:iam::180635532705:role/CI_GreengrassInstaller_Role
CI_JOBS_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_JobsServiceClient_Role
CI_SHADOW_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_ShadowServiceClient_Role

Expand Down Expand Up @@ -641,14 +642,71 @@ jobs:
- name: run X509 sample
run: |
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json
- name: configure AWS credentials (Greengrass)
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

# Runs the Greengrass samples
linux-greengrass-tests:
xiazhvera marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- 17
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Setup C++
run: |
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_greengrass_discovery_cfg.json
sudo apt-get -qq update -y
sudo apt-get -qq install -y build-essential
sudo apt install cmake
gcc --version
cmake --version
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
echo "Downloading source"
git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }}
echo "Running builder"
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 }} --variant build_gg_samples_only
- name: Install Greengrass Development Kit
run: |
python3 -m pip install awsiotsdk
python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2
- name: Configure AWS credentials (Greengrass)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build and run Greengrass basic discovery sample
working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/basic_discovery
run: |
gdk component build
gdk test-e2e build
gdk test-e2e run
- name: Show logs
working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/basic_discovery
# Print logs unconditionally to provide more details on Greengrass run even if the test failed.
if: always()
run: |
echo "=== greengrass.log"
cat testResults/gg*/greengrass.log
echo "=== software.amazon.awssdk.sdk-gg-test-discovery.log"
cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log
- name: Build and run Greengrass IPC sample
working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc
run: |
gdk component build
gdk test-e2e build
gdk test-e2e run
- name: Show logs
working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc
# Print logs unconditionally to provide more details on Greengrass run even if the test failed.
if: always()
run: |
echo "=== greengrass.log"
cat testResults/gg*/greengrass.log
echo "=== software.amazon.awssdk.sdk-gg-ipc.log"
cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log

# check that docs can still build
check-docs:
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/ci_run_greengrass_discovery_cfg.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
{
"language": "CPP",
"sample_file": "./aws-iot-device-sdk-cpp-v2/build/samples/greengrass/basic_discovery/basic-discovery",
"sample_region": "us-east-1",
"sample_main_class": "",
"runnable_file": "basic-discovery",
"runnable_region": "us-east-1",
"runnable_main_class": "",
"arguments": [
{
"name": "--cert",
"secret": "ci/Greengrass/cert",
"secret": "ci/GreengrassDiscovery/cert",
"filename": "tmp_certificate.pem"
},
{
"name": "--key",
"secret": "ci/Greengrass/key",
"secret": "ci/GreengrassDiscovery/key",
"filename": "tmp_key.pem"
},
{
"name": "--ca_file",
"secret": "ci/Greengrass/ca",
"filename": "tmp_ca.pem"
"name": "--thing_name",
"data": "CI_Greengrass_Discovery_Thing"
},
{
"name": "--region",
"data": "us-east-1"
},
{
"name": "--thing_name",
"data": "CI_GreenGrass_Thing"
"name": "--message",
"data": "hello"
},
{
"name": "--is_ci",
"data": "true"
"name": "--topic",
"data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID"
},
{
"name": "--print_discover_resp_only",
"data": ""
"name": "--mode",
"data": "publish"
}
]
}
21 changes: 21 additions & 0 deletions .github/workflows/ci_run_greengrass_ipc_cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"language": "CPP",
"runnable_file": "greengrass-ipc",
"runnable_region": "us-east-1",
"runnable_main_class": "",
"arguments": [
{
"name": "--topic",
"data": "test/gg-ipc-topic"
},
{
"name": "--message",
"data": "hello"
},
{
"name": "--is_ci",
"data": "true"
}

]
}
6 changes: 6 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"!build_steps": [
"build"
]
},
"build_gg_samples_only": {
"!build_steps": [
"build",
"build-gg-samples"
]
}
}
}
Loading
Loading