Skip to content

Commit 7b315b6

Browse files
committed
misc: Update workflow and CI test.
1 parent 579c0d2 commit 7b315b6

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

.github/workflows/client-test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ jobs:
7676
DEVICE_ID: ${{ secrets.DEVICE_ID1 }}
7777
SECRET_KEY: ${{ secrets.SECRET_KEY }}
7878
run: |
79-
python tests/ci.py
79+
python tests/ci.py --basic-auth
80+
81+
- name: '☁️ Connect to IoT cloud (CPython / Key/Cert Auth)'
82+
env:
83+
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
84+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
85+
run: |
86+
python tests/ci.py --file-auth
87+
8088
8189
- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth)'
8290
env:
@@ -93,4 +101,4 @@ jobs:
93101
run: |
94102
export PATH="${HOME}/cache/bin:${PATH}"
95103
micropython -c "import sys; print(sys.path)"
96-
micropython tests/ci.py
104+
micropython tests/ci.py --basic-auth

tests/ci.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ def on_value_changed(client, value):
2727
"-d", "--debug", action="store_true", help="Enable debugging messages"
2828
)
2929
parser.add_argument(
30-
"-c", "--crypto-device", action="store_true", help="Use crypto device"
30+
"-b", "--basic-auth", action="store_true", help="Username and password auth",
31+
)
32+
parser.add_argument(
33+
"-c", "--crypto-device", action="store_true", help="Use soft-hsm/crypto device",
34+
)
35+
parser.add_argument(
36+
"-f", "--file-auth", action="store_true", help="Use key/cert files"
3137
)
3238
args = parser.parse_args()
3339

@@ -45,8 +51,25 @@ def on_value_changed(client, value):
4551
# the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
4652
# be used to authenticate, for example:
4753
# client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
48-
if args.crypto_device:
49-
import arduino_iot_cloud.ussl as ssl
54+
if args.basic_auth:
55+
client = ArduinoCloudClient(
56+
device_id=os.getenv("DEVICE_ID"),
57+
username=os.getenv("DEVICE_ID"),
58+
password=os.getenv("SECRET_KEY"),
59+
)
60+
elif args.file_auth:
61+
import ssl
62+
client = ArduinoCloudClient(
63+
device_id=os.getenv("DEVICE_ID"),
64+
ssl_params={
65+
"keyfile": "key.pem",
66+
"certfile": "cert.pem",
67+
"ca_certs": "ca-root.pem",
68+
"cert_reqs": ssl.CERT_REQUIRED,
69+
},
70+
)
71+
elif args.crypto_device:
72+
import ssl
5073
client = ArduinoCloudClient(
5174
device_id=os.getenv("DEVICE_ID"),
5275
ssl_params={
@@ -60,11 +83,8 @@ def on_value_changed(client, value):
6083
},
6184
)
6285
else:
63-
client = ArduinoCloudClient(
64-
device_id=os.getenv("DEVICE_ID"),
65-
username=os.getenv("DEVICE_ID"),
66-
password=os.getenv("SECRET_KEY"),
67-
)
86+
parser.print_help()
87+
sys.exit(1)
6888

6989
# Register cloud objects.
7090
# Note: The following objects must be created first in the dashboard and linked to the device.

tests/ci.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ ci_install_micropython() {
99
git clone --depth=1 https://github.com/micropython/micropython.git
1010

1111
cat > micropython/ports/unix/manifest.py <<-EOF
12-
include("\$(PORT_DIR)/variants/manifest.py")
13-
include("\$(MPY_DIR)/extmod/asyncio")
12+
include("\$(PORT_DIR)/variants/standard/manifest.py")
1413
require("bundle-networking")
1514
require("time")
1615
require("senml")
1716
require("logging")
1817
EOF
1918

20-
make -C micropython/mpy-cross/
21-
make -C micropython/ports/unix/ submodules
22-
make -C micropython/ports/unix/ FROZEN_MANIFEST=manifest.py CFLAGS_EXTRA="-DMICROPY_PY_SELECT=1"
19+
echo "#undef MICROPY_PY_SELECT_SELECT" >> micropython/ports/unix/variants/mpconfigvariant_common.h
20+
echo "#undef MICROPY_PY_SELECT_POSIX_OPTIMISATIONS" >> micropython/ports/unix/variants/mpconfigvariant_common.h
21+
22+
make -j12 -C micropython/mpy-cross/
23+
make -j12 -C micropython/ports/unix/ submodules
24+
make -j12 -C micropython/ports/unix/ FROZEN_MANIFEST=manifest.py CFLAGS_EXTRA="-DMICROPY_PY_SELECT=1"
2325
cp micropython/ports/unix/build-standard/micropython ${CACHE_DIR}
2426
}
2527

0 commit comments

Comments
 (0)