Skip to content

Commit fe7b467

Browse files
committed
Add a GH Actions code coverage job
1 parent d2bf724 commit fe7b467

File tree

2 files changed

+37
-80
lines changed

2 files changed

+37
-80
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ jobs:
5252
- name: Build and test
5353
run: .travis/cmake-osx
5454

55+
coverage-linux:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Build and test
60+
run: .travis/cmake-linux
61+
env:
62+
CC: gcc
63+
CXX: g++
64+
- name: Upload coverage
65+
run: .travis/upload-coverage
66+
5567
build-tcc:
5668
runs-on: ubuntu-latest
5769
steps:

.travis/cmake-linux

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,39 @@
11
#!/bin/bash
22

3-
ACTION="$1"
4-
53
set -eu
64

75
CACHEDIR="$HOME/cache"
86
NPROC=$(nproc)
9-
ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"
10-
ASTYLE_VERSION=3.1
11-
TRAVIS_TOOL="https://raw.githubusercontent.com/TokTok/ci-tools/master/bin/travis-haskell"
12-
13-
travis_install() {
14-
bash <(curl -s "$TRAVIS_TOOL") download
15-
travis-haskell download TokTok/hs-tokstyle tokstyle "$HOME/.local"
16-
17-
which coveralls || {
18-
# Install cpp-coveralls to upload test coverage results.
19-
pip install --user ndg-httpsclient urllib3[secure] cpp-coveralls
20-
21-
# Work around https://github.com/eddyxu/cpp-coveralls/issues/108 by manually
22-
# installing the pyOpenSSL module and injecting it into urllib3 as per
23-
# https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
24-
sed -i -e '/^import sys$/a import urllib3.contrib.pyopenssl\nurllib3.contrib.pyopenssl.inject_into_urllib3()' "$(which coveralls)"
25-
}
26-
27-
# Install astyle (version in ubuntu-precise too old).
28-
([ -f "$ASTYLE" ] && "$ASTYLE" --version | grep "$ASTYLE_VERSION" >/dev/null) || {
29-
wget -O ../astyle.tar.gz "https://deb.debian.org/debian/pool/main/a/astyle/astyle_$ASTYLE_VERSION.orig.tar.gz"
30-
tar -xf ../astyle.tar.gz -C "$CACHEDIR"
31-
make -C "$CACHEDIR/astyle/build/gcc" clean
32-
make -C "$CACHEDIR/astyle/build/gcc" "-j$NPROC"
33-
}
34-
}
35-
36-
run_static_analysis() {
37-
pylint3 -E other/analysis/check_recursion
38-
39-
export CPPFLAGS="-isystem $CACHEDIR/include"
40-
export LDFLAGS="-L$CACHEDIR/lib"
41-
other/analysis/run-check_recursion
42-
other/analysis/run-clang
43-
other/analysis/run-clang-analyze
44-
}
45-
46-
travis_script() {
47-
. ".travis/flags-$CC.sh"
48-
49-
add_ld_flag -Wl,-z,defs
50-
51-
# Make compilation error on a warning
52-
add_flag -Werror
53-
54-
# Coverage flags.
55-
add_flag -fprofile-arcs -ftest-coverage
567

57-
"$ASTYLE" --version
58-
other/astyle/format-source . "$ASTYLE"
8+
sudo apt-get install -y --no-install-recommends libopus-dev libsodium-dev libvpx-dev ninja-build
599

60-
echo "Running TokTok style checker"
61-
"$HOME/.local/bin/check-cimple"
10+
. ".travis/flags-$CC.sh"
6211

63-
# Use () to run in a separate process so the exports are local.
64-
(run_static_analysis)
12+
add_ld_flag -Wl,-z,defs
6513

66-
other/analysis/check_logger_levels
14+
# Make compilation error on a warning
15+
add_flag -Werror
6716

68-
cmake -B_build -H. -GNinja \
69-
-DCMAKE_C_FLAGS="$C_FLAGS" \
70-
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
71-
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
72-
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
73-
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \
74-
-DMIN_LOGGER_LEVEL=TRACE \
75-
-DMUST_BUILD_TOXAV=ON \
76-
-DNON_HERMETIC_TESTS=ON \
77-
-DSTRICT_ABI=ON \
78-
-DTEST_TIMEOUT_SECONDS=120 \
79-
-DUSE_IPV6=OFF \
80-
-DAUTOTEST=ON
17+
# Coverage flags.
18+
add_flag -fprofile-arcs -ftest-coverage
8119

82-
cmake --build _build --parallel "$NPROC" --target install -- -k 0
20+
cmake -B_build -H. -GNinja \
21+
-DCMAKE_C_FLAGS="$C_FLAGS" \
22+
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
23+
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
24+
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
25+
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \
26+
-DMIN_LOGGER_LEVEL=TRACE \
27+
-DMUST_BUILD_TOXAV=ON \
28+
-DNON_HERMETIC_TESTS=OFF \
29+
-DSTRICT_ABI=ON \
30+
-DTEST_TIMEOUT_SECONDS=120 \
31+
-DUSE_IPV6=OFF \
32+
-DAUTOTEST=ON
8333

84-
cd _build # pushd
85-
ctest -j50 --output-on-failure ||
86-
ctest -j50 --output-on-failure --rerun-failed
87-
cd - # popd
88-
}
34+
cmake --build _build --parallel "$NPROC" --target install -- -k 0
8935

90-
if [ "-z" "$ACTION" ]; then
91-
"travis_script"
92-
else
93-
"travis_$ACTION"
94-
fi
36+
cd _build # pushd
37+
ctest -j50 --output-on-failure ||
38+
ctest -j50 --output-on-failure --rerun-failed
39+
cd - # popd

0 commit comments

Comments
 (0)