18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 03:24:58 +01:00

Merge branch 'master' into feat/renderers-cleanup

This commit is contained in:
2026-11-16 21:44:48 +01:00
264 changed files with 41203 additions and 10041 deletions

View File

@@ -14,6 +14,14 @@ on:
permissions: {}
# A newer push to a pull request makes the run for its older commit pointless, so that run is
# cancelled (sonar.yml then marks the analysis of the older commit as skipped). A push to master
# gets a group of its own, its commit, so the runs on master are neither cancelled nor held back
# by one another.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.sha }}
cancel-in-progress: true
jobs:
build:
name: Build under Build Wrapper
@@ -33,8 +41,16 @@ jobs:
with:
python-version: '3.14'
# A mirror that stops answering used to hold this step for over an hour.
# Time out each download, retry it, and give up on the whole step early.
- name: Install build dependencies
timeout-minutes: 15
run: |
printf '%s\n' \
'Acquire::Retries "3";' \
'Acquire::http::Timeout "60";' \
'Acquire::https::Timeout "60";' \
| sudo tee /etc/apt/apt.conf.d/80-ci-retries > /dev/null
sudo apt-get update -y
sudo apt-get install -y \
build-essential \
@@ -102,6 +118,7 @@ jobs:
--exclude='*.o' \
--exclude='*.a' \
--exclude='*.so' \
--exclude='*.so.*' \
-C "$GITHUB_WORKSPACE" .
- name: Upload analysis input

View File

@@ -27,9 +27,31 @@ jobs:
# Windows / MSVC
# ============================================================
# A newer push to the same branch or pull request cancels the build of the older commit. The
# groups are set on the build jobs rather than on the workflow, so a publish job that is already
# running is left to finish; with a build cancelled the publish job of that run is skipped. A push
# to master gets a group of its own, its commit, so the builds of master are never cancelled.
# Windows is built twice: with AVX2 (the default of ENABLE_AVX2) and without it, for CPUs older
# than Haswell (2013). Each variant has its own concurrency group, or one would cancel the other.
windows:
name: Windows x64 / MSVC
name: Windows x64 / MSVC / ${{ matrix.variant.name }}
runs-on: windows-2022
concurrency:
group: ${{ github.workflow }}-windows-${{ matrix.variant.suffix }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
variant:
- name: "AVX2"
suffix: "avx2"
cmake_flags: "-DENABLE_AVX2=ON"
- name: "No AVX2"
suffix: "noavx2"
cmake_flags: "-DENABLE_AVX2=OFF"
steps:
- name: Checkout repository
@@ -76,6 +98,27 @@ jobs:
run: |
call setup.bat
# the unit tests run at the end of the build and load lua51.dll (the Lua screens), but ref/luajit has only its import
# library. LuaJIT of the same 2.0 line is built here and put on PATH for them; it doesn't go into the uploaded build
- name: Build lua51.dll for the unit tests
shell: cmd
run: |
for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSDIR=%%i"
call "%VSDIR%\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
git init -q "%RUNNER_TEMP%\LuaJIT" || exit /b 1
cd /d "%RUNNER_TEMP%\LuaJIT"
rem the v2.0 branch of LuaJIT, pinned
git fetch -q --depth 1 https://github.com/LuaJIT/LuaJIT.git b83bcba6ea300d4eb16e8257ddf80bcdef1f938b || exit /b 1
git checkout -q FETCH_HEAD || exit /b 1
cd src
rem msvcbuild.bat runs the tools it builds (minilua, buildvm) from the current folder
set NoDefaultCurrentDirectoryInExePath=
call .\msvcbuild.bat || exit /b 1
if not exist lua51.dll exit /b 1
mkdir "%RUNNER_TEMP%\lua51"
copy /y lua51.dll "%RUNNER_TEMP%\lua51\" || exit /b 1
echo %RUNNER_TEMP%\lua51>> "%GITHUB_PATH%"
- name: Configure
shell: pwsh
run: |
@@ -83,11 +126,13 @@ jobs:
$pythonRoot = Split-Path $pythonExe
Write-Host "Python root: $pythonRoot"
Write-Host "Extra CMake flags: ${{ matrix.variant.cmake_flags }}"
cmake -S . -B build `
-G "Visual Studio 17 2022" `
-A x64 `
"-DPython3_ROOT_DIR=$pythonRoot"
"-DPython3_ROOT_DIR=$pythonRoot" `
${{ matrix.variant.cmake_flags }}
- name: Build
shell: pwsh
@@ -138,7 +183,7 @@ jobs:
- name: Upload Windows build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: maszyna-windows-x64-${{ env.CONFIG_WIN }}
name: maszyna-windows-x64-${{ matrix.variant.suffix }}-${{ env.CONFIG_WIN }}
path: |
build/bin/${{ env.CONFIG_WIN }}/
if-no-files-found: error
@@ -147,7 +192,7 @@ jobs:
- name: Upload Windows debug symbols
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: maszyna-windows-x64-symbols-${{ env.CONFIG_WIN }}
name: maszyna-windows-x64-symbols-${{ matrix.variant.suffix }}-${{ env.CONFIG_WIN }}
path: |
build/pdb/${{ env.CONFIG_WIN }}/*.pdb
build/bin/${{ env.CONFIG_WIN }}/*.map
@@ -160,8 +205,23 @@ jobs:
# ============================================================
linux:
name: Linux x64 / GCC
name: Linux x64 / GCC / ${{ matrix.variant.name }}
runs-on: ubuntu-24.04
# see the notes above the windows job: two variants, each with a concurrency group of its own
concurrency:
group: ${{ github.workflow }}-linux-${{ matrix.variant.suffix }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
variant:
- name: "AVX2"
suffix: "avx2"
cmake_flags: "-DENABLE_AVX2=ON"
- name: "No AVX2"
suffix: "noavx2"
cmake_flags: "-DENABLE_AVX2=OFF"
steps:
- name: Checkout repository
@@ -176,12 +236,25 @@ jobs:
with:
python-version: "3.14"
# A mirror that stops answering used to hold this step for over an hour.
# Time out each download, retry it, and give up on the whole step early.
- name: Install Linux dependencies
timeout-minutes: 15
run: |
printf '%s\n' \
'Acquire::Retries "3";' \
'Acquire::http::Timeout "60";' \
'Acquire::https::Timeout "60";' \
| sudo tee /etc/apt/apt.conf.d/80-ci-retries > /dev/null
sudo apt-get update
# libasound2-dev, libpulse-dev and libpipewire-0.3-dev: the headers of OpenAL Soft's audio backends (built below).
# Without them it builds with OSS only, which modern distributions and the Steam Linux Runtime don't have: no sound.
sudo apt-get install -y \
build-essential \
libasound2-dev \
libpulse-dev \
libpipewire-0.3-dev \
libgl1-mesa-dev \
libglew-dev \
libglfw3-dev \
@@ -190,6 +263,7 @@ jobs:
libluajit-5.1-dev \
libserialport-dev \
libsndfile1-dev \
libcurl4-openssl-dev \
xorg-dev \
libxkbcommon-dev \
libwayland-dev \
@@ -207,12 +281,17 @@ jobs:
https://github.com/kcat/openal-soft.git \
/tmp/openal-soft
# the backends are loaded with dlopen at run time (ALSOFT_DLOPEN), so the bundled library needs none of them;
# REQUIRE makes a missing header fail the build instead of shipping a library without sound
cmake \
-S /tmp/openal-soft \
-B /tmp/openal-soft/build \
-DCMAKE_BUILD_TYPE=Release \
-DALSOFT_EXAMPLES=OFF \
-DALSOFT_UTILS=OFF
-DALSOFT_UTILS=OFF \
-DALSOFT_REQUIRE_PIPEWIRE=ON \
-DALSOFT_REQUIRE_PULSEAUDIO=ON \
-DALSOFT_REQUIRE_ALSA=ON
cmake \
--build /tmp/openal-soft/build \
@@ -239,6 +318,7 @@ jobs:
-DWITH_ZMQ=OFF \
-DWITH_OPENVR=OFF \
-DUSE_LTO=OFF \
${{ matrix.variant.cmake_flags }} \
-DPython3_EXECUTABLE="${{ steps.python.outputs.python-path }}" \
-DCMAKE_CXX_FLAGS="-Wno-attributes -fno-inline-functions-called-once"
@@ -247,7 +327,31 @@ jobs:
cmake \
--build build \
--parallel "$(nproc)"
# the build copies the shared libraries next to the game (CMake_modules/bundle_runtime_libs.cmake) and the
# game looks for them there first ($ORIGIN): each one it loads from outside build/bin has to be one of the system
- name: Check the bundled libraries
run: |
GAME="$(find build/bin -maxdepth 1 -type f -name 'eu07*' -perm -u+x | head -n 1)"
test -n "$GAME"
echo "Game: $GAME"
readelf -d "$GAME" | grep -E 'R(UN)?PATH'
readelf -d "$GAME" | grep -q 'Library rpath: \[\$ORIGIN\]'
cat build/bin/bundled_libs.txt
ldd "$GAME"
if ldd "$GAME" | grep -q 'not found'; then
echo "::error::the game needs a library that is neither bundled nor in the system"
exit 1
fi
while read -r name; do
[ -n "$name" ] || continue
loaded="$(ldd "$GAME" | awk -v n="$name" '$1 == n { print $3 }')"
if [ -z "$loaded" ] || [ "$(realpath "$loaded")" != "$(realpath "build/bin/$name")" ]; then
echo "::error::$name is bundled, but the game loads it from '$loaded'"
exit 1
fi
done < build/bin/bundled_libs.txt
- name: Prepare Linux Python environment
run: |
PYTHON_ROOT="$(python -c 'import sys; print(sys.base_prefix)')"
@@ -280,7 +384,7 @@ jobs:
- name: Upload Linux build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: maszyna-linux-x64-${{ env.CONFIG_LINUX }}
name: maszyna-linux-x64-${{ matrix.variant.suffix }}-${{ env.CONFIG_LINUX }}
path: |
build/bin/
if-no-files-found: error
@@ -303,29 +407,47 @@ jobs:
cancel-in-progress: false
steps:
- name: Download Windows build
# the AVX2 build keeps the old name of the download, so the links already handed out still work
- name: Download Windows build (AVX2)
uses: actions/download-artifact@v4
with:
name: maszyna-windows-x64-${{ env.CONFIG_WIN }}
name: maszyna-windows-x64-avx2-${{ env.CONFIG_WIN }}
path: dist/maszyna-windows-x64
- name: Download Linux build
- name: Download Windows build (no AVX2)
uses: actions/download-artifact@v4
with:
name: maszyna-linux-x64-${{ env.CONFIG_LINUX }}
name: maszyna-windows-x64-noavx2-${{ env.CONFIG_WIN }}
path: dist/maszyna-windows-x64-noavx2
- name: Download Linux build (AVX2)
uses: actions/download-artifact@v4
with:
name: maszyna-linux-x64-avx2-${{ env.CONFIG_LINUX }}
path: dist/maszyna-linux-x64
- name: Download Linux build (no AVX2)
uses: actions/download-artifact@v4
with:
name: maszyna-linux-x64-noavx2-${{ env.CONFIG_LINUX }}
path: dist/maszyna-linux-x64-noavx2
- name: Pack
run: |
cd dist
find maszyna-linux-x64 -type f -exec sh -c 'file -b "$1" | grep -q "^ELF" && chmod +x "$1"' _ {} \;
if [ -d maszyna-linux-x64/linuxpython64/bin ]; then
chmod +x maszyna-linux-x64/linuxpython64/bin/*
fi
# the artifacts lose the executable bit
for dir in maszyna-linux-x64 maszyna-linux-x64-noavx2; do
find "$dir" -type f -exec sh -c 'file -b "$1" | grep -q "^ELF" && chmod +x "$1"' _ {} \;
if [ -d "$dir/linuxpython64/bin" ]; then
chmod +x "$dir"/linuxpython64/bin/*
fi
done
(cd maszyna-windows-x64 && zip -qr9 ../maszyna-windows-x64.zip .)
(cd maszyna-windows-x64-noavx2 && zip -qr9 ../maszyna-windows-x64-noavx2.zip .)
tar -czf maszyna-linux-x64.tar.gz -C maszyna-linux-x64 .
tar -czf maszyna-linux-x64-noavx2.tar.gz -C maszyna-linux-x64-noavx2 .
ls -la
- name: Publish rolling release of the branch
@@ -345,14 +467,18 @@ jobs:
"" \
"Download without a GitHub account:" \
"- Windows: $base/maszyna-windows-x64.zip" \
"- Windows, CPUs without AVX2 (older than Haswell, 2013): $base/maszyna-windows-x64-noavx2.zip" \
"- Linux: $base/maszyna-linux-x64.tar.gz" \
"- Linux, CPUs without AVX2: $base/maszyna-linux-x64-noavx2.tar.gz" \
"" \
"Unpack over a MaSzyna installation (the game data isn't included). Build log: $RUN_URL")"
gh release delete "$tag" --yes --cleanup-tag || true
gh release create "$tag" \
dist/maszyna-windows-x64.zip \
dist/maszyna-windows-x64-noavx2.zip \
dist/maszyna-linux-x64.tar.gz \
dist/maszyna-linux-x64-noavx2.tar.gz \
--target "$SHA" \
--prerelease \
--latest=false \
@@ -361,4 +487,6 @@ jobs:
echo "### Public download" >> "$GITHUB_STEP_SUMMARY"
echo "- Windows: $base/maszyna-windows-x64.zip" >> "$GITHUB_STEP_SUMMARY"
echo "- Windows, no AVX2: $base/maszyna-windows-x64-noavx2.zip" >> "$GITHUB_STEP_SUMMARY"
echo "- Linux: $base/maszyna-linux-x64.tar.gz" >> "$GITHUB_STEP_SUMMARY"
echo "- Linux, no AVX2: $base/maszyna-linux-x64-noavx2.tar.gz" >> "$GITHUB_STEP_SUMMARY"

135
.github/workflows/coverage.yml vendored Normal file
View File

@@ -0,0 +1,135 @@
# .github/workflows/coverage.yml
# UNTRUSTED CONTEXT. This workflow runs fork-authored code.
# It must never reference `secrets.*`. It only builds, runs the unit tests and
# uploads a report; nothing here feeds the SonarQube Cloud analysis.
#
# Coverage of the game's core library (eu07_core) by the unit tests, measured with
# gcov on a GCC build: the report goes to the summary of the run and to an artifact.
# It is not sent to SonarQube Cloud on purpose: the project's quality gate ("Sonar
# way") fails a pull request whose new code is covered in less than 80%, a condition
# that isn't evaluated as long as sonar-project.properties excludes every file from
# coverage. Wiring this report in would turn that condition on.
name: Coverage
on:
push:
branches:
- master
pull_request:
types: [ opened, reopened, synchronize ]
permissions: {}
# A newer push to a pull request cancels the run for its older commit; a push to master
# gets a group of its own (its commit), so the runs on master are never cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.sha }}
cancel-in-progress: true
jobs:
coverage:
name: Unit test coverage (GCC)
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
submodules: recursive
- name: Set up Python 3.14
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.14'
# the same packages as the Build workflow: the game is configured as a whole,
# though only the unit tests and the core library they link are built
- name: Install build dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y \
build-essential \
libgl1-mesa-dev libglew-dev libglfw3-dev \
libpng-dev libopenal-dev libluajit-5.1-dev \
libserialport-dev libsndfile1-dev \
xorg-dev libxkbcommon-dev libwayland-dev wayland-protocols
python3 -m pip install --no-cache-dir --only-binary :all: gcovr==8.3
- name: Build current OpenAL Soft
run: |
git clone --depth 1 --branch 1.24.2 https://github.com/kcat/openal-soft.git /tmp/openal-soft
cmake -S /tmp/openal-soft -B /tmp/openal-soft/build \
-DCMAKE_BUILD_TYPE=Release -DALSOFT_EXAMPLES=OFF -DALSOFT_UTILS=OFF
cmake --build /tmp/openal-soft/build -j"$(nproc)"
sudo cmake --install /tmp/openal-soft/build
sudo ldconfig
# see the Build workflow
- name: Patch GLM for GCC
run: |
sed -i 's/GLM_FUNC_QUALIFIER std::string format(const char\* message, \.\.\.)/inline std::string format(const char* message, ...)/' \
ref/glm/glm/gtx/string_cast.inl
grep -n "std::string format(const char\* message" ref/glm/glm/gtx/string_cast.inl
# unoptimised, so every line keeps its own code and the counts are those of the source
- name: Configure (CMake)
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_BETTER_RENDERER=OFF \
-DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DUSE_LTO=OFF \
-DCMAKE_CXX_FLAGS="--coverage -O0 -Wno-attributes -fno-inline-functions-called-once" \
-DPython3_EXECUTABLE="$(which python3)"
# the tests alone: the game itself isn't linked, so they aren't run by its build
- name: Build the unit tests
run: cmake --build build --target eu07_unit_tests -j"$(nproc)"
- name: Run the unit tests
run: ./build/tests/unit/eu07_unit_tests
# the game's own sources only: no submodules, no vendored code, not the tests themselves.
# betterRenderer/ is left out for its thirdparty/yaml-cpp, which every target of the game links and so builds here
- name: Coverage report
run: |
# a failure of gcovr fails the step, though its output goes through tee
set -o pipefail
mkdir -p coverage-report/html
gcovr --root . build \
--exclude 'ref/' --exclude 'imgui/' --exclude 'stb/' --exclude 'betterRenderer/' \
--exclude 'tests/' --exclude 'build/' \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--gcov-ignore-errors=no_working_dir_found \
--print-summary \
--txt coverage-report/coverage.txt \
--html-details coverage-report/html/index.html \
--sonarqube coverage-report/coverage-sonarqube.xml \
--json-summary-pretty --json-summary coverage-report/coverage-summary.json \
| tee coverage-report/summary.txt
{
echo '## Unit test coverage of the core library'
echo
echo 'GCC, unoptimised build, `eu07_unit_tests`. Lines run by the tests, per source file of the game the tests compile.'
echo
echo '```'
grep -E '^(lines|functions|branches):' coverage-report/summary.txt
echo '```'
echo
echo '<details><summary>Per file</summary>'
echo
echo '```'
cat coverage-report/coverage.txt
echo '```'
echo
echo '</details>'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload the coverage report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: unit-test-coverage
path: coverage-report
retention-days: 14
if-no-files-found: error