Skip to content

Commit 5d03449

Browse files
tsukasa-audpgeorge
authored andcommitted
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 b36aa84 commit 5d03449

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
@@ -18,7 +18,9 @@ function ci_commit_formatting_run {
1818
# package tests
1919

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

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

3238
function ci_package_tests_setup_lib {
33-
mkdir -p ~/.micropython/lib
34-
$CP micropython/ucontextlib/ucontextlib.py ~/.micropython/lib/
35-
$CP python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
36-
$CP -r python-stdlib/hashlib-core/hashlib ~/.micropython/lib/
37-
$CP -r python-stdlib/hashlib-sha224/hashlib ~/.micropython/lib/
38-
$CP -r python-stdlib/hashlib-sha256/hashlib ~/.micropython/lib/
39-
$CP -r python-stdlib/hashlib-sha384/hashlib ~/.micropython/lib/
40-
$CP -r python-stdlib/hashlib-sha512/hashlib ~/.micropython/lib/
41-
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
42-
$CP python-stdlib/tempfile/tempfile.py ~/.micropython/lib/
43-
$CP -r python-stdlib/unittest/unittest ~/.micropython/lib/
44-
$CP -r python-stdlib/unittest-discover/unittest ~/.micropython/lib/
45-
$CP unix-ffi/ffilib/ffilib.py ~/.micropython/lib/
46-
tree ~/.micropython
39+
export MICROPYPATH
40+
mkdir -p "${VIRTUAL_ENV}/lib"
41+
$CP micropython/ucontextlib/ucontextlib.py "${VIRTUAL_ENV}/lib/"
42+
$CP python-stdlib/fnmatch/fnmatch.py "${VIRTUAL_ENV}/lib/"
43+
$CP -r python-stdlib/hashlib-core/hashlib "${VIRTUAL_ENV}/lib/"
44+
$CP -r python-stdlib/hashlib-sha224/hashlib "${VIRTUAL_ENV}/lib/"
45+
$CP -r python-stdlib/hashlib-sha256/hashlib "${VIRTUAL_ENV}/lib/"
46+
$CP -r python-stdlib/hashlib-sha384/hashlib "${VIRTUAL_ENV}/lib/"
47+
$CP -r python-stdlib/hashlib-sha512/hashlib "${VIRTUAL_ENV}/lib/"
48+
$CP python-stdlib/shutil/shutil.py "${VIRTUAL_ENV}/lib/"
49+
$CP python-stdlib/tempfile/tempfile.py "${VIRTUAL_ENV}/lib/"
50+
$CP -r python-stdlib/unittest/unittest "${VIRTUAL_ENV}/lib/"
51+
$CP -r python-stdlib/unittest-discover/unittest "${VIRTUAL_ENV}/lib/"
52+
$CP unix-ffi/ffilib/ffilib.py "${VIRTUAL_ENV}/lib/"
53+
tree "${VIRTUAL_ENV}"
4754
}
4855

4956
function ci_package_tests_run {
57+
export MICROPYPATH
5058
for test in \
5159
micropython/drivers/storage/sdcard/sdtest.py \
5260
micropython/xmltok/test_xmltok.py \

0 commit comments

Comments
 (0)