Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 59 additions & 51 deletions .github/actions/openvic-sim-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
name: Build OpenVic-Simulation
description: Setup and Build OpenVic-Simulation with the provided options
description: Configure, build, and test OpenVic-Simulation with CMake

inputs:
identifier:
description: Identifier of this build
description: Identifier of this build (artifact name)
required: true
target:
description: Target type to build for (template_release, template_debug, editor)
required: true
platform:
description: Platform to build for (windows, linux, macos)
preset:
description: CMake configure preset
required: true
arch:
description: Architecture to build for (x86_32, x86_64, universal)
configuration:
description: Build configuration (Debug, Release, RelWithDebInfo)
required: true
scons-flags:
description: Additional flags to send to SCons
default: 'build_ovsim_benchmarks=yes'
build-library:
description: Whether to build the library file
target:
description: Godot target flavor (template_debug, template_release, editor)
default: 'template_debug'
cmake-args:
description: Additional -D flags passed to the CMake configure step
default: ''
run-tests:
description: Whether to run the unit tests after building
default: 'true'
cache-base-branch:
description: Branch to base the cache upon
default: 'master'
disable-cache:
description: Whether to disable the build cache
default: 'false'

runs:
using: composite
steps:
- name: Setup build cache
uses: OpenVicProject/openvic-cache@master
if: ${{ inputs.disable-cache != 'true' }}
with:
cache-name: ${{ inputs.identifier }}
base-branch: ${{ inputs.cache-base-branch }}
continue-on-error: true

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"
- name: Setup MSVC environment
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
Get-ChildItem env: | ForEach-Object { Add-Content -Path $env:GITHUB_ENV -Value "$($_.Name)=$($_.Value)" }

- name: Set up SCons
- name: Setup Ninja
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons
scons --version
# Ninja is preinstalled on GitHub-hosted images; fall back to the
# image's package manager if a future image drops it.
if ! command -v ninja >/dev/null 2>&1; then
if [ "$RUNNER_OS" = "macOS" ]; then
brew install ninja
elif [ "$RUNNER_OS" = "Windows" ]; then
choco install ninja -y
else
sudo apt-get update -y && sudo apt-get install -y ninja-build
fi
fi
ninja --version

- name: Install APT dependencies
if: ${{ inputs.platform == 'linux' }}
uses: awalsh128/cache-apt-pkgs-action@681749ae568c81c2037cb9185e38b709b261bd2f # v1.6.1
if: ${{ runner.os == 'Linux' }}
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
with:
packages: build-essential pkg-config libtbb-dev

- name: Install and Set g++ to version 13
if: ${{ inputs.platform == 'linux' }}
if: ${{ runner.os == 'Linux' }}
shell: sh
run: |
g++ --version
Expand All @@ -68,29 +68,37 @@ runs:
sudo update-alternatives --set g++ /usr/bin/g++-13
g++ --version

- name: Compile with SCons
uses: OpenVicProject/openvic-build@master
with:
platform: ${{ inputs.platform }}
target: ${{ inputs.target }}
sconsflags: arch=${{ inputs.arch }} ${{ inputs.build-library && 'build_ovsim_library=yes' }} ${{ inputs.scons-flags }}
- name: Configure
shell: bash
run: |
cmake --preset ${{ inputs.preset }} \
-DGODOTCPP_TARGET=${{ inputs.target }} \
${{ inputs.cmake-args }}

- name: Delete compilation files
if: ${{ inputs.platform == 'windows' }}
shell: pwsh
- name: Build
shell: bash
run: |
CONFIG_LOWER=$(echo "${{ inputs.configuration }}" | tr '[:upper:]' '[:lower:]')
cmake --build --preset ${{ inputs.preset }}-$CONFIG_LOWER

- name: Run tests
if: ${{ inputs.run-tests == 'true' }}
shell: bash
run: |
Remove-Item bin/* -Include *.exp,*.pdb -Force
CONFIG_LOWER=$(echo "${{ inputs.configuration }}" | tr '[:upper:]' '[:lower:]')
ctest --preset ${{ inputs.preset }}-$CONFIG_LOWER

- name: Upload library artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.event.repository.name }}-${{ inputs.identifier }}-library
path: |
${{ github.workspace }}/bin/libopenvic-simulation.*
${{ github.workspace }}/out/build/${{ inputs.preset }}/bin/${{ inputs.configuration }}/libopenvic-simulation.a
${{ github.workspace }}/out/build/${{ inputs.preset }}/bin/${{ inputs.configuration }}/openvic-simulation.lib

- name: Upload executable artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.event.repository.name }}-${{ inputs.identifier }}-executable
path: |
${{ github.workspace }}/bin/openvic-simulation.headless.*
${{ github.workspace }}/out/build/${{ inputs.preset }}/bin/${{ inputs.configuration }}/openvic-simulation.headless*
17 changes: 9 additions & 8 deletions .github/changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ everything: &everything
- "**"

# Determines if build actions should occur after static checks are ran. Broadly speaking, these
# files changing would result in SCons rebuilding the engine, or are otherwise pertinent to the
# files changing would result in CMake rebuilding, or are otherwise pertinent to the
# buildsystem itself.
sources:
- .github/{actions/*,workflows}/*.yml
- "**/{SConstruct,SCsub,*.py}"
- "**/CMakeLists.txt"
- "**/*.cmake"
- "**/CMakePresets.json"
- "**/*.py"
- "**/*.{hpp,cpp,inc}"
- scripts
- deps/**
- tests/**

pre-commit:
- *everything
- '!scripts/**'
- '!deps/*/**'
- '!tests/deps/*/**'
- '!tests/benchmarks/deps/*/**'
# First-party submodules (openvic-dataloader, lexy-vdf) run their own checks.
- '!deps/openvic-dataloader/**'
- '!deps/lexy-vdf/**'

# Determines which files are appropriate for running clangd-tidy checks on.
clangd:
- "**/*.{hpp,cpp,inc}"
- "**/*.{hpp,cpp,inc}"
36 changes: 16 additions & 20 deletions .github/workflows/build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,44 @@ jobs:
- identifier: windows-debug
os: windows-latest
name: 🏁 Windows Debug
preset: windows-x64-md
configuration: Debug
target: template_debug
platform: windows
arch: x86_64
test-bin-suffix: .md.exe

- identifier: windows-release
os: windows-latest
name: 🏁 Windows Release
preset: windows-x64-md
configuration: Release
target: template_release
platform: windows
arch: x86_64
test-bin-suffix: .md.exe

- identifier: macos-debug
os: macos-latest
name: 🍎 macOS (universal) Debug
preset: macos-universal
configuration: Debug
target: template_debug
platform: macos
arch: universal

- identifier: macos-release
os: macos-latest
name: 🍎 macOS (universal) Release
preset: macos-universal
configuration: Release
target: template_release
platform: macos
arch: universal

- identifier: linux-debug
os: ubuntu-22.04
name: 🐧 Linux Debug
preset: linux-x64
configuration: Debug
target: template_debug
platform: linux
arch: x86_64

- identifier: linux-release
os: ubuntu-22.04
name: 🐧 Linux Release
preset: linux-x64
configuration: Release
target: template_release
platform: linux
arch: x86_64

steps:
- name: Checkout project
Expand All @@ -69,10 +67,8 @@ jobs:
uses: ./.github/actions/openvic-sim-build
with:
identifier: ${{ matrix.identifier }}
preset: ${{ matrix.preset }}
configuration: ${{ matrix.configuration }}
target: ${{ matrix.target }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}

- name: Run tests
run: |
./tests/bin/openvic-simulation.tests.${{ matrix.platform }}.${{ matrix.target }}.${{ matrix.arch }}${{ matrix.test-bin-suffix || '' }}
# Benchmarks are built (not run) for compile coverage.
cmake-args: -DOPENVIC_SIM_BUILD_BENCHMARKS=ON
34 changes: 15 additions & 19 deletions .github/workflows/nightly-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ jobs:
relevant_files=(
"deps/*"
"misc/*"
"scripts"
"src/*.hpp"
"src/*.cpp"
':!src/openvic-simulation/pch.hpp'
':!src/openvic-simulation/pch.cpp'
"pyproject.toml"
"SConstruct"
"CMakeLists.txt"
"CMakePresets.json"
".github/workflows/builds.yml"
".github/actions/openvic-sim-release/action.yml"
".github/workflows/nightly-releases.yml"
Expand Down Expand Up @@ -131,27 +131,21 @@ jobs:
- identifier: windows-release
os: windows-latest
name: 🏁 Windows Release
target: template_release
platform: windows
arch: x86_64
scons-flags: ''
preset: windows-x64-md
cmake-args: ''

- identifier: macos-release
os: macos-latest
name: 🍎 macOS (universal) Release
target: template_release
platform: macos
arch: universal
scons-flags: 'lto=full'
preset: macos-universal
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

- identifier: linux-release
os: ubuntu-latest
name: 🐧 Linux Release
runner: ubuntu-22.04
target: template_release
platform: linux
arch: x86_64
scons-flags: 'lto=full use_static_cpp=yes'
preset: linux-x64
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

steps:
- name: Checkout project
Expand All @@ -164,11 +158,13 @@ jobs:
uses: ./.github/actions/openvic-sim-build
with:
identifier: ${{ matrix.identifier }}
target: ${{ matrix.target }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
disable-cache: true
scons-flags: use_hot_reload=no build_ovsim_tests=no debug_symbols=yes optimize=speed_trace ${{ matrix.scons-flags }}
preset: ${{ matrix.preset }}
# Optimized build with debug symbols (the old optimize=speed_trace
# debug_symbols=yes flavor).
configuration: RelWithDebInfo
target: template_release
run-tests: false
cmake-args: -DOPENVIC_SIM_BUILD_TESTS=OFF ${{ matrix.cmake-args }}

publish-nightly-release:
name: Publish Release
Expand Down
28 changes: 11 additions & 17 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,21 @@ jobs:
- identifier: windows-release
os: windows-latest
name: 🏁 Build Windows
target: template_release
platform: windows
arch: x86_64
scons-flags: ''
preset: windows-x64-md
cmake-args: ''

- identifier: macos-release
os: macos-latest
name: 🍎 Build macOS
target: template_release
platform: macos
arch: universal
scons-flags: lto=full
preset: macos-universal
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

- identifier: linux-release
os: ubuntu-latest
name: 🐧 Build Linux
runner: ubuntu-22.04
target: template_release
platform: linux
arch: x86_64
scons-flags: lto=full use_static_cpp=yes
preset: linux-x64
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

steps:
- name: Checkout project
Expand All @@ -93,11 +87,11 @@ jobs:
uses: ./.github/actions/openvic-sim-build
with:
identifier: ${{ matrix.identifier }}
target: ${{ matrix.target }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
disable-cache: true
scons-flags: use_hot_reload=no build_ovsim_tests=no ${{ matrix.scons-flags }}
preset: ${{ matrix.preset }}
configuration: Release
target: template_release
run-tests: false
cmake-args: -DOPENVIC_SIM_BUILD_TESTS=OFF ${{ matrix.cmake-args }}

publish-release:
name: Publish Release
Expand Down
Loading