blob: 03098777af2f418ad53da0932c24782a4d5466fc [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")
Vadim Yanitskiya7935522023-05-16 16:15:06 +070034 # Print pylint version
35 pip3 freeze | grep pylint
Oliver Smith8e45b752022-10-18 16:35:14 +020036 # Run pylint to find potential errors
37 # Ignore E1102: not-callable
38 # pySim/filesystem.py: E1102: method is not callable (not-callable)
39 # Ignore E0401: import-error
40 # pySim/utils.py:276: E0401: Unable to import 'Crypto.Cipher' (import-error)
41 # pySim/utils.py:277: E0401: Unable to import 'Crypto.Util.strxor' (import-error)
42 python3 -m pylint -j0 --errors-only \
43 --disable E1102 \
44 --disable E0401 \
45 --enable W0301 \
46 pySim *.py
47 ;;
48"docs")
49 rm -rf docs/_build
50 make -C "docs" html latexpdf
Harald Welte5da7a722021-04-03 20:21:02 +020051
Oliver Smith8e45b752022-10-18 16:35:14 +020052 if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
53 make -C "docs" publish publish-html
54 fi
55 ;;
56*)
57 set +x
58 echo "ERROR: JOB_TYPE has unexpected value '$JOB_TYPE'."
59 exit 1
60esac