Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add coverage check to the docker build. #112

Merged
merged 1 commit into from
Feb 25, 2024
Merged
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
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
plugins = Cython.Coverage
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pyx_library(
cython_directives = {
"embedsignature": "True",
"embedsignature.format": "python",
"language_level": "3",
},
tags = ["no-cross"],
visibility = ["//visibility:public"],
Expand Down
59 changes: 32 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
FROM ubuntu:22.04
LABEL maintainer="[email protected]"
FROM alpine:3.19.0

RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
ca-certificates \
cmake \
gcc \
g++ \
git \
libopus-dev \
libsodium-dev \
libvpx-dev \
ninja-build \
pkg-config \
python3 \
python3-dev \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --no-cache-dir cython cython-lint mypy
RUN ["apk", "add", "--no-cache", \
"cmake", \
"g++", \
"gcc", \
"git", \
"libsodium-dev", \
"libvpx-dev", \
"linux-headers", \
"opus-dev", \
"pkgconfig", \
"py3-pip", \
"python3", \
"python3-dev", \
"samurai"]
RUN ["python3", "-m", "venv", "/path/to/venv"]

RUN . /path/to/venv/bin/activate \
&& pip3 install --no-cache-dir coverage cython cython-lint mypy

WORKDIR /build
RUN git clone --depth=1 --recursive https://github.com/TokTok/c-toxcore /build/c-toxcore \
&& cmake -GNinja -B/build/c-toxcore/_build -H/build/c-toxcore \
-DBOOTSTRAP_DAEMON=OFF \
-DENABLE_STATIC=OFF \
-DMUST_BUILD_TOXAV=ON \
&& cmake --build /build/c-toxcore/_build --target install --parallel "$(nproc)" \
&& ldconfig
&& cmake --build /build/c-toxcore/_build --target install

COPY pytox /build/pytox

RUN cython-lint --max-line-length 300 $(find pytox -name "*.pyx" -or -name "*.pxd")
RUN cython -I. $(find pytox -name "*.pyx")
RUN . /path/to/venv/bin/activate \
&& find pytox -name "*.pyx" -or -name "*.pxd" -print0 | xargs -0 cython-lint --max-line-length 300 \
&& find pytox -name "*.pyx" -print0 | xargs -0 cython -I.

COPY setup.py /build/
RUN python3 setup.py install \
&& python3 -c 'import pytox.toxcore.tox as core; print(core.__doc__)'
ENV CFLAGS="-DCYTHON_TRACE=1 -O0"
RUN . /path/to/venv/bin/activate \
&& pip install --no-cache-dir . \
&& python3 -c 'import pytox.toxcore.tox as core; print(core.Tox_Ptr.__init__.__doc__)'

COPY .coveragerc /build/
COPY test /build/test
RUN python3 test/tox_test.py
RUN . /path/to/venv/bin/activate \
&& coverage run -m unittest discover -v -p "*_test.py"
RUN . /path/to/venv/bin/activate \
&& coverage report -m
1 change: 1 addition & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty but required for test discovery.
1 change: 1 addition & 0 deletions test/auto_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty but required for test discovery.
File renamed without changes.