github/workflows: Add workflow to run package tests.

All of the runable package tests are run together in the new `tools/ci.sh`
function called `ci_package_tests_run`.  This is added to a new GitHub
workflow to test the packages as part of CI.

Some packages use `unittest` while others use an ad-hoc test script.
Eventually it would be good to unify all the package tests to use
`unittest`.

Signed-off-by: Damien George <damien@micropython.org>
pull/883/head
Damien George 2024-06-14 11:40:29 +10:00
rodzic 8834023d05
commit 98f8a7e771
2 zmienionych plików z 104 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,16 @@
name: Package tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Setup environment
run: source tools/ci.sh && ci_package_tests_setup_micropython
- name: Setup libraries
run: source tools/ci.sh && ci_package_tests_setup_lib
- name: Run tests
run: source tools/ci.sh && ci_package_tests_run

Wyświetl plik

@ -1,5 +1,7 @@
#!/bin/bash
CP=/bin/cp
########################################################################################
# commit formatting
@ -12,6 +14,92 @@ function ci_commit_formatting_run {
tools/verifygitlog.py -v upstream/master..HEAD --no-merges
}
########################################################################################
# package tests
MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython
function ci_package_tests_setup_micropython {
git clone https://github.com/micropython/micropython.git /tmp/micropython
# build mpy-cross and micropython (use -O0 to speed up the build)
make -C /tmp/micropython/mpy-cross -j CFLAGS_EXTRA=-O0
make -C /tmp/micropython/ports/unix submodules
make -C /tmp/micropython/ports/unix -j CFLAGS_EXTRA=-O0
}
function ci_package_tests_setup_lib {
mkdir -p ~/.micropython/lib
$CP micropython/ucontextlib/ucontextlib.py ~/.micropython/lib/
$CP python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
$CP -r python-stdlib/hashlib-core/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha224/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha256/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha384/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha512/hashlib ~/.micropython/lib/
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
$CP python-stdlib/tempfile/tempfile.py ~/.micropython/lib/
$CP -r python-stdlib/unittest/unittest ~/.micropython/lib/
$CP -r python-stdlib/unittest-discover/unittest ~/.micropython/lib/
$CP unix-ffi/ffilib/ffilib.py ~/.micropython/lib/
tree ~/.micropython
}
function ci_package_tests_run {
for test in \
micropython/drivers/storage/sdcard/sdtest.py \
micropython/xmltok/test_xmltok.py \
python-ecosys/requests/test_requests.py \
python-stdlib/argparse/test_argparse.py \
python-stdlib/base64/test_base64.py \
python-stdlib/binascii/test_binascii.py \
python-stdlib/collections-defaultdict/test_defaultdict.py \
python-stdlib/functools/test_partial.py \
python-stdlib/functools/test_reduce.py \
python-stdlib/heapq/test_heapq.py \
python-stdlib/hmac/test_hmac.py \
python-stdlib/itertools/test_itertools.py \
python-stdlib/operator/test_operator.py \
python-stdlib/os-path/test_path.py \
python-stdlib/pickle/test_pickle.py \
python-stdlib/string/test_translate.py \
unix-ffi/gettext/test_gettext.py \
unix-ffi/pwd/test_getpwnam.py \
unix-ffi/re/test_re.py \
unix-ffi/time/test_strftime.py \
; do
echo "Running test $test"
(cd `dirname $test` && $MICROPYTHON `basename $test`)
if [ $? -ne 0 ]; then
false # make this function return an error code
return
fi
done
for path in \
micropython/ucontextlib \
python-stdlib/contextlib \
python-stdlib/datetime \
python-stdlib/fnmatch \
python-stdlib/hashlib \
python-stdlib/pathlib \
python-stdlib/quopri \
python-stdlib/shutil \
python-stdlib/tempfile \
python-stdlib/time \
python-stdlib/unittest-discover/tests \
; do
(cd $path && $MICROPYTHON -m unittest)
if [ $? -ne 0 ]; then false; return; fi
done
(cd micropython/usb/usb-device && $MICROPYTHON -m tests.test_core_buffer)
if [ $? -ne 0 ]; then false; return; fi
(cd python-ecosys/cbor2 && $MICROPYTHON -m examples.cbor_test)
if [ $? -ne 0 ]; then false; return; fi
}
########################################################################################
# build packages