Skip to content

Commit 048a266

Browse files
committed
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 <[email protected]>
1 parent 8834023 commit 048a266

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

.github/workflows/package_tests.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Package tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v4
11+
- name: Setup environment
12+
run: source tools/ci.sh && ci_package_tests_setup_micropython
13+
- name: Setup libraries
14+
run: source tools/ci.sh && ci_package_tests_setup_lib
15+
- name: Run tests
16+
run: source tools/ci.sh && ci_package_tests_run

tools/ci.sh

+83
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
CP=/bin/cp
4+
35
########################################################################################
46
# commit formatting
57

@@ -12,6 +14,87 @@ function ci_commit_formatting_run {
1214
tools/verifygitlog.py -v upstream/master..HEAD --no-merges
1315
}
1416

17+
########################################################################################
18+
# package tests
19+
20+
MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython
21+
22+
function ci_package_tests_setup_micropython {
23+
git clone https://github.com/micropython/micropython.git /tmp/micropython
24+
25+
# build mpy-cross and micropython (use -O0 to speed up the build)
26+
make -C /tmp/micropython/mpy-cross -j CFLAGS_EXTRA=-O0
27+
make -C /tmp/micropython/ports/unix submodules
28+
make -C /tmp/micropython/ports/unix -j CFLAGS_EXTRA=-O0
29+
}
30+
31+
function ci_package_tests_setup_lib {
32+
mkdir -p ~/.micropython/lib
33+
$CP micropython/ucontextlib/ucontextlib.py ~/.micropython/lib/
34+
$CP python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
35+
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
36+
$CP python-stdlib/tempfile/tempfile.py ~/.micropython/lib/
37+
$CP -r python-stdlib/unittest/unittest ~/.micropython/lib/
38+
$CP -r python-stdlib/unittest-discover/unittest ~/.micropython/lib/
39+
$CP unix-ffi/ffilib/ffilib.py ~/.micropython/lib/
40+
tree ~/.micropython
41+
}
42+
43+
function ci_package_tests_run {
44+
for test in \
45+
micropython/drivers/storage/sdcard/sdtest.py \
46+
micropython/xmltok/test_xmltok.py \
47+
python-ecosys/requests/test_requests.py \
48+
python-stdlib/argparse/test_argparse.py \
49+
python-stdlib/base64/test_base64.py \
50+
python-stdlib/binascii/test_binascii.py \
51+
python-stdlib/collections-defaultdict/test_defaultdict.py \
52+
python-stdlib/functools/test_partial.py \
53+
python-stdlib/functools/test_reduce.py \
54+
python-stdlib/heapq/test_heapq.py \
55+
python-stdlib/hmac/test_hmac.py \
56+
python-stdlib/itertools/test_itertools.py \
57+
python-stdlib/operator/test_operator.py \
58+
python-stdlib/os-path/test_path.py \
59+
python-stdlib/pickle/test_pickle.py \
60+
python-stdlib/string/test_translate.py \
61+
unix-ffi/gettext/test_gettext.py \
62+
unix-ffi/pwd/test_getpwnam.py \
63+
unix-ffi/re/test_re.py \
64+
unix-ffi/time/test_strftime.py \
65+
; do
66+
echo "Running test $test"
67+
(cd `dirname $test` && $MICROPYTHON `basename $test`)
68+
if [ $? -ne 0 ]; then
69+
false # make this function return an error code
70+
return
71+
fi
72+
done
73+
74+
for path in \
75+
micropython/ucontextlib \
76+
python-stdlib/contextlib \
77+
python-stdlib/datetime \
78+
python-stdlib/fnmatch \
79+
python-stdlib/hashlib \
80+
python-stdlib/pathlib \
81+
python-stdlib/quopri \
82+
python-stdlib/shutil \
83+
python-stdlib/tempfile \
84+
python-stdlib/time \
85+
python-stdlib/unittest-discover/tests \
86+
; do
87+
(cd $path && $MICROPYTHON -m unittest)
88+
if [ $? -ne 0 ]; then false; return; fi
89+
done
90+
91+
(cd micropython/usb/usb-device && $MICROPYTHON -m tests.test_core_buffer)
92+
if [ $? -ne 0 ]; then false; return; fi
93+
94+
(cd python-ecosys/cbor2 && $MICROPYTHON -m examples.cbor_test)
95+
if [ $? -ne 0 ]; then false; return; fi
96+
}
97+
1598
########################################################################################
1699
# build packages
17100

0 commit comments

Comments
 (0)