Skip to content

msic: Update CI tests. #96

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

Merged
merged 3 commits into from
Mar 4, 2025
Merged
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
16 changes: 11 additions & 5 deletions .github/workflows/client-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: '🧪 Test Cloud Client'

on:
push:
branches:
branches:
- 'main'
paths:
- '**.py'
Expand All @@ -16,14 +16,17 @@ on:
- edited
- reopened
- synchronize
branches:
branches:
- 'main'
paths:
- '**.py'
- '.github/workflows/*.yml'
- '.github/workflows/*.json'
- '!**/README.md'

schedule:
- cron: '0 12 * * *' # Runs every day at 12 PM UTC

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -89,14 +92,18 @@ jobs:
- name: '☁️ Connect to IoT cloud (CPython / Key-Cert Auth / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python tests/ci.py --file-auth

- name: '☁️ Connect to IoT cloud (CPython / Key-Cert Auth / CADATA / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
run: |
python tests/ci.py --file-auth --ca-data

- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
export SOFTHSM2_CONF="${HOME}/softhsm/tokens/softhsm2.conf"
python tests/ci.py --crypto-device
Expand All @@ -122,7 +129,6 @@ jobs:
- name: '☁️ Connect to IoT cloud (MicroPython / Key-Cert Auth / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
export PATH="${HOME}/cache/bin:${PATH}"
micropython -c "import sys; print(sys.path)"
Expand Down
12 changes: 9 additions & 3 deletions tests/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import asyncio
from arduino_iot_cloud import ArduinoCloudClient
from arduino_iot_cloud import Task
from arduino_iot_cloud import CADATA # noqa
import argparse


Expand All @@ -25,7 +26,7 @@ def on_value_changed(client, value):
def wdt_task(client, args, ts=[None]):
if ts[0] is None:
ts[0] = time.time()
if time.time() - ts[0] > 10:
if time.time() - ts[0] > 20:
loop = asyncio.get_event_loop()
loop.set_exception_handler(exception_handler)
logging.error("Timeout waiting for variable")
Expand All @@ -47,6 +48,9 @@ def wdt_task(client, args, ts=[None]):
parser.add_argument(
"-f", "--file-auth", action="store_true", help="Use key/cert files"
)
parser.add_argument(
"-ca", "--ca-data", action="store_true", help="Use embedded CADATA"
)
parser.add_argument(
"-s", "--sync", action="store_true", help="Run in synchronous mode"
)
Expand Down Expand Up @@ -76,12 +80,14 @@ def wdt_task(client, args, ts=[None]):
elif args.file_auth:
import ssl
fmt = "der" if sys.implementation.name == "micropython" else "pem"
ca_key = "cadata" if args.ca_data else "cafile"
ca_val = CADATA if args.ca_data else f"ca-root.{fmt}"
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
ssl_params={
"keyfile": f"key.{fmt}",
"certfile": f"cert.{fmt}",
"ca_certs": f"ca-root.{fmt}",
ca_key: ca_val,
"cert_reqs": ssl.CERT_REQUIRED,
},
sync_mode=args.sync,
Expand All @@ -95,7 +101,7 @@ def wdt_task(client, args, ts=[None]):
"use_hsm": True,
"keyfile": "pkcs11:token=arduino",
"certfile": "pkcs11:token=arduino",
"ca_certs": "ca-root.pem",
"cafile": "ca-root.pem",
"cert_reqs": ssl.CERT_REQUIRED,
"engine_path": "/lib/x86_64-linux-gnu/engines-3/libpkcs11.so",
"module_path": "/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so",
Expand Down