Skip to content

Commit b36aa84

Browse files
tsukasa-audpgeorge
authored andcommitted
tools/ci.sh: Use $TMPDIR for temporary storage.
`tools/ci.sh` will now respect the `TMPDIR` environment variable when we need somewhere to store things (such as a checkout of micropython). If this variable is not set, we will fallback to `/tmp` (like the script currently does). Signed-off-by: Greg Darke <micropython@me.tsukasa.au>
1 parent 381ac74 commit b36aa84

1 file changed

Lines changed: 27 additions & 26 deletions

File tree

tools/ci.sh

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

20-
MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython
20+
TMPDIR="${TMPDIR:-/tmp}"
21+
MICROPYTHON="${TMPDIR}/micropython/ports/unix/build-standard/micropython"
2122

2223
function ci_package_tests_setup_micropython {
23-
git clone https://github.com/micropython/micropython.git /tmp/micropython
24+
git clone https://github.com/micropython/micropython.git "${TMPDIR}/micropython"
2425

2526
# 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
27+
make -C "${TMPDIR}/micropython/mpy-cross" -j CFLAGS_EXTRA=-O0
28+
make -C "${TMPDIR}/micropython/ports/unix" submodules
29+
make -C "${TMPDIR}/micropython/ports/unix" -j CFLAGS_EXTRA=-O0
2930
}
3031

3132
function ci_package_tests_setup_lib {
@@ -73,7 +74,7 @@ function ci_package_tests_run {
7374
unix-ffi/time/test_strftime.py \
7475
; do
7576
echo "Running test $test"
76-
(cd `dirname $test` && $MICROPYTHON `basename $test`)
77+
(cd `dirname $test` && "${MICROPYTHON}" `basename $test`)
7778
if [ $? -ne 0 ]; then
7879
false # make this function return an error code
7980
return
@@ -96,29 +97,29 @@ function ci_package_tests_run {
9697
python-stdlib/unittest/tests \
9798
python-stdlib/unittest-discover/tests \
9899
; do
99-
(cd $path && $MICROPYTHON -m unittest)
100+
(cd $path && "${MICROPYTHON}" -m unittest)
100101
if [ $? -ne 0 ]; then false; return; fi
101102
done
102103

103-
(cd micropython/usb/usb-device && $MICROPYTHON -m tests.test_core_buffer)
104+
(cd micropython/usb/usb-device && "${MICROPYTHON}" -m tests.test_core_buffer)
104105
if [ $? -ne 0 ]; then false; return; fi
105106

106-
(cd python-ecosys/cbor2 && $MICROPYTHON -m examples.cbor_test)
107+
(cd python-ecosys/cbor2 && "${MICROPYTHON}" -m examples.cbor_test)
107108
if [ $? -ne 0 ]; then false; return; fi
108109
}
109110

110111
########################################################################################
111112
# build packages
112113

113114
function ci_build_packages_setup {
114-
git clone https://github.com/micropython/micropython.git /tmp/micropython
115+
git clone https://github.com/micropython/micropython.git "${TMPDIR}/micropython"
115116

116117
# build mpy-cross (use -O0 to speed up the build)
117-
make -C /tmp/micropython/mpy-cross -j CFLAGS_EXTRA=-O0
118+
make -C "${TMPDIR}/micropython/mpy-cross" -j CFLAGS_EXTRA=-O0
118119

119120
# check the required programs run
120-
/tmp/micropython/mpy-cross/build/mpy-cross --version
121-
python3 /tmp/micropython/tools/manifestfile.py --help
121+
"${TMPDIR}/micropython/mpy-cross/build/mpy-cross" --version
122+
python3 "${TMPDIR}/micropython/tools/manifestfile.py" --help
122123
}
123124

124125
function ci_build_packages_check_manifest {
@@ -129,17 +130,17 @@ function ci_build_packages_check_manifest {
129130
if [[ "$file" =~ "/unix-ffi/" ]]; then
130131
extra_args="--unix-ffi"
131132
fi
132-
python3 /tmp/micropython/tools/manifestfile.py $extra_args --lib . --compile $file
133+
python3 "${TMPDIR}/micropython/tools/manifestfile.py" $extra_args --lib . --compile $file
133134
done
134135
}
135136

136137
function ci_build_packages_compile_index {
137-
python3 tools/build.py --micropython /tmp/micropython --output $PACKAGE_INDEX_PATH
138+
python3 tools/build.py --micropython "${TMPDIR}/micropython" --output $PACKAGE_INDEX_PATH
138139
}
139140

140141
function ci_build_packages_examples {
141142
for example in $(find -path \*example\*.py); do
142-
/tmp/micropython/mpy-cross/build/mpy-cross $example
143+
"${TMPDIR}/micropython/mpy-cross/build/mpy-cross" $example
143144
done
144145
}
145146

@@ -151,26 +152,26 @@ function ci_push_package_index {
151152
# "truthy" value in the "Secrets and variables" -> "Actions"
152153
# -> "Variables" setting of the GitHub repo.
153154

154-
PAGES_PATH=/tmp/gh-pages
155+
PAGES_PATH="${TMPDIR}/gh-pages"
155156

156157
if git fetch --depth=1 origin gh-pages; then
157-
git worktree add ${PAGES_PATH} gh-pages
158-
cd ${PAGES_PATH}
158+
git worktree add "${PAGES_PATH}" gh-pages
159+
cd "${PAGES_PATH}"
159160
NEW_BRANCH=0
160161
else
161162
echo "Creating gh-pages branch for $GITHUB_REPOSITORY..."
162-
git worktree add --force ${PAGES_PATH} HEAD
163-
cd ${PAGES_PATH}
163+
git worktree add --force "${PAGES_PATH}" HEAD
164+
cd "${PAGES_PATH}"
164165
git switch --orphan gh-pages
165166
NEW_BRANCH=1
166167
fi
167168

168-
DEST_PATH=${PAGES_PATH}/mip/${GITHUB_REF_NAME}
169-
if [ -d ${DEST_PATH} ]; then
170-
git rm -r ${DEST_PATH}
169+
DEST_PATH="${PAGES_PATH}/mip/${GITHUB_REF_NAME}"
170+
if [ -d "${DEST_PATH}" ]; then
171+
git rm -r "${DEST_PATH}"
171172
fi
172-
mkdir -p ${DEST_PATH}
173-
cd ${DEST_PATH}
173+
mkdir -p "${DEST_PATH}"
174+
cd "${DEST_PATH}"
174175

175176
cp -r ${PACKAGE_INDEX_PATH}/* .
176177

0 commit comments

Comments
 (0)