ddnet/.github/workflows/build.yaml

240 lines
8.1 KiB
YAML

name: Build
on:
push:
branches-ignore:
- staging.tmp
- trying.tmp
- staging-squash-merge.tmp
pull_request:
jobs:
build-cmake:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, ubuntu-20.04]
include:
- os: ubuntu-latest
cmake-args: -G Ninja
package-file: "*-linux_x86_64.tar.xz"
fancy: true
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- os: ubuntu-20.04
cmake-path: /usr/bin/
cmake-args: -G Ninja -DTEST_MYSQL=ON
package-file: "*-linux_x86_64.tar.xz"
fancy: false
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
GTEST_FILTER: -*SQLite*
- os: macOS-latest
cmake-args: -G Ninja
package-file: "*-macos.dmg"
fancy: false
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- os: windows-latest
cmake-args: -A x64
package-file: "*-win64.zip"
fancy: false
env:
CFLAGS: /WX
CXXFLAGS: /WX
LDFLAGS: /WX
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libvulkan-dev glslang-tools spirv-tools libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev libpng-dev valgrind gcovr -y
- name: Prepare Linux (non-fancy)
if: ${{ contains(matrix.os, 'ubuntu') && !matrix.fancy }}
run: |
sudo rm -rf /var/lib/mysql/ /var/run/mysqld
sudo mkdir /var/lib/mysql/ /var/run/mysqld/
sudo chown mysql:mysql /var/lib/mysql/ /var/run/mysqld/
sudo mysqld --initialize-insecure --user=mysql --basedir=/usr --datadir=/var/lib/mysql/
sudo /usr/bin/mysqld_safe --basedir=/usr --datadir='/var/lib/mysql/' &
sleep 10
sudo mysql <<EOF
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
EOF
- name: Prepare Linux (fancy)
if: contains(matrix.os, 'ubuntu') && matrix.fancy
run: |
sudo apt-get install libmariadbclient-dev libwebsockets-dev mariadb-server-10.3 -y
sudo rm -rf /var/lib/mysql/
sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql/
cd /usr; sudo mysqld_safe --datadir='/var/lib/mysql/' --no-watch
sleep 10
sudo mysql <<EOF
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
EOF
- name: Prepare macOS
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config sdl2 ffmpeg python3 ninja molten-vk vulkan-headers glslang spirv-tools
brew upgrade freetype
pip3 install dmgbuild
sudo rm -rf /Library/Developer/CommandLineTools
- name: Build in debug mode
env: ${{ matrix.env }}
run: |
mkdir debug
cd debug
${{ matrix.cmake-path }}cmake --version
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake --build . --config Debug --target everything ${{ matrix.build-args }}
- name: Test debug
env: ${{ matrix.env }}
run: |
cd debug
${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
- name: Run debug server
env: ${{ matrix.env }}
run: |
cd debug
./DDNet-Server shutdown
- name: Build in release mode
env: ${{ matrix.env }}
run: |
mkdir release
cd release
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Release -Werror=dev -DDOWNLOAD_GTEST=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
${{ matrix.cmake-path }}cmake --build . --config Release --target everything ${{ matrix.build-args }}
- name: Test release
env: ${{ matrix.env }}
run: |
cd release
${{ matrix.cmake-path }}cmake --build . --config Release --target run_tests ${{ matrix.build-args }}
- name: Run release server
env: ${{ matrix.env }}
run: |
cd release
./DDNet-Server shutdown
- name: Build headless client
if: contains(matrix.os, 'ubuntu-latest')
env: ${{ matrix.env }}
run: |
mkdir headless
cd headless
CFLAGS="$CFLAGS --coverage"
CXXFLAGS="$CXXFLAGS --coverage"
LDFLAGS="$LDFLAGS --coverage"
${{ matrix.cmake-path }}cmake --version
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DHEADLESS_CLIENT=ON -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }}
- name: Test headless client (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
- name: Upload Codecov report (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v3
with:
gcov: true
gcov_include: src
flags: unittests
- name: Test headless client (start & connect)
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
# Remove old coverage data:
find . -name '*.gcno' -o -name '*.gcda' -delete
./DDNet-Server &
./DDNet "cl_download_skins 0;connect localhost:8303;quit"
- name: Upload Codecov report (start & connect)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v3
with:
gcov: true
gcov_include: src
flags: startconnect
- name: Build in release mode with debug info and all features on
if: matrix.fancy
env: ${{ matrix.env }}
run: |
mkdir fancy
cd fancy
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDOWNLOAD_GTEST=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. -DANTIBOT=ON -DWEBSOCKETS=ON ..
${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target everything ${{ matrix.build-args }}
- name: Test fancy
if: matrix.fancy
env: ${{ matrix.env }}
run: |
cd fancy
${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target run_tests ${{ matrix.build-args }}
- name: Run fancy server
if: matrix.fancy
env: ${{ matrix.env }}
run: |
cd fancy
./DDNet-Server shutdown
- name: Run integration tests with Valgrind's Memcheck
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
# Remove old coverage data:
find . -name '*.gcno' -o -name '*.gcda' -delete
./integration_test.sh --valgrind-memcheck
- name: Upload Codecov report (integration tests)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v3
with:
gcov: true
gcov_include: src
flags: intgrationtests
- name: Package
run: |
cd release
${{ matrix.cmake-path }}cmake --build . --config Release --target package_default ${{ matrix.build-args }}
mkdir artifacts
mv ${{ matrix.package-file }} artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v1
with:
name: ddnet-${{ matrix.os }}
path: release/artifacts