Skip to content

Commit 76a1a6a

Browse files
committed
test: Add coverage check to the docker build.
1 parent aeb2cce commit 76a1a6a

File tree

6 files changed

+36
-28
lines changed

6 files changed

+36
-28
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
plugins = Cython.Coverage

BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pyx_library(
1919
cython_directives = {
2020
"embedsignature": "True",
2121
"embedsignature.format": "python",
22-
"language_level": "3",
2322
},
2423
tags = ["no-cross"],
2524
visibility = ["//visibility:public"],

Dockerfile

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
1-
FROM ubuntu:22.04
2-
LABEL maintainer="[email protected]"
1+
FROM alpine:3.19.0
32

4-
RUN apt-get update \
5-
&& DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
6-
ca-certificates \
7-
cmake \
8-
gcc \
9-
g++ \
10-
git \
11-
libopus-dev \
12-
libsodium-dev \
13-
libvpx-dev \
14-
ninja-build \
15-
pkg-config \
16-
python3 \
17-
python3-dev \
18-
python3-pip \
19-
&& apt-get clean \
20-
&& rm -rf /var/lib/apt/lists/* \
21-
&& pip3 install --no-cache-dir cython cython-lint mypy
3+
RUN ["apk", "add", "--no-cache", \
4+
"cmake", \
5+
"g++", \
6+
"gcc", \
7+
"git", \
8+
"libsodium-dev", \
9+
"libvpx-dev", \
10+
"linux-headers", \
11+
"opus-dev", \
12+
"pkgconfig", \
13+
"py3-pip", \
14+
"python3", \
15+
"python3-dev", \
16+
"samurai"]
17+
RUN ["python3", "-m", "venv", "/path/to/venv"]
18+
19+
RUN . /path/to/venv/bin/activate \
20+
&& pip3 install --no-cache-dir coverage cython cython-lint mypy
2221

2322
WORKDIR /build
2423
RUN git clone --depth=1 --recursive https://github.com/TokTok/c-toxcore /build/c-toxcore \
2524
&& cmake -GNinja -B/build/c-toxcore/_build -H/build/c-toxcore \
2625
-DBOOTSTRAP_DAEMON=OFF \
2726
-DENABLE_STATIC=OFF \
2827
-DMUST_BUILD_TOXAV=ON \
29-
&& cmake --build /build/c-toxcore/_build --target install --parallel "$(nproc)" \
30-
&& ldconfig
28+
&& cmake --build /build/c-toxcore/_build --target install
3129

3230
COPY pytox /build/pytox
3331

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

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

42+
COPY .coveragerc /build/
4143
COPY test /build/test
42-
RUN python3 test/tox_test.py
44+
RUN . /path/to/venv/bin/activate \
45+
&& coverage run -m unittest discover -v -p "*_test.py"
46+
RUN . /path/to/venv/bin/activate \
47+
&& coverage report -m

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty but required for test discovery.

test/auto_tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty but required for test discovery.
File renamed without changes.

0 commit comments

Comments
 (0)