blob: e75ac40f3cee6b719f6306902001163a56e6da9a [file] [log] [blame]
Vadim Yanitskiy7ce04a52022-08-30 01:30:37 +07001#!/bin/sh -xe
Harald Weltee4759fd2021-04-11 10:58:30 +02002# 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 Smith8e45b752022-10-18 16:35:14 +02007# * JOB_TYPE: one of 'test', 'pylint', 'docs'
Harald Weltee4759fd2021-04-11 10:58:30 +02008#
Alexander Couzens47312322018-07-19 23:31:39 +02009
Oliver Smith507b5272022-10-18 16:48:52 +020010export PYTHONUNBUFFERED=1
11
Harald Welte91d4ec72019-05-10 16:20:54 +020012if [ ! -d "./pysim-testdata/" ] ; then
Alexander Couzens47312322018-07-19 23:31:39 +020013 echo "###############################################"
Harald Welte91d4ec72019-05-10 16:20:54 +020014 echo "Please call from pySim-prog top directory"
Alexander Couzens47312322018-07-19 23:31:39 +020015 echo "###############################################"
16 exit 1
17fi
18
Oliver Smith8e45b752022-10-18 16:35:14 +020019case "$JOB_TYPE" in
20"test")
21 virtualenv -p python3 venv --system-site-packages
22 . venv/bin/activate
Alexander Couzens47312322018-07-19 23:31:39 +020023
Oliver Smith8e45b752022-10-18 16:35:14 +020024 pip install -r requirements.txt
Philipp Maierec9cdb72023-07-27 14:43:08 +020025 pip install pyshark
Vadim Yanitskiy4ae7c492021-03-11 23:17:27 +010026
Oliver Smith8e45b752022-10-18 16:35:14 +020027 # Execute automatically discovered unit tests first
28 python -m unittest discover -v -s tests/
Vadim Yanitskiye9fe09b2021-05-02 01:46:55 +020029
Oliver Smith8e45b752022-10-18 16:35:14 +020030 # Run the test with physical cards
31 cd pysim-testdata
Philipp Maier1cdcbe42023-07-27 14:55:30 +020032 ../tests/pySim-prog_test.sh
Philipp Maierec9cdb72023-07-27 14:43:08 +020033 ../tests/pySim-trace_test.sh
Oliver Smith8e45b752022-10-18 16:35:14 +020034 ;;
35"pylint")
Vadim Yanitskiya7935522023-05-16 16:15:06 +070036 # Print pylint version
37 pip3 freeze | grep pylint
Oliver Smith8e45b752022-10-18 16:35:14 +020038 # 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 Welte5da7a722021-04-03 20:21:02 +020053
Oliver Smith8e45b752022-10-18 16:35:14 +020054 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
62esac