Add tests. Run them in CI. Make soundscripts use fixed_vector instead… #509
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-2019] | |
vgui_build: [non-vgui, vgui] | |
include: | |
- os: ubuntu-latest | |
cc: gcc | |
cxx: g++ | |
- os: windows-2019 | |
cc: cl | |
cxx: cl | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
include_features: "false" | |
fgd_name: "halflife_featureful.fgd" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup VGUI-related environment variables | |
shell: bash | |
run: | | |
if [ ${{ matrix.vgui_build }} == 'vgui' ] | |
then | |
echo "USE_VGUI=ON" >> "$GITHUB_ENV"; echo "vgui_suffix=-vgui" >> "$GITHUB_ENV" | |
else | |
echo "USE_VGUI=OFF" >> "$GITHUB_ENV"; echo "vgui_suffix=" >> "$GITHUB_ENV" | |
fi | |
- name: Checkout steam-runtime | |
if: startsWith(matrix.os, 'ubuntu') | |
uses: actions/checkout@v4 | |
with: | |
repository: ValveSoftware/steam-runtime | |
path: steam-runtime | |
- name: Cache steam-runtime | |
if: startsWith(matrix.os, 'ubuntu') | |
id: cache-steam-runtime | |
uses: actions/cache@v4 | |
with: | |
path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
key: ${{ runner.os }}-steam-runtime | |
- name: Download steam-runtime | |
if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true' | |
run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/0.20210610.0/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
- name: Install steam runtime | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
sudo apt update | |
./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf | |
- name: Build on Linux | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
schroot --chroot steamrt_scout_i386 -- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPOLLY=ON -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VGUI=${{ env.USE_VGUI }} -DCMAKE_INSTALL_PREFIX="$PWD/dist" | |
if [ ${{ env.USE_VGUI == 'ON' }} ]; then cp vgui_support/vgui-dev/lib/vgui.so build/cl_dll; cp vgui_support/vgui-dev/lib/vgui.so build ; fi | |
schroot --chroot steamrt_scout_i386 -- cmake --build build --target all | |
schroot --chroot steamrt_scout_i386 -- cmake --build build --target install | |
- name: Add msbuild to PATH | |
if: startsWith(matrix.os, 'windows') | |
uses: microsoft/setup-msbuild@v2 | |
- name: Build on Windows | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
cmake -G "Visual Studio 16 2019" -A Win32 -B build -DUSE_VGUI=${{ env.USE_VGUI }} -DCMAKE_INSTALL_PREFIX="dist" | |
msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Extract gamedir | |
shell: bash | |
run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT | |
id: extract_gamedir | |
- name: Copy fgd to dist dir | |
run: cp fgd/halflife.fgd dist/${{ steps.extract_gamedir.outputs.gamedir }}/${{ env.fgd_name }} | |
- name: Copy features to dist dir | |
if: ${{ env.include_features == 'true' }} | |
run: cp -r features/ dist/${{ steps.extract_gamedir.outputs.gamedir }}/ | |
- name: Delete .lib files from dist | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/cl_dlls/client.lib | |
Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/hl.lib | |
- name: Install Google Test | |
if: startsWith(matrix.os, 'ubuntu') | |
run: sudo apt -y install libgtest-dev | |
- name: Run tests | |
if: startsWith(matrix.os, 'ubuntu') | |
working-directory: ./tests | |
run: | | |
cmake -B build -S . | |
cmake --build build --target all | |
./build/test | |
- name: Upload linux artifact | |
if: startsWith(matrix.os, 'ubuntu') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux${{ env.vgui_suffix }} | |
path: dist/${{ steps.extract_gamedir.outputs.gamedir }} | |
- name: Upload windows artifact | |
if: startsWith(matrix.os, 'windows') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows${{ env.vgui_suffix }} | |
path: dist/${{ steps.extract_gamedir.outputs.gamedir }} | |