-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from arduino/workflow_micropython
misc: Add micropython test.
- Loading branch information
Showing
3 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,23 @@ jobs: | |
- name: '⏳ Checkout repository' | ||
uses: actions/checkout@v3 | ||
|
||
- name: '♻ Caching dependencies' | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ~/cache/bin/ | ||
key: 'micropython' | ||
|
||
- name: '🐍 Set up Python' | ||
uses: actions/setup-python@v4 | ||
with: | ||
cache: 'pip' | ||
python-version: "3.10" | ||
|
||
- name: '🐍 Set up MicroPython' | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: source tests/ci.sh && ci_install_micropython | ||
|
||
- name: '🛠 Install dependencies' | ||
run: | | ||
python -m pip install --upgrade pip | ||
|
@@ -49,7 +60,8 @@ jobs: | |
- name: '🛠 Install package' | ||
run: | | ||
python3 -m build | ||
pip install dist/arduino_iot_cloud-*.whl | ||
pip install --user dist/arduino_iot_cloud-*.whl | ||
pip install --target=${HOME}/.micropython/lib dist/arduino_iot_cloud-*.whl | ||
- name: '🔑 Configure soft crypto device' | ||
env: | ||
|
@@ -59,17 +71,26 @@ jobs: | |
run: | | ||
source tests/ci.sh && ci_configure_softhsm | ||
- name: '☁️ Connect to IoT cloud (basic auth)' | ||
- name: '☁️ Connect to IoT cloud (CPython / Basic Auth)' | ||
env: | ||
DEVICE_ID: ${{ secrets.DEVICE_ID1 }} | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
run: | | ||
python tests/ci.py | ||
- name: '☁️ Connect to IoT cloud (using crypto device)' | ||
- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth)' | ||
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 | ||
- name: '☁️ Connect to IoT cloud (MicroPython / Basic Auth)' | ||
env: | ||
DEVICE_ID: ${{ secrets.DEVICE_ID1 }} | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
run: | | ||
export PATH="${HOME}/cache/bin:${PATH}" | ||
micropython -c "import sys; print(sys.path)" | ||
micropython tests/ci.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,58 @@ | ||
#!/bin/bash | ||
|
||
ci_install_micropython() { | ||
CACHE_DIR=${HOME}/cache/bin | ||
mkdir -p ${CACHE_DIR} | ||
|
||
sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi | ||
|
||
git clone --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") | ||
require("logging") | ||
EOF | ||
|
||
make -C micropython/mpy-cross/ | ||
make -C micropython/ports/unix/ submodules | ||
make -C micropython/ports/unix/ FROZEN_MANIFEST=manifest.py CFLAGS_EXTRA="-DMICROPY_PY_SELECT=1" | ||
cp micropython/ports/unix/build-standard/micropython ${CACHE_DIR} | ||
} | ||
|
||
ci_configure_softhsm() { | ||
TOKEN_DIR=${HOME}/softhsm/tokens/ | ||
TOKEN_URI="pkcs11:token=arduino" | ||
PROVIDER=/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so | ||
TOKEN_DIR=${HOME}/softhsm/tokens/ | ||
TOKEN_URI="pkcs11:token=arduino" | ||
PROVIDER=/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so | ||
|
||
mkdir -p ${TOKEN_DIR} | ||
cat > ${TOKEN_DIR}/softhsm2.conf << EOF | ||
directories.tokendir = ${TOKEN_DIR} | ||
objectstore.backend = file | ||
mkdir -p ${TOKEN_DIR} | ||
cat > ${TOKEN_DIR}/softhsm2.conf <<-EOF | ||
directories.tokendir = ${TOKEN_DIR} | ||
objectstore.backend = file | ||
# ERROR, WARNING, INFO, DEBUG | ||
log.level = ERROR | ||
# ERROR, WARNING, INFO, DEBUG | ||
log.level = ERROR | ||
# If CKF_REMOVABLE_DEVICE flag should be set | ||
slots.removable = false | ||
# If CKF_REMOVABLE_DEVICE flag should be set | ||
slots.removable = false | ||
# Enable and disable PKCS#11 mechanisms using slots.mechanisms. | ||
slots.mechanisms = ALL | ||
# Enable and disable PKCS#11 mechanisms using slots.mechanisms. | ||
slots.mechanisms = ALL | ||
# If the library should reset the state on fork | ||
library.reset_on_fork = false | ||
EOF | ||
# If the library should reset the state on fork | ||
library.reset_on_fork = false | ||
EOF | ||
|
||
export SOFTHSM2_CONF=${TOKEN_DIR}/softhsm2.conf | ||
export SOFTHSM2_CONF=${TOKEN_DIR}/softhsm2.conf | ||
|
||
echo "$KEY_PEM" >> key.pem | ||
echo "$CERT_PEM" >> cert.pem | ||
echo "$CA_PEM" >> ca-root.pem | ||
echo "$KEY_PEM" >> key.pem | ||
echo "$CERT_PEM" >> cert.pem | ||
echo "$CA_PEM" >> ca-root.pem | ||
|
||
softhsm2-util --init-token --slot 0 --label "arduino" --pin 1234 --so-pin 1234 | ||
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-privkey key.pem --label "mykey" | ||
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-certificate cert.pem --label "mycert" | ||
softhsm2-util --init-token --slot 0 --label "arduino" --pin 1234 --so-pin 1234 | ||
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-privkey key.pem --label "mykey" | ||
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-certificate cert.pem --label "mycert" | ||
} |