Setup github actions

This commit is contained in:
Alexey Sokolov
2021-06-29 22:05:35 +01:00
parent 688645413c
commit bcbdce2daf
4 changed files with 197 additions and 5 deletions

56
.github/build.sh vendored Normal file
View File

@@ -0,0 +1,56 @@
set -x
pwd
ls -la
cpanm --local-lib=~/perl5 local::lib
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Devel::Cover::Report::Clover
pip3 install --user coverage
export ZNC_MODPERL_COVERAGE=1"
export ZNC_MODPYTHON_COVERAGE=1"
case "$RUNNER_OS" in
Linux)
CXX_FOR_COV=$CXX
;;
macOS)
CXX_FOR_COV=clang++
;;
esac
case "$CXX_FOR_COV" in
g++)
CXXFLAGS+=" --coverage"
LDFLAGS+=" --coverage"
;;
clang++)
CXXFLAGS+=" -fprofile-instr-generate -fcoverage-mapping"
LDFLAGS+=" -fprofile-instr-generate"
;;
esac
mkdir build
cd build
../configure --enable-debug --enable-perl --enable-python --enable-tcl --enable-cyrus --enable-charset $CFGFLAGS
cmake --system-information
make -j2 VERBOSE=1
env LLVM_PROFILE_FILE="$PWD/unittest.profraw" make VERBOSE=1 unittest
sudo make install
/usr/local/bin/znc --version
# TODO: use DEVEL_COVER_OPTIONS for https://metacpan.org/pod/Devel::Cover
env LLVM_PROFILE_FILE="$PWD/inttest.profraw" ZNC_MODPERL_COVERAGE_OPTS="-db,$PWD/cover_db" PYTHONWARNINGS=error make VERBOSE=1 inttest
case "$RUNNER_OS" in
Linux)
~/perl5/bin/cover --no-gcov --report=clover
;;
macOS)
xcrun llvm-profdata merge unittest.profraw -o unittest.profdata
xcrun llvm-profdata merge inttest.profraw -o inttest.profdata
xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=unittest.profdata test/unittest_bin > unittest-cmake-coverage.txt
xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata /usr/local/bin/znc > inttest-znc-coverage.txt
find /usr/local/lib/znc -name '*.so' -or -name '*.bundle' | while read f; do xcrun llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata $f > inttest-$(basename $f)-coverage.txt; done
;;
esac

3
.github/ubuntu_deps.sh vendored Normal file
View File

@@ -0,0 +1,3 @@
sudo apt-get update
sudo apt-get install -y tcl-dev libsasl2-dev libicu-dev swig qtbase5-dev libboost-locale-dev libperl-dev cpanminus gettext

138
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,138 @@
name: Test
on:
- push
- pull_request
jobs:
gcc:
name: GCC
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: source .github/ubuntu_deps.sh
- run: source .github/build.sh
- uses: codecov/codecov-action@v1
tarball:
name: Tarball
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: source .github/ubuntu_deps.sh
- run: |
./make-tarball.sh --nightly znc-git-2015-01-16 /tmp/znc-tarball.tar.gz
tar xvf /tmp/znc-tarball.tar.gz
cd znc-git-2015-01-16
export CFGFLAGS="--with-gtest=$GITHUB_WORKSPACE/third_party/googletest/googletest --with-gmock=$GITHUB_WORKSPACE/third_party/googletest/googlemock --disable-swig"
source .github/build.sh
- uses: codecov/codecov-action@v1
# can be removed when asan below is fixed
clang:
name: Clang
runs-on: ubuntu-20.04
env:
CXX: clang++
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: source .github/ubuntu_deps.sh
- run: source .github/build.sh
- uses: codecov/codecov-action@v1
#clang_asan:
#name: Clang ASAN
#runs-on: ubuntu-20.04
#env:
#CXX: clang++
#CXXFLAGS: "-fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fPIE"
#LDFLAGS: "-fsanitize=address -pie"
#steps:
#- uses: actions/checkout@v2
#with:
#submodules: true
#- run: source .github/ubuntu_deps.sh
#- run: source .github/build.sh
#- uses: codecov/codecov-action@v1
#clang_tsan:
#name: Clang TSAN
#runs-on: ubuntu-20.04
#env:
#CXX: clang++
#CXXFLAGS: "-fsanitize=thread -O1 -fPIE"
#LDFLAGS: "-fsanitize=thread"
#steps:
#- uses: actions/checkout@v2
#with:
#submodules: true
#- run: source .github/ubuntu_deps.sh
#- run: source .github/build.sh
#- uses: codecov/codecov-action@v1
# TODO: enable
#CXXFLAGS: "-fsanitize=memory -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins"
#LDFLAGS: "-fsanitize=memory"
#CXXFLAGS: "-fsanitize=undefined -O1 -fPIE -fno-sanitize-recover"
#LDFLAGS: "-fsanitize=undefined -pie -fno-sanitize-recover"
#macos:
#name: macOS
#runs-on: macos-latest
#steps:
#- uses: actions/checkout@v2
#with:
#submodules: true
#- run: |
#brew update
#brew install icu4c qt5 gettext pkg-config cpanminus boost
#- run: source .github/build.sh
#- uses: codecov/codecov-action@v1
docker:
name: Docker push
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs:
- gcc
- tarball
- clang
steps:
- uses: actions/checkout@v2
with:
submodules: true
- id: tagger
run: |
git fetch --unshallow
echo "::set-output name=describe::$(git describe)"
if [[ "$GITHUB_REF" == refs/heads/master ]]; then
echo "::set-output name=latest::type=raw,latest"
fi
- uses: docker/metadata-action@v3
id: meta
with:
images: zncbouncer/znc-git
tags: |
type=ref,event=branch
type=ref,event=branch,suffix=-${{steps.tagger.outputs.describe}}'
${{steps.tagger.outputs.latest}}
- run: echo "${GITHUB_REF#refs/heads/}-${{steps.tagger.outputs.describe}}" > .nightly
- run: cat .nightly
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION_EXTRA=+docker-git-

View File

@@ -5,13 +5,8 @@ ARG VERSION_EXTRA=""
ARG CMAKEFLAGS="-DVERSION_EXTRA=${VERSION_EXTRA} -DCMAKE_INSTALL_PREFIX=/opt/znc -DWANT_CYRUS=YES -DWANT_PERL=YES -DWANT_PYTHON=YES"
ARG MAKEFLAGS=""
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vcs-ref=$VCS_REF
LABEL org.label-schema.vcs-url="https://github.com/znc/znc"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.url="https://znc.in"
COPY . /znc-src