Skip to content

Commit 2447a80

Browse files
committed
tools/ci.sh: Allow CI tests to run locally.
When working on code in this repo, it can be beneficial to run the same tests that run as part of the CI workflow on GitHub. This change makes it possible to run `tools/ci.sh` without it messing with your user-wide micropython install (`~/.micropython/lib`). It now defaults to creating a virtual environment in `/tmp/micropython-venv`. Expected usage of this is: ```bash # Setup tests (run once) $ source tools/ci.sh $ ci_package_tests_setup_micropython # Run tests (run many times) $ ci_package_tests_setup_lib && ci_package_tests_run || echo 'Failed' ``` Signed-off-by: Greg Darke <micropython@me.tsukasa.au>
1 parent a1a9e57 commit 2447a80

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

tools/ci.sh

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ function ci_commit_formatting_run {
1717
########################################################################################
1818
# package tests
1919

20-
MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython
20+
VIRTUAL_ENV="${VIRTUAL_ENV:-/tmp/micropython-venv}"
21+
MICROPYTHON="${MICROPYTHON:-${VIRTUAL_ENV}/bin/micropython}"
22+
MICROPYPATH="${VIRTUAL_ENV}/lib:.frozen"
2123

2224
function ci_package_tests_setup_micropython {
2325
git clone https://github.com/micropython/micropython.git /tmp/micropython
@@ -26,26 +28,32 @@ function ci_package_tests_setup_micropython {
2628
make -C /tmp/micropython/mpy-cross -j CFLAGS_EXTRA=-O0
2729
make -C /tmp/micropython/ports/unix submodules
2830
make -C /tmp/micropython/ports/unix -j CFLAGS_EXTRA=-O0
31+
32+
# Create the virtual environment directory
33+
mkdir -p "${VIRTUAL_ENV}/bin" "${VIRTUAL_ENV}/lib"
34+
ln -s /tmp/micropython/ports/unix/build-standard/micropython "${MICROPYTHON}"
2935
}
3036

3137
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 -r python-stdlib/hashlib-core/hashlib ~/.micropython/lib/
36-
$CP -r python-stdlib/hashlib-sha224/hashlib ~/.micropython/lib/
37-
$CP -r python-stdlib/hashlib-sha256/hashlib ~/.micropython/lib/
38-
$CP -r python-stdlib/hashlib-sha384/hashlib ~/.micropython/lib/
39-
$CP -r python-stdlib/hashlib-sha512/hashlib ~/.micropython/lib/
40-
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
41-
$CP python-stdlib/tempfile/tempfile.py ~/.micropython/lib/
42-
$CP -r python-stdlib/unittest/unittest ~/.micropython/lib/
43-
$CP -r python-stdlib/unittest-discover/unittest ~/.micropython/lib/
44-
$CP unix-ffi/ffilib/ffilib.py ~/.micropython/lib/
45-
tree ~/.micropython
38+
export MICROPYPATH
39+
mkdir -p ${VIRTUAL_ENV}/lib
40+
$CP micropython/ucontextlib/ucontextlib.py ${VIRTUAL_ENV}/lib/
41+
$CP python-stdlib/fnmatch/fnmatch.py ${VIRTUAL_ENV}/lib/
42+
$CP -r python-stdlib/hashlib-core/hashlib ${VIRTUAL_ENV}/lib/
43+
$CP -r python-stdlib/hashlib-sha224/hashlib ${VIRTUAL_ENV}/lib/
44+
$CP -r python-stdlib/hashlib-sha256/hashlib ${VIRTUAL_ENV}/lib/
45+
$CP -r python-stdlib/hashlib-sha384/hashlib ${VIRTUAL_ENV}/lib/
46+
$CP -r python-stdlib/hashlib-sha512/hashlib ${VIRTUAL_ENV}/lib/
47+
$CP python-stdlib/shutil/shutil.py ${VIRTUAL_ENV}/lib/
48+
$CP python-stdlib/tempfile/tempfile.py ${VIRTUAL_ENV}/lib/
49+
$CP -r python-stdlib/unittest/unittest ${VIRTUAL_ENV}/lib/
50+
$CP -r python-stdlib/unittest-discover/unittest ${VIRTUAL_ENV}/lib/
51+
$CP unix-ffi/ffilib/ffilib.py ${VIRTUAL_ENV}/lib/
52+
tree ${VIRTUAL_ENV}
4653
}
4754

4855
function ci_package_tests_run {
56+
export MICROPYPATH
4957
for test in \
5058
micropython/drivers/storage/sdcard/sdtest.py \
5159
micropython/xmltok/test_xmltok.py \

0 commit comments

Comments
 (0)