blob: 34f47ea3c6c0f3e0be49fb5c11af836f971ab111 [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
Vadim Yanitskiy4ae7c492021-03-11 23:17:27 +010025
Oliver Smith8e45b752022-10-18 16:35:14 +020026 # Execute automatically discovered unit tests first
27 python -m unittest discover -v -s tests/
Vadim Yanitskiye9fe09b2021-05-02 01:46:55 +020028
Oliver Smith8e45b752022-10-18 16:35:14 +020029 # Run the test with physical cards
30 cd pysim-testdata
31 ../tests/pysim-test.sh
32 ;;
33"pylint")
34 # Run pylint to find potential errors
35 # Ignore E1102: not-callable
36 # pySim/filesystem.py: E1102: method is not callable (not-callable)
37 # Ignore E0401: import-error
38 # pySim/utils.py:276: E0401: Unable to import 'Crypto.Cipher' (import-error)
39 # pySim/utils.py:277: E0401: Unable to import 'Crypto.Util.strxor' (import-error)
40 python3 -m pylint -j0 --errors-only \
41 --disable E1102 \
42 --disable E0401 \
43 --enable W0301 \
44 pySim *.py
45 ;;
46"docs")
47 rm -rf docs/_build
48 make -C "docs" html latexpdf
Harald Welte5da7a722021-04-03 20:21:02 +020049
Oliver Smith8e45b752022-10-18 16:35:14 +020050 if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
51 make -C "docs" publish publish-html
52 fi
53 ;;
54*)
55 set +x
56 echo "ERROR: JOB_TYPE has unexpected value '$JOB_TYPE'."
57 exit 1
58esac