Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:3.11.7
RUN apt-get update \
&& apt-get install -y \
cmake \
liblua5.1-0-dev \
lua5.1 \
libjson-c-dev

RUN mkdir /tmp/requirements \
&& git clone git://git.openwrt.org/project/libubox.git /tmp/requirements/libubox \
&& cd /tmp/requirements/libubox \
&& git checkout eb9bcb64185ac155c02cc1a604692c4b00368324 \
&& cmake CMakeLists.txt \
&& make install \
&& git clone git://git.openwrt.org/project/ubus.git /tmp/requirements/ubus \
&& cd /tmp/requirements/ubus \
&& git checkout afa57cce0aff82f4a7a0e509d4387ebc23dd3be7 \
&& cmake CMakeLists.txt \
&& make install \
&& git clone git://git.openwrt.org/project/uci.git /tmp/requirements/uci \
&& cd /tmp/requirements/uci \
&& git checkout 16ff0badbde7e17ec3bd1f827ffe45922956cf86 \
&& cmake CMakeLists.txt \
&& make install \
&& rm -rf /tmp/requirements \
&& echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf \
&& ldconfig

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& rm /tmp/requirements.txt
WORKDIR /app
CMD ["python3", "-m", "pytest"]
47 changes: 2 additions & 45 deletions builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,8 @@

set -e

repobase="ghcr.io/nethserver"

images=()
container=$(buildah from docker.io/ubuntu:jammy)

trap "buildah rm ${container}" EXIT

echo "Disalble IPv6 for APT"
buildah run ${container} /bin/bash -c "echo 'Acquire::ForceIPv4 \"true\";' > /etc/apt/apt.conf.d/99force-ipv4"

echo "Installing build depencies..."
buildah run ${container} /bin/bash -c "apt-get update"
buildah run ${container} /bin/bash -c "apt install software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa -y && apt-get install python3.10 -y"
buildah run ${container} /bin/bash -c "apt-get update && apt-get -y install --no-install-recommends \
lua5.1 liblua5.1-0-dev libjson-c-dev ca-certificates git cmake make pkg-config gcc"

echo "Compile libubox"
buildah run ${container} /bin/bash -c "git clone git://git.openwrt.org/project/libubox.git ~/libubox && \
cd ~/libubox && \
cmake CMakeLists.txt && \
make install && \
cd .. && \
rm -rf libubox"

echo "Compile uci"
buildah run ${container} /bin/bash -c "git clone git://git.openwrt.org/project/uci.git ~/uci && \
cd ~/uci && \
cmake cmake CMakeLists.txt && \
make install && \
cd .. && \
rm -rf uci"

echo "Install packages needed for PyUci"
buildah run ${container} /bin/bash -c "apt-get -y install --no-install-recommends \
python3-dev python3-setuptools python3-pip lcov python3-venv && \
apt-get clean"

echo "Install packages with pip"
buildah run ${container} /bin/bash -c "pip install pytest==7.1.2 pyuci pytest-mock passlib"

echo "Setup image"
buildah config --workingdir /root ${container}
buildah config --cmd='["python3", "-m", "pytest"]' ${container}
buildah commit ${container} "${repobase}/python3-nethsec-test"
images+=("${repobase}/python3-nethsec-test")
podman build --force-rm --layers --jobs 0 --tag ghcr.io/nethserver/python3-nethsec-test .
images+=("ghcr.io/nethserver/python3-nethsec-test")

if [[ -n "${CI}" ]]; then
# Set output value for Github Actions
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage==7.6.12
pydoctor==24.11.2
pytest==8.3.5
pytest-mock==3.14.0
pyuci==0.10.3
passlib==1.7.4
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
#
# The container assumes the source code is mounted inside /root
#
podman run --rm -t -v .:/root:Z ghcr.io/nethserver/python3-nethsec-test
podman run --rm --tty --volume .:/app:Z ghcr.io/nethserver/python3-nethsec-test
Loading