Skip to content

Commit

Permalink
github/workflows: Add workflow to run package tests.
Browse files Browse the repository at this point in the history
All of the runable package tests are run together in the new `ci.sh`
function.  This is added to a new GitHub workflow to test the packages as
part of CI.

Eventually it would be good to unify all the package tests to use
`unittest`.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Jun 14, 2024
1 parent 2b3bd5b commit 333ec9c
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/package_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
- name: Run tests
run: source tools/ci.sh && ci_package_tests_run
73 changes: 73 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,79 @@ 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 {
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

# install unittest
mkdir -p ~/.micropython/lib
cp python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
cp python-stdlib/shutil/shutil.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/pathlib \
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

Expand Down

0 comments on commit 333ec9c

Please sign in to comment.