Vadim Yanitskiy | 7ce04a5 | 2022-08-30 01:30:37 +0700 | [diff] [blame] | 1 | #!/bin/sh -xe |
Harald Welte | e4759fd | 2021-04-11 10:58:30 +0200 | [diff] [blame] | 2 | # jenkins build helper script for pysim. This is how we build on jenkins.osmocom.org |
| 3 | # |
| 4 | # environment variables: |
| 5 | # * WITH_MANUALS: build manual PDFs if set to "1" |
| 6 | # * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1") |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 7 | # * JOB_TYPE: one of 'test', 'pylint', 'docs' |
Harald Welte | e4759fd | 2021-04-11 10:58:30 +0200 | [diff] [blame] | 8 | # |
Alexander Couzens | 4731232 | 2018-07-19 23:31:39 +0200 | [diff] [blame] | 9 | |
Oliver Smith | 507b527 | 2022-10-18 16:48:52 +0200 | [diff] [blame] | 10 | export PYTHONUNBUFFERED=1 |
| 11 | |
Harald Welte | 91d4ec7 | 2019-05-10 16:20:54 +0200 | [diff] [blame] | 12 | if [ ! -d "./pysim-testdata/" ] ; then |
Alexander Couzens | 4731232 | 2018-07-19 23:31:39 +0200 | [diff] [blame] | 13 | echo "###############################################" |
Harald Welte | 91d4ec7 | 2019-05-10 16:20:54 +0200 | [diff] [blame] | 14 | echo "Please call from pySim-prog top directory" |
Alexander Couzens | 4731232 | 2018-07-19 23:31:39 +0200 | [diff] [blame] | 15 | echo "###############################################" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 19 | case "$JOB_TYPE" in |
| 20 | "test") |
| 21 | virtualenv -p python3 venv --system-site-packages |
| 22 | . venv/bin/activate |
Alexander Couzens | 4731232 | 2018-07-19 23:31:39 +0200 | [diff] [blame] | 23 | |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 24 | pip install -r requirements.txt |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 25 | pip install pyshark |
Vadim Yanitskiy | 4ae7c49 | 2021-03-11 23:17:27 +0100 | [diff] [blame] | 26 | |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 27 | # Execute automatically discovered unit tests first |
| 28 | python -m unittest discover -v -s tests/ |
Vadim Yanitskiy | e9fe09b | 2021-05-02 01:46:55 +0200 | [diff] [blame] | 29 | |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 30 | # Run the test with physical cards |
| 31 | cd pysim-testdata |
Philipp Maier | 1cdcbe4 | 2023-07-27 14:55:30 +0200 | [diff] [blame] | 32 | ../tests/pySim-prog_test.sh |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 33 | ../tests/pySim-trace_test.sh |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 34 | ;; |
| 35 | "pylint") |
Vadim Yanitskiy | a793552 | 2023-05-16 16:15:06 +0700 | [diff] [blame] | 36 | # Print pylint version |
| 37 | pip3 freeze | grep pylint |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 38 | # Run pylint to find potential errors |
| 39 | # Ignore E1102: not-callable |
| 40 | # pySim/filesystem.py: E1102: method is not callable (not-callable) |
| 41 | # Ignore E0401: import-error |
| 42 | # pySim/utils.py:276: E0401: Unable to import 'Crypto.Cipher' (import-error) |
| 43 | # pySim/utils.py:277: E0401: Unable to import 'Crypto.Util.strxor' (import-error) |
| 44 | python3 -m pylint -j0 --errors-only \ |
| 45 | --disable E1102 \ |
| 46 | --disable E0401 \ |
| 47 | --enable W0301 \ |
| 48 | pySim *.py |
| 49 | ;; |
| 50 | "docs") |
| 51 | rm -rf docs/_build |
| 52 | make -C "docs" html latexpdf |
Harald Welte | 5da7a72 | 2021-04-03 20:21:02 +0200 | [diff] [blame] | 53 | |
Oliver Smith | 8e45b75 | 2022-10-18 16:35:14 +0200 | [diff] [blame] | 54 | if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then |
| 55 | make -C "docs" publish publish-html |
| 56 | fi |
| 57 | ;; |
| 58 | *) |
| 59 | set +x |
| 60 | echo "ERROR: JOB_TYPE has unexpected value '$JOB_TYPE'." |
| 61 | exit 1 |
| 62 | esac |