Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ function ci_commit_formatting_run {
########################################################################################
# package tests

MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython
VIRTUAL_ENV="${VIRTUAL_ENV:-/tmp/micropython-venv}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding /tmp should probably be left as a last resort - POSIX specs say there should be an environment variable called TMPDIR pointing to the temporary directory.

See also https://en.wikipedia.org/wiki/TMPDIR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it would be better to put these somewhere other than /tmp, but the existing script uses /tmp a lot.

Would you prefer I switch just this (new) usage of /tmp to ${TMPDIR}, or should I switch the other usages of /tmp in this script as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be easier to read if there's one commit that replaces all existing instances of /tmp to ${TMPDIR:-/tmp} first, and then have the existing changes into a follow-up commit. Whether the commits should be split into two separate PRs or not is a bit of personal preference IMHO (technically the first commit could be a valid PR in its own right).

As far as I know GitHub doesn't allow declaring dependencies on PRs, so let's keep both commits in here to make sure nothing gets lost if this gets merged. Thanks!

MICROPYTHON="${MICROPYTHON:-${VIRTUAL_ENV}/bin/micropython}"
MICROPYPATH="${VIRTUAL_ENV}/lib:.frozen"

function ci_package_tests_setup_micropython {
git clone https://github.com/micropython/micropython.git /tmp/micropython
Expand All @@ -26,26 +28,32 @@ function ci_package_tests_setup_micropython {
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

# Create the virtual environment directory
mkdir -p "${VIRTUAL_ENV}/bin" "${VIRTUAL_ENV}/lib"
ln -s /tmp/micropython/ports/unix/build-standard/micropython "${MICROPYTHON}"
}

function ci_package_tests_setup_lib {
mkdir -p ~/.micropython/lib
$CP micropython/ucontextlib/ucontextlib.py ~/.micropython/lib/
$CP python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
$CP -r python-stdlib/hashlib-core/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha224/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha256/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha384/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha512/hashlib ~/.micropython/lib/
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
$CP python-stdlib/tempfile/tempfile.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
export MICROPYPATH
mkdir -p ${VIRTUAL_ENV}/lib
$CP micropython/ucontextlib/ucontextlib.py ${VIRTUAL_ENV}/lib/
$CP python-stdlib/fnmatch/fnmatch.py ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/hashlib-core/hashlib ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/hashlib-sha224/hashlib ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/hashlib-sha256/hashlib ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/hashlib-sha384/hashlib ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/hashlib-sha512/hashlib ${VIRTUAL_ENV}/lib/
$CP python-stdlib/shutil/shutil.py ${VIRTUAL_ENV}/lib/
$CP python-stdlib/tempfile/tempfile.py ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/unittest/unittest ${VIRTUAL_ENV}/lib/
$CP -r python-stdlib/unittest-discover/unittest ${VIRTUAL_ENV}/lib/
$CP unix-ffi/ffilib/ffilib.py ${VIRTUAL_ENV}/lib/
tree ${VIRTUAL_ENV}
}

function ci_package_tests_run {
export MICROPYPATH
for test in \
micropython/drivers/storage/sdcard/sdtest.py \
micropython/xmltok/test_xmltok.py \
Expand Down
Loading