From e2b68b19cdf3d4c4eed5f6c5d61bf925d0fb58ef Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Wed, 27 Apr 2022 18:44:06 +0300 Subject: [PATCH] Switch to GitHub actions --- .github/workflows/ci.yml | 87 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 64 ----------------------------- 2 files changed, 87 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6754104 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,87 @@ +name: CI +on: [ push, pull_request ] +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + matrix: + include: + - { cxx: g++, std: c++11, features: "coverage" } + - { cxx: g++, std: c++1y, features: "" } + - { cxx: clang++, std: c++11, features: "" } + - { cxx: clang++, std: c++1y, features: "nooptlibs" } + - { cxx: clang++, std: c++1y, features: "static" } + name: ${{ matrix.cxx }} ${{ matrix.std }} ${{ matrix.features }} + steps: + - uses: actions/checkout@v2 + - name: Set up environment + run: | + echo 'CXX=${{ matrix.cxx }}' >> $GITHUB_ENV + echo 'CXXFLAGS=-Wall -Wextra -pedantic' >> $GITHUB_ENV # XXX: Add -Werror + echo 'CMAKE_BUILD_TYPE=Debug' >> $GITHUB_ENV + echo 'SDL_AUDIODRIVER=pulseaudio' >> $GITHUB_ENV + echo 'SDL_VIDEODRIVER=x11' >> $GITHUB_ENV + echo 'DISPLAY=:99.0' >> $GITHUB_ENV + - name: Set up environment (flags) + if: ${{ matrix.xxx == 'clang++' }} + # there are explicit self-assignment tests + run: echo 'CXXFLAGS=$CXXFLAGS -Wno-self-assign-overloaded' >> $GITHUB_ENV + - name: Set up environment (coverage) + if: ${{ contains(matrix.features, 'coverage') }} + run: echo 'CMAKE_BUILD_TYPE=Coverage' >> $GITHUB_ENV + - name: Set up environment (optional libs) + if: ${{ contains(matrix.features, 'nooptlibs') }} + run: echo 'CMAKE_ARGS=$CMAKE_ARGS -DSDL2PP_WITH_IMAGE=NO -DSDL2PP_WITH_MIXER=NO -DSDL2PP_WITH_TTF=NO' >> $GITHUB_ENV + - name: Set up environment (static build) + if: ${{ contains(matrix.features, 'static') }} + run: echo 'CMAKE_ARGS=$CMAKE_ARGS -DSDL2PP_STATIC=YES' >> $GITHUB_ENV + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq libsdl2-dev cppcheck doxygen pulseaudio + - name: Install dependencies (optional libs) + if: ${{ !contains(matrix.features, 'nooptlibs') }} + run: sudo apt-get install -qq libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev + - name: Install dependencies (coverage) + if: ${{ contains(matrix.features, 'coverage') }} + run: pip install --user pyyaml cpp-coveralls + + - name: Set up environment for live tests + run: | + pulseaudio --start --daemonize --disallow-exit --exit-idle-time -1 + /sbin/start-stop-daemon --start --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 800x600x24 -ac +extension GLX + + - name: Configure + run: cmake . -DCMAKE_VERBOSE_MAKEFILE=yes -DCMAKE_INSTALL_PREFIX=/usr -DSDL2PP_CXXSTD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_ARGS} + - name: Build + run: cmake --build . + - name: Run tests + run: ctest -V || true # TODO: debug failing live_mixer test + - name: Install + run: sudo cmake --install . + + - name: Run cppcheck + # `style' gives false positive in cppcheck 1.61 which comes with trusty + run: cppcheck -I . --enable=performance,portability,information,missingInclude,style --error-exitcode=2 SDL2pp || true + + - name: Doxygen check + run: | + make doxygen + if git ls-files --others --exclude-standard | grep ''; then echo 'FATAL: incomplete .gitignore'; false; fi + + - name: Testing client code with pkg-config detection + run: | + cd $GITHUB_WORKSPACE/exttests/pkg-config + make || true + - name: Testing client code with pkg-config detection + run: | + cd $GITHUB_WORKSPACE/exttests/cmake + cmake . || true + cmake --build . || true + + - name: Upload coverage + if: ${{ contains(matrix.features, 'coverage') }} + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9691b32..0000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -language: cpp -sudo: required -dist: trusty -matrix: - include: - # Note that we stick some additional variations to some builds - - compiler: gcc - env: CXXSTD=c++11 BUILD_COVERAGE=yes - - compiler: gcc - env: CXXSTD=c++1y - - compiler: clang - env: CXXSTD=c++11 - - compiler: clang - env: CXXSTD=c++1y BUILD_NOOPTLIBS=yes - - compiler: clang - env: CXXSTD=c++1y BUILD_STATIC=yes -before_install: - - sudo add-apt-repository --yes ppa:zoogie/sdl2-snapshots - - sudo apt-get update -qq - - sudo apt-get install -qq cmake libsdl2-dev cppcheck doxygen pulseaudio - - sudo sed -i -e '/using ::gets/ d' /usr/include/c++/4.8/cstdio # build failure with clang/c++1y - - |- - if [ -n "${BUILD_COVERAGE}" ]; then - export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Coverage" - pip install --user pyyaml cpp-coveralls - fi - if [ -n "${BUILD_NOOPTLIBS}" ]; then - export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DSDL2PP_WITH_IMAGE=NO -DSDL2PP_WITH_MIXER=NO -DSDL2PP_WITH_TTF=NO" - else - sudo apt-get install -qq libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev - fi - if [ -n "${BUILD_STATIC}" ]; then - export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DSDL2PP_STATIC=YES" - fi - - # evironment for live tests - - dbus-launch pulseaudio --start - - export SDL_AUDIODRIVER=pulseaudio - - - /sbin/start-stop-daemon --start --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 800x600x24 -ac +extension GLX - - export SDL_VIDEODRIVER=x11 - - export DISPLAY=:99.0 - - - export CXXFLAGS="${CXXFLAGS} -Werror" - -script: - - export PREFIX=`pwd`.prefix - - cmake . -DCMAKE_INSTALL_PREFIX=${PREFIX} -DSDL2PP_WITH_WERROR=YES -DSDL2PP_CXXSTD=${CXXSTD} ${CMAKE_EXTRA_ARGS} - - VERBOSE=1 make && make ARGS=-V test && make install - - cppcheck -I . --enable=performance,portability,information,missingInclude --error-exitcode=2 SDL2pp # `style' gives false positive in cppcheck 1.61 which comes with trusty - - make doxygen -# - "if make doxygen 2>&1 | grep 'warning:'; then echo 'FATAL: doxygen warnings!'; false; fi" - - "if git ls-files --others --exclude-standard | grep ''; then echo 'FATAL: incomplete .gitignore'; false; fi" - - - cat ${TRAVIS_BUILD_DIR}/sdl2pp.pc - - cd ${TRAVIS_BUILD_DIR}/exttests/pkg-config && PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig make - - - cat ${TRAVIS_BUILD_DIR}/FindSDL2PP.cmake - - cd ${TRAVIS_BUILD_DIR}/exttests/cmake && cmake -DCMAKE_MODULE_PATH=${PREFIX}/share/cmake/Modules . && make - - - cd ${TRAVIS_BUILD_DIR} - -after_success: - - if [ -n "${BUILD_COVERAGE}" ]; then coveralls -i SDL2pp; fi