Skip to content

Commit

Permalink
Merge pull request #27 from PelionIoT/edge-update
Browse files Browse the repository at this point in the history
Edge release update & GitHub test jobs
  • Loading branch information
JanneKiiskila authored Feb 12, 2024
2 parents c16ab2a + e401f02 commit 0293806
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 13 deletions.
172 changes: 172 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: mbed-edge-examples-make-and-test

on:
workflow_dispatch:
push:
paths-ignore:
- '**/README.md'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
make-examples-and-test:
runs-on: client
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
API_KEY: ${{ secrets.EDGE_EXAMPLES_API_KEY }}
DEV_CERT: ${{ secrets.EDGE_EXAMPLES_DEV_CERT}}
SYSTEM_TESTS: pelion-system-tests
EDGE_LOG: edge-core.log
PT_LOG: pt-example.log
SCRIPTS_INTERNAL: scripts-internal
RESULT_LOG_FILE: result_pytest.log
RESULT_HTML: result.html
RESULT_XML: result.xml
steps:
- name: Checkout continuous-integration
uses: actions/checkout@v4
# Self hosted has dependencies in place already
# - name: Install dependencies
# run: |
# sudo apt install build-essential git libc6-dev cmake
# sudo apt install libmosquitto-dev mosquitto-clients
# sudo apt install libglib2.0-dev
# sudo apt install doxygen
- name: git submodule update
run: git submodule update --init --recursive
# This builds release, debug and sanitize versions.
- run: make all
- name: Build edge-core
run: |
echo "$DEV_CERT" > lib/mbed-edge/config/mbed_cloud_dev_credentials.c
cd lib/mbed-edge
if [[ ! -d "build" ]]; then
rm -rf build
fi
mkdir -p build
cd build
cmake -DDEVELOPER_MODE=ON -DFIRMWARE_UPDATE=OFF ..
make -j$(nproc)
- name: Start edge-core
run: |
cd lib/mbed-edge/build
bin/edge-core >../../../${{ env.EDGE_LOG }} &
# Wait a bit for it to connect..
sleep 5
- name: Check out ${{ env.SYSTEM_TESTS }} repository
uses: actions/checkout@v4
with:
repository: PelionIoT/${{ env.SYSTEM_TESTS }}
token: ${{ secrets.ACCESS_TOKEN }}
path: ${{ env.SYSTEM_TESTS }}
- name: Check out $${{ env.SCRIPTS_INTERNAL }} repository
uses: actions/checkout@v4
with:
repository: PelionIoT/${{ env.SCRIPTS_INTERNAL }}
token: ${{ secrets.ACCESS_TOKEN }}
path: ${{ env.SCRIPTS_INTERNAL }}
- name: Create pytest config
run: |
CONFIG_FILE=${{ env.SYSTEM_TESTS }}/prod-edge-core-config.json
cp .github/workflows/prod-edge-core-config.json "$CONFIG_FILE"
jq '.api_key = "${{ env.API_KEY }}"' "$CONFIG_FILE" > tmp.json && mv tmp.json "$CONFIG_FILE"
- name: Start pt-example
run: |
cd build-debug
./bin/pt-example -n pt-example >../../${{ env.PT_LOG }} &
sleep 5
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Run pt-example-tests
run: |
cd ${{ env.SYSTEM_TESTS }}
# Check if venv folder exists, if not create it
if [[ ! -d "venv" ]]; then
python3 -m venv venv
fi
source venv/bin/activate
pip install --upgrade pip
pip install -U -r requirements.txt
pip install packages/*.whl
pip install -e systemtest-library
pytest -v --config_path=prod-edge-core-config.json --html=../${{ env.RESULT_HTML }} \
--self-contained-html -log_cli=true --log-cli-level=DEBUG \
--log-file=../${{ env.RESULT_LOG_FILE }} --log-file-level=DEBUG \
--junitxml=../${{ env.RESULT_XML }} test_cases/edge/test_pt_example.py
deactivate
- name: Cleanup - delete device from Izuma DM
if: always()
run: |
devid=$(curl --no-progress-meter localhost:8080/status | jq -r '."endpoint-name"')
if [[ -n "$devid" ]]; then
echo "Delete $devid via Izuma V3 REST API"
scripts-internal/cloud/delete-device.sh $devid ${{ secrets.EDGE_EXAMPLES_API_KEY }}
fi
- name: Cleanup - remove mcc_config -folder.
if: always()
run: |
# Delete the old identity/MCC contents to change identity in the next run
ls -al
rm -rf lib/mbed-edge/build/mcc_config
rm -rf mbed-edge-examples/lib/mbed-edge/build/mcc_config
rm -rf lib/mbed-edge/config/mbed_cloud_dev_credentials.c
rm -rf pelion-system-tests/prod-edge-core-config.json
- name: Cleanup - kill edge-core process
if: always()
run: |
edgepid=$(ps -aux |grep bin/edge-core | awk '{print $2}' | head -n1)
if [[ -n "$edgepid" ]]; then
# Kill edge-core if pid is not empty
echo "Kill edge-core with pid: $edgepid"
kill $edgepid
fi
- name: Cleanup - kill pt-example
if: always()
run: |
ptpid=$(ps -aux |grep pt-example | awk '{print $2}' | head -n1)
if [[ -n "$ptpid" ]]; then
# Kill pt-example if pid is not empty
echo "Kill pt-example with pid: $ptpid"
kill $ptpid
fi
- name: Archive clitest logs and results
uses: actions/upload-artifact@v3
if: always()
with:
name: mbed-edge-examples-logs
path: '**/*.log'
if-no-files-found: error

- name: Publish pytest result
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
junit_files: ${{ env.RESULT_XML }}
report_individual_runs: true
action_fail: true
action_fail_on_inconclusive: true
check_name: mbed-edge-examples-result

docker-build:
runs-on: client
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
steps:
- name: Checkout continuous-integration
uses: actions/checkout@v4
- name: git submodule update
run: git submodule update --init --recursive
- name: Docker build pt-example
run: docker build -t pt-example:latest -f ./Dockerfile.pt-example .
# Don't run it - it will run forever essentially.
- name: Docker build pt-example
run: docker build -t simple-example:latest -f ./Dockerfile.simple-pt-example .
# Don't run it - it will run forever essentially.
- name: Docker system prune
if: always()
run: docker system prune -f
25 changes: 19 additions & 6 deletions .github/workflows/misspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ concurrency:

jobs:
static-checks:
runs-on: ubuntu-latest
runs-on: client
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Run misspell (findings may not increase)
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Install & run misspell
if: always()
run: |
curl -L -o ./install-misspell.sh https://git.io/misspell
sh ./install-misspell.sh
bin/misspell -i mosquitto .
# The original misspell is not maintained anymore, use the one
# from golangci instead
go install github.com/golangci/misspell/cmd/misspell@latest
# As we run it locally - the repo is already there, including
# the lib folder which has a lot of misspellings.
# We need to specify the folders/files to check.
misspell -error -i mosquitto .github blept-example byte-order \
c-api-stress-tester cmake config device-interface examples-common \
examples-common-2 include mqttpt-example pt-example \
simple-js-examples/*.js simple-js-examples/*.md \
CHANGELOG.md CMakeLists.txt CONTRIBUTING.md Do* Makefile README.md
24 changes: 24 additions & 0 deletions .github/workflows/prod-edge-core-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"api_gw" : "https://api.us-east-1.mbedcloud.com",
"api_key" : "",
"account_id" : "0158778f9f1002420a014c1100000000",
"edge_k8s_url" : "https://edge-k8s.us-east-1.mbedcloud.com",
"edge_build_type" : "edge-core",
"internal_id" : "",
"pcr_repo_path" : "containers.us-east-1.mbedcloud.com",
"connection_type" : "local",
"pt_example_skip_autostart" : false,
"pt_example_options" : "-n pt-example-edge-ci",
"edge_local_host_port" : "8080",
"callback_handler" : "https://callback-prod.kiiskila.cc",
"has_remote_terminal" : true,
"rest_user_agent" : "edge-examples-ci",
"endpoint_count" : "3",
"edge_skip_release" : true,
"test_edge_billing" : true,
"dockerhub_auth" : {
"username" : "pelionservices",
"email" : "[email protected]",
"password" : ""
}
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for Edge examples

## Release 0.21.1

* Update `mbed-edge` submodule to 0.21.1.
* `Dockerfile.pt-example` takes into account now the case where build or build-debug exists in work area.
* `Dockerfile.simpe-pt-example` base image upgraded to `node:alpine3.18.`

## Release 0.21.0

* Update mbed-edge submodule to 0.21.0.
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.pt-example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt-get update && \

COPY . .

RUN rm -rf build build-debug
RUN make build-pt-example-debug

CMD [ "./build-debug/bin/pt-example", "-n", "docker-pt-example" ]
2 changes: 1 addition & 1 deletion Dockerfile.simple-pt-example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12.22.1-alpine3.12
FROM node:alpine3.18

WORKDIR /usr/src/app/simple-js-examples

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Pt-example is a basic example of the C-API and pt-client usage.
without real MQTT hardware using provided Mosquitto MQTT simulator scripts. The endpoints may
publish for example temperature and humidity values to Device Management.

NOTE! This requires Eclipse's Mosquitto - see installation info: https://mosquitto.org/download/

## blept-example

The `blept-example` is a protocol translator reference implementation for use with Bluetooth Low Energy (BLE) devices that implement a Bluetooth Low Energy Generic Attributes (GATT) server. It connects to BLE devices and translates their GATT services and characteristics into Open Mobile Alliance (OMA) Lightweight Machine to Machine (LwM2M) Objects and Resources.
Expand Down Expand Up @@ -46,10 +48,13 @@ This example tests the robustness and thread safeness of Protocol API C-API inte
Install these (using `sudo` typically):

```
apt install build-essential git libc6-dev
apt install libmosquitto-dev mosquitto-clients
apt install libglib2.0-dev
sudo apt-get update
sudo apt-get install build-essential cmake git libc6-dev \
libmosquitto-dev mosquitto-clients libglib2.0-dev \
doxygen
```
NOTE! Mosquitto might not be available directly in your distribution (for example Ubuntu 22.04),
see https://mosquitto.org/download/ for more installation information.
1. Preparing all the sources
Expand Down
4 changes: 4 additions & 0 deletions mqttpt-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The example translates MQTT endpoints connected to Device Management via Edge Co
The mqttpt-example has a dependency to `jansson`-library. In the example build the
`jansson`-library built by the `mbed-edge`-submodule is used.

This example also requires Eclipse's mosquitto.
Mosquitto might not be available directly in your distribution (for example Ubuntu 22.04),
see https://mosquitto.org/download/ for more installation information.

### Compilation

Read the README.md in the root for the basic build instructions.
Expand Down
7 changes: 5 additions & 2 deletions mqttpt-example/mqttgw_sim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ This is an MQTT gateway simulator to test the `mqttpt-example` protocol translat

### Requirements
Requires `mosquitto_pub` client for publishing the MQTT messages to MQTT broker.
```bash
sudo apt install -y mosquitto-clients
```
sudo apt install mosquitto-clients`
```

NOTE! Mosquitto might not be available directly in your distribution (for example Ubuntu 22.04),
see https://mosquitto.org/download/ for more installation information.

### Usage
1. Run `edge-core` and `mqttpt-example`
Expand Down
2 changes: 1 addition & 1 deletion simple-js-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Fixed values for the example:
from [Device Management Portal](https://portal.mbedcloud.com)
1. Run this example and connect to Edge.
```bash
nodejs simple-pt-example.js
node simple-pt-example.js
```
Or, using docker
```
Expand Down

0 comments on commit 0293806

Please sign in to comment.