Skip to content

samples version of the game engine now in tutorial. #2

samples version of the game engine now in tutorial.

samples version of the game engine now in tutorial. #2

name: SimpleEngine CI
on:
push:
paths:
- 'attachments/simple_engine/**'
- '.github/workflows/simple_engine_ci.yml'
pull_request:
paths:
- 'attachments/simple_engine/**'
- '.github/workflows/simple_engine_ci.yml'
workflow_dispatch:
jobs:
desktop:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
defaults:
run:
working-directory: attachments/simple_engine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up MSVC dev environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Set up Ninja
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-ninja@v5
- name: Install Vulkan SDK (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
throw "Chocolatey is required on windows-latest runners"
}
if (Test-Path "C:\VulkanSDK") {
Write-Host "Using existing Vulkan SDK at C:\VulkanSDK"
} else {
Write-Host "Downloading Vulkan SDK installer..."
choco install -y aria2
$installer = Join-Path $env:TEMP "vulkan-sdk.exe"
aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe"
Write-Host "Installing Vulkan SDK (silent, default feature set)..."
# NOTE: Do not pass --components here. LunarG has changed component IDs over time,
# and specifying them can cause 'Component(s) not found' failures.
Start-Process -FilePath $installer -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow
}
$vulkanPath = ""
if (Test-Path "C:\VulkanSDK") {
$vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName
}
if (-not $vulkanPath) {
throw "Vulkan SDK not found after install"
}
"VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Vulkan SDK (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y wget gnupg ca-certificates
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
# Pick the correct LunarG repo list for the runner's Ubuntu codename.
codename=""
if [ -f /etc/os-release ]; then
. /etc/os-release
codename="${VERSION_CODENAME:-}"
fi
if [ -z "$codename" ] && command -v lsb_release >/dev/null 2>&1; then
codename="$(lsb_release -sc)"
fi
if [ -z "$codename" ]; then
codename="jammy"
fi
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
if ! sudo wget -qO "$listPath" "$listUrl"; then
echo "Warning: failed to fetch ${listUrl}; falling back to jammy list"
codename="jammy"
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
sudo wget -qO "$listPath" "$listUrl"
fi
sudo apt-get update
sudo apt-get install -y vulkan-sdk
# We configure with Ninja on Linux; ensure it's available.
sudo apt-get install -y ninja-build
# Use the engine's dependency install scripts instead of calling vcpkg directly in CI.
- name: Bootstrap vcpkg (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg"
if (-not (Test-Path $vcpkgRoot)) {
git clone https://github.com/microsoft/vcpkg $vcpkgRoot
}
Push-Location $vcpkgRoot
.\bootstrap-vcpkg.bat
Pop-Location
"VCPKG_INSTALLATION_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"$vcpkgRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
call install_dependencies_windows.bat
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
chmod +x ./install_dependencies_linux.sh
./install_dependencies_linux.sh
- name: Configure (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: >
cmake -S . -B build -G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE"
- name: Configure (Linux)
if: runner.os == 'Linux'
shell: bash
run: >
cmake -S . -B build -G Ninja
-DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --target SimpleEngine --parallel 4
- name: Test
run: ctest --test-dir build --output-on-failure