Skip to content

Commit

Permalink
misc: Update workflow and CI test.
Browse files Browse the repository at this point in the history
  • Loading branch information
iabdalkader committed Aug 25, 2023
1 parent 579c0d2 commit 719eb0e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/client-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ jobs:
DEVICE_ID: ${{ secrets.DEVICE_ID1 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python tests/ci.py
python tests/ci.py --basic-auth
- name: '☁️ Connect to IoT cloud (CPython / Key/Cert Auth)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python tests/ci.py --file-auth
- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth)'
env:
Expand All @@ -93,4 +101,4 @@ jobs:
run: |
export PATH="${HOME}/cache/bin:${PATH}"
micropython -c "import sys; print(sys.path)"
micropython tests/ci.py
micropython tests/ci.py --basic-auth
36 changes: 28 additions & 8 deletions tests/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def on_value_changed(client, value):
"-d", "--debug", action="store_true", help="Enable debugging messages"
)
parser.add_argument(
"-c", "--crypto-device", action="store_true", help="Use crypto device"
"-b", "--basic-auth", action="store_true", help="Username and password auth",
)
parser.add_argument(
"-c", "--crypto-device", action="store_true", help="Use soft-hsm/crypto device",
)
parser.add_argument(
"-f", "--file-auth", action="store_true", help="Use key/cert files"
)
args = parser.parse_args()

Expand All @@ -45,8 +51,25 @@ def on_value_changed(client, value):
# the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
# be used to authenticate, for example:
# client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
if args.crypto_device:
import arduino_iot_cloud.ussl as ssl
if args.basic_auth:
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
username=os.getenv("DEVICE_ID"),
password=os.getenv("SECRET_KEY"),
)
elif args.file_auth:
import ssl
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
ssl_params={
"keyfile": "key.pem",
"certfile": "cert.pem",
"ca_certs": "ca-root.pem",
"cert_reqs": ssl.CERT_REQUIRED,
},
)
elif args.crypto_device:
import ssl
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
ssl_params={
Expand All @@ -60,11 +83,8 @@ def on_value_changed(client, value):
},
)
else:
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
username=os.getenv("DEVICE_ID"),
password=os.getenv("SECRET_KEY"),
)
parser.print_help()
sys.exit(1)

# Register cloud objects.
# Note: The following objects must be created first in the dashboard and linked to the device.
Expand Down
3 changes: 1 addition & 2 deletions tests/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ ci_install_micropython() {

sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi

git clone --depth=1 https://github.com/micropython/micropython.git
git clone --branch v1.20.0 --depth=1 https://github.com/micropython/micropython.git

cat > micropython/ports/unix/manifest.py <<-EOF
include("\$(PORT_DIR)/variants/manifest.py")
include("\$(MPY_DIR)/extmod/asyncio")
require("bundle-networking")
require("time")
require("senml")
Expand Down

0 comments on commit 719eb0e

Please sign in to comment.