Skip to content

Commit

Permalink
make-and-test - add pt-example tests to action
Browse files Browse the repository at this point in the history
  • Loading branch information
JanneKiiskila committed Jan 11, 2024
1 parent 4eb47d0 commit 3f19c5e
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 5 deletions.
101 changes: 96 additions & 5 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mbed-edge-examples-make
name: mbed-edge-examples-make-and-test

on:
workflow_dispatch:
Expand All @@ -12,27 +12,118 @@ concurrency:
cancel-in-progress: true

jobs:
make-examples:
make-examples-and-test:
runs-on: edge-example-ci
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
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
# 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
mkdir 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 &
# 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: |
cp .github/workflows/prod-edge-core-config.json ${{ env.SYSTEM_TESTS }}/edge-core-config.json
CONFIG_FILE=${{ env.SYSTEM_TESTS }}/edge-core-config.json
jq '.api_key = "${{ secrets[env.API_KEY_SECRET_NAME] }}"' "$CONFIG_FILE" > tmp.json && mv tmp.json "$CONFIG_FILE"
- name: Start pt-example
run: |
cd build-debug
./bin/pt-example -n pt-example &
sleep 5
- name: Run pt-example-tests
run: |
cd ${{ env.SYSTEM_TESTS }}
# Check if venv folder exists, if not create it
if [[ ! -d "venv" ]]; then
virtualenv -p python3 venv
fi
source venv/bin/activate
./install.sh
pytest -v --config_path=edge-core-config.json --html=$RESULT_HTML \
--self-contained-html -log_cli=true --log-cli-level=DEBUG \
--log-file=$RESULT_LOG_FILE --log-file-level=DEBUG \
--junitxml=$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 - 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 the logs and publish the results
if: always()
uses: ./.github/actions/archive-publish
with:
log_path: |
${{ env.SYSTEM_TESTS }}/*.log
${{ env.SYSTEM_TESTS }}/${{ env.RESULT_HTML }}
junit_files: ${{ env.SYSTEM_TESTS }}/${{ env.RESULT_XML }}

docker-build:
runs-on: edge-example-ci
runs-on: ubuntu22.04
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
steps:
Expand Down
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" : ""
}
}

0 comments on commit 3f19c5e

Please sign in to comment.