|
1 | 1 | #!/bin/bash |
2 | 2 | set -eo pipefail |
3 | 3 |
|
| 4 | +in_section=false |
| 5 | +if [ "${CI}" -eq "true" ]; then |
| 6 | + start_section () { |
| 7 | + if $in_section; then end_section; fi |
| 8 | + echo "::group::$*" |
| 9 | + export in_section=true |
| 10 | + } |
| 11 | + end_section () { |
| 12 | + echo "::endgroup::$*" |
| 13 | + in_section=false |
| 14 | + } |
| 15 | +else |
| 16 | + start_section () { |
| 17 | + if $in_section; then end_section; fi |
| 18 | + echo "=== $*" |
| 19 | + export in_section=true |
| 20 | + } |
| 21 | + end_section () { |
| 22 | + echo |
| 23 | + in_section=false |
| 24 | + } |
| 25 | +fi |
| 26 | + |
4 | 27 | repo_name=`git config remote.origin.url | sed -e 's,^.*/,,;s/\.git$//' | tr A-Z_ a-z-` |
5 | | -echo "=== Building package: $repo_name" |
| 28 | +echo "*** Building package: $repo_name" |
6 | 29 |
|
7 | | -echo "=== Create and set up virtual environment" |
| 30 | +start_section "Create and set up virtual environment" |
8 | 31 | [ -d .venv ] || python3 -m venv .env |
9 | 32 | . .env/bin/activate |
10 | | -echo "=== Install requirements" |
| 33 | +start_section "Install requirements" |
11 | 34 | pip3 install wheel |
12 | | -pip3 install -r requirements_dev.txt |
13 | | -echo "=== Run pre-commit" |
| 35 | +pip3 install -r optional_requirements.txt |
| 36 | +start_section "Run pre-commit" |
14 | 37 | pre-commit run --all-files |
15 | 38 |
|
16 | | -echo "=== Clone and build circuitpython unix port" |
| 39 | +start_section "Clone and build circuitpython unix port" |
17 | 40 | [ -e circuitpython/py/py.mk ] || git clone --shallow-since=2021-07-01 https://github.com/adafruit/circuitpython |
18 | 41 | [ -e circuitpython/lib/libffi/autogen.sh ] || (cd circuitpython && git submodule update --init lib/libffi lib/axtls lib/berkeley-db-1.xx tools/huffman lib/uzlib extmod/ulab) |
19 | 42 | [ -x circuitpython/ports/unix/micropython ] || ( |
20 | 43 | make -C circuitpython/mpy-cross -j$(nproc) |
21 | | -make -C circuitpython/ports/unix -j$(nproc) deplibs |
| 44 | +make -C circuitpython/ports/unix -j$(nproc) deplibs submodules |
22 | 45 | make -C circuitpython/ports/unix -j$(nproc) DEBUG=1 STRIP=: |
23 | 46 | ) |
24 | 47 |
|
25 | | -echo "=== Run tests" |
| 48 | +start_section "Run tests" |
26 | 49 | python -m jepler_udecimal.test |
27 | 50 |
|
28 | | -run-tests () { |
29 | | - env MICROPYPATH=. PYTHONPATH=. MICROPY_MICROPYTHON=circuitpython/ports/unix/micropython circuitpython/tests/run-tests.py "$@" |
| 51 | +run_tests () { |
| 52 | + env MICROPYPATH="`readlink -f .`" PYTHONPATH="`readlink -f .`" MICROPY_MICROPYTHON=circuitpython/ports/unix/build-standard/micropython circuitpython/tests/run-tests.py --keep-path "$@" |
30 | 53 | } |
31 | 54 |
|
32 | | -run-tests --clean-failures |
33 | | -if ! run-tests -d examples; then |
34 | | - run-tests --print-failures |
| 55 | +run_tests --clean-failures |
| 56 | +if ! run_tests -d examples; then |
| 57 | + run_tests --print-failures |
35 | 58 | exit 1 |
36 | 59 | fi |
37 | 60 |
|
38 | 61 | PYTHONPATH=. python examples/test_udecimal.py > test_udecimal.exp |
39 | | -echo "=== Build CircuitPython bundle" |
| 62 | +start_section "Build CircuitPython bundle" |
40 | 63 | circuitpython-build-bundles --package_folder_prefix jepler --filename_prefix $repo_name --library_location . |
41 | 64 |
|
42 | | -echo "=== Build docs" |
| 65 | +start_section "Build docs" |
43 | 66 | rm -rf docs/_build |
44 | 67 | (cd docs && sphinx-build -E -W -b html . _build/html) |
45 | 68 |
|
46 | | -echo "=== Build pypi files" |
47 | | -python setup.py sdist |
48 | | -python setup.py bdist_wheel --universal |
| 69 | +start_section "Build pypi files" |
| 70 | +python -m build |
49 | 71 |
|
50 | | -echo "=== Check pypi files" |
| 72 | +start_section "Check pypi files" |
51 | 73 | twine check dist/* |
| 74 | +end_section |
| 75 | + |
| 76 | +echo "=== Success" |
| 77 | + |
52 | 78 | # SPDX-FileCopyrightText: Copyright (c) 2020 jepler for Unpythonic Networks |
53 | 79 | # |
54 | 80 | # SPDX-License-Identifier: MIT |
0 commit comments