Skip to content

Commit e7fe64b

Browse files
committed
github/workflows: Add workflow to run package tests.
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]>
1 parent 2b3bd5b commit e7fe64b

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

.github/workflows/package_tests.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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
13+
- name: Run tests
14+
run: source tools/ci.sh && ci_package_tests_run

tools/ci.sh

+70
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,76 @@ function ci_commit_formatting_run {
1212
tools/verifygitlog.py -v upstream/master..HEAD --no-merges
1313
}
1414

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

0 commit comments

Comments
 (0)