Project updates and compilation fixes #940
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] | |
jobs: | |
Windows-Build: | |
runs-on: windows-latest | |
env: | |
# Path to the solution file relative to the root of the project. | |
SOLUTION_FILE_PATH: .\DarkRadiant.sln | |
TESTS_FILE_PATH: .\install\Tests.exe | |
BUILD_CONFIGURATION: Release | |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Inject commit hash in version.h Header | |
env: | |
VERSION_HEADER_FILE: include\version.h | |
SHA: ${{github.sha}} | |
run: | | |
$sha = $env:SHA.Substring(0, 7) | |
Write-Host "Writing $sha to $env:VERSION_HEADER_FILE" | |
$replaced = Get-Content $env:VERSION_HEADER_FILE | % { if ($_ -match '#define RADIANT_VERSION "((\d+.\d+.\d+)([\w\d]*))"') { $_.Replace($matches[1], $matches[2] + "_rev$sha") } else { $_ } }; | |
$replaced | Out-File $env:VERSION_HEADER_FILE | |
shell: powershell | |
- name: Add MSBuild to PATH | |
uses: microsoft/setup-msbuild@v1 | |
- name: Restore NuGet packages | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: nuget restore ${{env.SOLUTION_FILE_PATH}} | |
- name: Build | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=x64 /maxcpucount:4 /nodeReuse:false /p:UseSharedConfiguration=false ${{env.SOLUTION_FILE_PATH}} | |
- name: Install Mesa openGL Drivers | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
env: | |
UNIT_TEST_MESA_DRIVER_URL: https://github.com/codereader/DarkRadiant_WinDeps/releases/download/3.0.0/unit_test_mesa_driver-x64-20.1.8.7z | |
run: | | |
Write-Host ("Downloading Mesa driver package from {0}..." -f $env:UNIT_TEST_MESA_DRIVER_URL) | |
$outFile = ".\install\unit_test_mesa_driver-x64.7z" | |
Invoke-WebRequest $env:UNIT_TEST_MESA_DRIVER_URL -OutFile $outFile | |
Write-Host ("Unpacking {0}..." -f $outFile) | |
& .\tools\7z\7za.exe x $outFile -o".\install\" | |
Get-ChildItem .\install\OpenGL32.dll | |
shell: powershell | |
- name: Setup VSTest.console.exe | |
uses: darenm/[email protected] | |
- name: Run Unit Tests | |
run: | | |
FOR /F "tokens=* USEBACKQ" %%g IN (`powershell -Command "(Get-ChildItem -Recurse -Path 'C:\Program Files\Microsoft Visual Studio\' -Filter "GoogleTestAdapter.TestAdapter.dll" -ErrorAction SilentlyContinue).DirectoryName"`) do (SET "GTEST_ADAPTER_PATH=%%g") | |
echo Test Adapter Path resolved to: %GTEST_ADAPTER_PATH% | |
vstest.console.exe ${{env.TESTS_FILE_PATH}} /Platform:x64 /Logger:trx /TestAdapterPath:"%%GTEST_ADAPTER_PATH%%" | |
shell: cmd | |
- name: Generate Portable Package | |
run: | | |
echo Remove Mesa driver from output folder again | |
del ..\..\install\OpenGL32.dll | |
powershell -ExecutionPolicy ByPass .\compile_release_package.ps1 -Platform x64 -SkipBuild -GenerateSetupPackage:$false -GeneratePortablePackage:$false -OutputFolder ..\..\PortablePackage\ | |
shell: cmd | |
working-directory: .\tools\scripts | |
- name: Upload Portable Package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: darkradiant-portable-package-x64 | |
path: | | |
tools/scripts/DarkRadiant_install.x64/**/* | |
!tools/scripts/DarkRadiant_install.x64/**/*.pdb | |
- name: Upload Portable Package PDBs | |
uses: actions/upload-artifact@v3 | |
with: | |
name: darkradiant-pdb-files-x64 | |
path: | | |
tools/scripts/DarkRadiant_install.x64/**/*.pdb | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-test-results | |
path: TestResults\*.trx | |
Linux-Build: | |
runs-on: ubuntu-latest | |
env: | |
BUILD_TYPE: Release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Package Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -yq gettext pkg-config zlib1g-dev libjpeg-dev libxml2-dev libsigc++-2.0-dev | |
sudo apt-get install -yq libgtest-dev libeigen3-dev libwxgtk3.0-gtk3-dev libpng-dev | |
sudo apt-get install -yq libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev libgit2-dev | |
- name: Configure CMake | |
# Use a bash shell so we can use the same syntax for environment variable | |
# access regardless of the host operating system | |
shell: bash | |
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install | |
- name: Build | |
env: | |
CMAKE_BUILD_PARALLEL_LEVEL: 3 | |
CTEST_OUTPUT_ON_FAILURE: ON | |
shell: bash | |
run: cmake --build . --config $BUILD_TYPE --target install |