From ef82ae3aeb835290671f09ce12fabae25f914396 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Sun, 18 Feb 2024 13:55:01 +0100 Subject: [PATCH] Add GitHub Actions build workflows --- .github/workflows/build_linux.yml | 51 +++++++++++++++++ .github/workflows/build_macos.yml | 85 +++++++++++++++++++++++++++++ .github/workflows/build_windows.yml | 48 ++++++++++++++++ source/CMakeLists.txt | 7 ++- source/extern/CMakeLists.txt | 1 + source/test/CMakeLists.txt | 3 + source/vcpkg-configuration.json | 8 +++ source/vcpkg.json | 11 ++++ 8 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_linux.yml create mode 100644 .github/workflows/build_macos.yml create mode 100644 .github/workflows/build_windows.yml create mode 100644 source/vcpkg-configuration.json create mode 100644 source/vcpkg.json diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml new file mode 100644 index 0000000..dd64b8f --- /dev/null +++ b/.github/workflows/build_linux.yml @@ -0,0 +1,51 @@ +name: Ubuntu Linux + +on: + push: + branches: + - "*" + tags: + - "*" + + pull_request: + branches: + - "*" + +jobs: + build: + name: OpenStarbound Linux x86_64 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install Packages + run: | + sudo apt-get update + sudo apt-get install -y libgl1-mesa-dev mesa-common-dev libsdl2-dev libglew-dev libvorbis-dev libogg-dev libz3-dev libpng-dev libfreetype-dev libgtest-dev libgmock-dev ninja-build + + - name: Configure Test Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-debug" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES -DCMAKE_BUILD_TYPE=Debug + + - name: Build Debug + run: cmake --build "${{ github.workspace }}/cmake-build-debug" --parallel + + - name: Run Unit Tests + run: ctest --test-dir "${{ github.workspace }}/cmake-build-debug" -L 'NoAssets' --verbose + + - name: Cleanup Test Build + run: rm -Rf "${{ github.workspace }}/cmake-build-debug" "${{ github.workspace }}/dist" + + - name: Configure Release Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-release" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=NO -DCMAKE_BUILD_TYPE=Release + + - name: Build Release + run: cmake --build "${{ github.workspace }}/cmake-build-release" --parallel + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Dev-Linux-x86_64 + path: dist/* diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml new file mode 100644 index 0000000..f6031fe --- /dev/null +++ b/.github/workflows/build_macos.yml @@ -0,0 +1,85 @@ +name: macOS + +on: + push: + branches: + - "*" + tags: + - "*" + + pull_request: + branches: + - "*" + +jobs: + build-intel: + name: OpenStarbound macOS x86_64 + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install Packages + run: brew install sdl2 glew libvorbis lzlib libpng freetype ninja + + - name: Configure Test Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-debug" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES -DCMAKE_BUILD_TYPE=Debug + + - name: Build Debug + run: cmake --build "${{ github.workspace }}/cmake-build-debug" --parallel + + - name: Run Unit Tests + run: ctest --test-dir "${{ github.workspace }}/cmake-build-debug" -L 'NoAssets' --verbose + + - name: Cleanup Test Build + run: rm -Rf "${{ github.workspace }}/cmake-build-debug" "${{ github.workspace }}/dist" + + - name: Configure Release Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-release" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=NO -DCMAKE_BUILD_TYPE=Release + + - name: Build Release + run: cmake --build "${{ github.workspace }}/cmake-build-release" --parallel + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Dev-macOS-Intel + path: dist/* + + build-arm: + name: OpenStarbound macOS arm64 + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install Packages + run: brew install sdl2 glew libvorbis lzlib libpng freetype ninja + + - name: Configure Test Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-debug" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES -DCMAKE_BUILD_TYPE=Debug + + - name: Build Debug + run: cmake --build "${{ github.workspace }}/cmake-build-debug" --config "Debug" --parallel + + - name: Run Unit Tests + run: ctest --test-dir "${{ github.workspace }}/cmake-build-debug" -L 'NoAssets' --verbose --build-config "Debug" + + - name: Cleanup Test Build + run: rm -Rf "${{ github.workspace }}/cmake-build-debug" "${{ github.workspace }}/dist" + + - name: Configure Release Build + run: cmake -G "Ninja" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-release" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES -DCMAKE_BUILD_TYPE=Release + + - name: Build Release + run: cmake --build "${{ github.workspace }}/cmake-build-release" --parallel + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Dev-macOS-Silicon + path: dist/* \ No newline at end of file diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml new file mode 100644 index 0000000..ad92d65 --- /dev/null +++ b/.github/workflows/build_windows.yml @@ -0,0 +1,48 @@ +name: Windows + +on: + push: + branches: + - "*" + tags: + - "*" + + pull_request: + branches: + - "*" + +jobs: + build: + name: OpenStarbound Windows x86_64 + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Configure Test Build + run: cmake -G "Visual Studio 17 2022" -A "X64" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-debug" -DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>DLL" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES + + - name: Build Debug + run: cmake --build "${{ github.workspace }}/cmake-build-debug" --config "Debug" --parallel + + - name: Run Unit Tests + run: ctest --test-dir "${{ github.workspace }}/cmake-build-debug" -L 'NoAssets' --verbose --build-config "Debug" + + - name: Cleanup Test Build + run: | + Remove-Item "${{ github.workspace }}\cmake-build-debug" -Recurse + Remove-Item "${{ github.workspace }}\dist" -Recurse + + - name: Configure Release Build + run: cmake -G "Visual Studio 17 2022" -A "X64" -S "${{ github.workspace }}/source" -B "${{ github.workspace }}/cmake-build-release" -DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>DLL" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" -DCMAKE_VERBOSE_MAKEFILE=YES -DBUILD_TESTING=YES + + - name: Build Release + run: cmake --build "${{ github.workspace }}/cmake-build-release" --config "Release" --parallel + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Dev-Windows-x64 + path: dist/* diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 18f3c45..5ff8eb5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -509,8 +509,11 @@ SET (STAR_GAME_INCLUDES ADD_SUBDIRECTORY (game) # Googletest based tests -ENABLE_TESTING() -ADD_SUBDIRECTORY (test) +OPTION (BUILD_TESTING "Build test projects" OFF) +IF (BUILD_TESTING) + ENABLE_TESTING() + ADD_SUBDIRECTORY (test) +ENDIF() # Starbound stand-alone server. ADD_SUBDIRECTORY (server) diff --git a/source/extern/CMakeLists.txt b/source/extern/CMakeLists.txt index bc57870..624b837 100644 --- a/source/extern/CMakeLists.txt +++ b/source/extern/CMakeLists.txt @@ -9,6 +9,7 @@ SET (OPUS_FLOAT_APPROX ON) SET (OPUS_STACK_PROTECTOR OFF) SET (OPUS_NONTHREADSAFE_PSEUDOSTACK OFF) SET (OPUS_USE_ALLOCA ON) +SET (BUILD_TESTING OFF) # Skip Opus tests, these won't build because the tests don't honor OPUS_FLOAT_APPROX. ADD_SUBDIRECTORY (opus) IF (OPUS_NONTHREADSAFE_PSEUDOSTACK) diff --git a/source/test/CMakeLists.txt b/source/test/CMakeLists.txt index fdbea13..9c32a4f 100644 --- a/source/test/CMakeLists.txt +++ b/source/test/CMakeLists.txt @@ -83,3 +83,6 @@ ADD_EXECUTABLE (game_tests ${star_game_tests_SOURCES}) TARGET_LINK_LIBRARIES (game_tests ${STAR_EXT_LIBS}) ADD_TEST (NAME game_tests WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/game_tests) + +SET_TESTS_PROPERTIES(core_tests PROPERTIES + LABELS "NoAssets") diff --git a/source/vcpkg-configuration.json b/source/vcpkg-configuration.json new file mode 100644 index 0000000..a11399f --- /dev/null +++ b/source/vcpkg-configuration.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", + "default-registry": { + "kind": "git", + "baseline": "638b1588be3a265a9c7ad5b212cef72a1cad336a", + "repository": "https://github.com/microsoft/vcpkg" + } +} \ No newline at end of file diff --git a/source/vcpkg.json b/source/vcpkg.json new file mode 100644 index 0000000..7b396a2 --- /dev/null +++ b/source/vcpkg.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "dependencies": [ + "glew", + "sdl2", + "libvorbis", + "zlib", + "freetype", + "libpng" + ] +} \ No newline at end of file