-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enable CI - Committed test suite that was forgotten on dev machine.
- Loading branch information
Showing
13 changed files
with
435 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[run] | ||
source = isotp | ||
concurrency = thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
FROM ubuntu:20.04 as build-tests | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
wget \ | ||
libssl-dev \ | ||
build-essential \ | ||
libffi-dev \ | ||
libreadline-dev \ | ||
zlib1g-dev \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
iproute2 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /tmp/ | ||
|
||
# ============================================ | ||
ARG PYTHON_VERSION="3.11.1" | ||
ARG PYTHON_SRC="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | ||
|
||
RUN wget $PYTHON_SRC \ | ||
&& tar -xvzf "Python-${PYTHON_VERSION}.tgz" \ | ||
&& cd "Python-${PYTHON_VERSION}" \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm "Python-${PYTHON_VERSION}.tgz" \ | ||
&& rm -rf "Python-${PYTHON_VERSION}" | ||
|
||
|
||
# ============================================ | ||
ARG PYTHON_VERSION="3.10.9" | ||
ARG PYTHON_SRC="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | ||
|
||
RUN wget $PYTHON_SRC \ | ||
&& tar -xvzf "Python-${PYTHON_VERSION}.tgz" \ | ||
&& cd "Python-${PYTHON_VERSION}" \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm "Python-${PYTHON_VERSION}.tgz" \ | ||
&& rm -rf "Python-${PYTHON_VERSION}" | ||
|
||
# ============================================ | ||
ARG PYTHON_VERSION="3.9.16" | ||
ARG PYTHON_SRC="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | ||
|
||
RUN wget $PYTHON_SRC \ | ||
&& tar -xvzf "Python-${PYTHON_VERSION}.tgz" \ | ||
&& cd "Python-${PYTHON_VERSION}" \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm "Python-${PYTHON_VERSION}.tgz" \ | ||
&& rm -rf "Python-${PYTHON_VERSION}" | ||
|
||
# ============================================ | ||
ARG PYTHON_VERSION="3.8.16" | ||
ARG PYTHON_SRC="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | ||
|
||
RUN wget $PYTHON_SRC \ | ||
&& tar -xvzf "Python-${PYTHON_VERSION}.tgz" \ | ||
&& cd "Python-${PYTHON_VERSION}" \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm "Python-${PYTHON_VERSION}.tgz" \ | ||
&& rm -rf "Python-${PYTHON_VERSION}" | ||
|
||
# ============================================ | ||
|
||
ARG PYTHON_VERSION="3.7.17" | ||
ARG PYTHON_SRC="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | ||
|
||
RUN wget $PYTHON_SRC \ | ||
&& tar -xvzf "Python-${PYTHON_VERSION}.tgz" \ | ||
&& cd "Python-${PYTHON_VERSION}" \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm "Python-${PYTHON_VERSION}.tgz" \ | ||
&& rm -rf "Python-${PYTHON_VERSION}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
pipeline { | ||
agent { | ||
label 'docker' | ||
} | ||
stages { | ||
stage ('Docker') { | ||
agent { | ||
dockerfile { | ||
// Required to be root to create vcan interfaces | ||
args '-e HOME=/tmp -e BUILD_CONTEXT=ci --cap-add=NET_ADMIN -u 0:0' | ||
additionalBuildArgs '--target build-tests' | ||
reuseNode true | ||
} | ||
} | ||
stages { | ||
stage('Setup vcan'){ | ||
steps { | ||
sh ''' | ||
ip link add dev vcan0 type vcan || true | ||
ip link set up vcan0 | ||
ip link add dev vcan1 type vcan || true | ||
ip link set up vcan1 | ||
ip link add dev vcan2 type vcan || true | ||
ip link set up vcan2 | ||
ip link add dev vcan3 type vcan || true | ||
ip link set up vcan3 | ||
ip link add dev vcan4 type vcan || true | ||
ip link set up vcan4 | ||
''' | ||
} | ||
} | ||
stage('Testing'){ | ||
parallel{ | ||
|
||
stage ('Python 3.11') { | ||
steps { | ||
sh ''' | ||
python3.11 -m venv venv-3.11 | ||
VENV_DIR=venv-3.11 scripts/with-venv.sh scripts/check-python-version.sh 3.11 | ||
VENV_DIR=venv-3.11 COVERAGE_SUFFIX=3.11 UNITTEST_VCAN=vcan0 scripts/with-venv.sh scripts/runtests.sh | ||
''' | ||
} | ||
} | ||
stage ('Python 3.10') { | ||
steps { | ||
sh ''' | ||
python3.10 -m venv venv-3.10 | ||
VENV_DIR=venv-3.10 scripts/with-venv.sh scripts/check-python-version.sh 3.10 | ||
VENV_DIR=venv-3.10 COVERAGE_SUFFIX=3.10 UNITTEST_VCAN=vcan1 scripts/with-venv.sh scripts/runtests.sh | ||
''' | ||
} | ||
} | ||
stage ('Python 3.9') { | ||
steps { | ||
sh ''' | ||
python3.9 -m venv venv-3.9 | ||
VENV_DIR=venv-3.9 scripts/with-venv.sh scripts/check-python-version.sh 3.9 | ||
VENV_DIR=venv-3.9 COVERAGE_SUFFIX=3.9 UNITTEST_VCAN=vcan2 scripts/with-venv.sh scripts/runtests.sh | ||
''' | ||
} | ||
} | ||
stage ('Python 3.8') { | ||
steps { | ||
sh ''' | ||
python3.8 -m venv venv-3.8 | ||
VENV_DIR=venv-3.8 scripts/with-venv.sh scripts/check-python-version.sh 3.8 | ||
VENV_DIR=venv-3.8 COVERAGE_SUFFIX=3.8 UNITTEST_VCAN=vcan3 scripts/with-venv.sh scripts/runtests.sh | ||
''' | ||
} | ||
} | ||
stage ('Python 3.7') { | ||
steps { | ||
sh ''' | ||
python3.7 -m venv venv-3.7 | ||
VENV_DIR=venv-3.7 scripts/with-venv.sh scripts/check-python-version.sh 3.7 | ||
VENV_DIR=venv-3.7 COVERAGE_SUFFIX=3.7 UNITTEST_VCAN=vcan4 scripts/with-venv.sh scripts/runtests.sh | ||
''' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd -P )" | ||
PY_MODULE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd -P )" | ||
|
||
VENV_DIR="${VENV_DIR:-venv}" | ||
VENV_ROOT="${VENV_DIR:-$PROJECT_ROOT/$VENV_DIR}" | ||
|
||
log() { echo -e "\x1B[92m[OK]\x1B[39m $@"; } | ||
|
||
[ ! -d "$VENV_ROOT" ] \ | ||
&& log "Missing venv. Creating..." \ | ||
&& python3 -m venv "$VENV_ROOT" | ||
|
||
source "$VENV_ROOT/bin/activate" | ||
|
||
if ! pip3 show wheel 2>&1 >/dev/null; then | ||
log "Installing wheel..." | ||
pip3 install wheel | ||
log "Upgrading pip..." | ||
pip3 install --upgrade pip | ||
log "Upgrading setuptools..." | ||
pip3 install --upgrade setuptools | ||
fi | ||
|
||
MODULE_FEATURE="[dev]" | ||
if ! [[ -z "${BUILD_CONTEXT+x}" ]]; then | ||
if [[ "$BUILD_CONTEXT" == "ci" ]]; then | ||
MODULE_FEATURE="[test]" # Will cause testing tools to be installed. | ||
fi | ||
fi | ||
|
||
if ! diff "$PY_MODULE_ROOT/setup.py" "$VENV_ROOT/cache/setup.py" 2>&1 >/dev/null; then | ||
log "Install inside venv" | ||
pip3 install -e "${PY_MODULE_ROOT}${MODULE_FEATURE}" | ||
mkdir -p "$VENV_ROOT/cache/" | ||
cp "$PY_MODULE_ROOT/setup.py" "$VENV_ROOT/cache/setup.py" | ||
fi | ||
|
||
set +e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
shopt -s nocasematch | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Python version must be specified" | ||
exit 1 | ||
fi | ||
|
||
REQUIRED_VERSION=$1 | ||
ACTUAL_PYTHON_VERSION=$(python3 --version) | ||
ACTUAL_PIP_VERSION=$(pip3 --version) | ||
|
||
if [[ $ACTUAL_PYTHON_VERSION != *"python ${REQUIRED_VERSION}"* ]]; then | ||
echo "ERROR - Reported python3 version is ${ACTUAL_PYTHON_VERSION}. Expecting Python ${REQUIRED_VERSION}" | ||
exit 1 | ||
fi | ||
|
||
if [[ $ACTUAL_PIP_VERSION != *"python ${REQUIRED_VERSION}"* ]]; then | ||
echo "ERROR - Reported pip3 version is ${ACTUAL_PIP_VERSION}. Expecting pip for Python ${REQUIRED_VERSION}" | ||
exit 1 | ||
fi | ||
|
||
echo "Python version OK." | ||
echo " - ${ACTUAL_PYTHON_VERSION}" | ||
echo " - ${ACTUAL_PIP_VERSION}" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
COVERAGE_SUFFIX="${COVERAGE_SUFFIX:-dev}" | ||
HTML_COVDIR="htmlcov_${COVERAGE_SUFFIX}" | ||
COV_DATAFILE=".coverage_${COVERAGE_SUFFIX}" | ||
|
||
if ! [[ -z "${BUILD_CONTEXT+x}" ]]; then | ||
if [[ "$BUILD_CONTEXT" == "ci" ]]; then | ||
if ! [[ -z "${NODE_NAME+x}" ]]; then | ||
echo "Running tests on agent: ${NODE_NAME}" | ||
fi | ||
fi | ||
fi | ||
|
||
set -x | ||
|
||
python3 -m coverage run --data-file ${COV_DATAFILE} -m unittest -v | ||
python3 -m mypy isotp --strict --no-warn-unused-ignore | ||
python3 -m coverage report --data-file ${COV_DATAFILE} | ||
python3 -m coverage html --data-file ${COV_DATAFILE} -d $HTML_COVDIR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd -P )" | ||
source "$PROJECT_ROOT/scripts/activate-venv.sh" | ||
|
||
set -e # activate-venv sets +e | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.