From 1d3cea6b2e8784d3715bd23461cb77b12bdb7684 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 11 Jan 2024 20:16:00 +0100 Subject: [PATCH] GHA: Add Windows & macOS builds to GDExtension workflow Also, don't run test builds when doc change in a PR --- .github/workflows/gdextension.yml | 209 ++++++++++++++++++++++++ .github/workflows/gdextension_linux.yml | 140 ---------------- .github/workflows/test_builds.yml | 14 +- gdextension/SConstruct | 2 +- gdextension/limboai.gdextension | 2 +- gdextension/setup_gdextension.sh | 21 +-- 6 files changed, 230 insertions(+), 158 deletions(-) create mode 100644 .github/workflows/gdextension.yml delete mode 100644 .github/workflows/gdextension_linux.yml diff --git a/.github/workflows/gdextension.yml b/.github/workflows/gdextension.yml new file mode 100644 index 0000000..bb82542 --- /dev/null +++ b/.github/workflows/gdextension.yml @@ -0,0 +1,209 @@ +name: 🔌 GDExtension +on: + workflow_call: + inputs: + godot-cpp-treeish: + description: A tag, branch or commit hash in the godot-cpp repository. + type: string + default: 4.2 + limboai-treeish: + description: A tag, branch or commit hash in the LimboAI repository. + type: string + default: master + test-build: + description: Should we perform only a limited number of test builds? + type: boolean + default: false + + workflow_dispatch: + inputs: + godot-cpp-treeish: + description: A tag, branch or commit hash in the godot-cpp repository. + type: string + default: 4.2 + limboai-treeish: + description: A tag, branch or commit hash in the LimboAI repository. + type: string + default: master + test-build: + description: Should we perform only a limited number of test builds? + type: boolean + default: false + +# Global Settings +env: + SCONS_CACHE_LIMIT: 4096 + SCONSFLAGS: dev_build=no debug_symbols=no + +jobs: + gdextension: + runs-on: ${{ matrix.opts.runner }} + name: ${{ matrix.opts.name }} + strategy: + fail-fast: false + matrix: + opts: + - name: 🐧 Linux (x86_64, release) + runner: ubuntu-20.04 + platform: linux + target: template_release + arch: x86_64 + should-build: true + + - name: 🐧 Linux (x86_64, debug) + runner: ubuntu-20.04 + platform: linux + target: editor + arch: x86_64 + should-build: true + + - name: 🪟 Windows (x86_64, release) + runner: windows-latest + platform: windows + target: template_release + arch: x86_64 + should-build: true + + - name: 🪟 Windows (x86_64, debug) + runner: windows-latest + platform: windows + target: editor + arch: x86_64 + should-build: true + + - name: 🍎 macOS (universal, release) + runner: macos-latest + platform: macos + target: template_release + arch: universal + should-build: true + + - name: 🍎 macOS (universal, debug) + runner: macos-latest + platform: macos + target: editor + arch: universal + should-build: true + + exclude: + - { opts: {should-build: false }} + + env: + BIN: liblimboai.${{matrix.opts.platform}}.${{matrix.opts.target}}.${{matrix.opts.arch}} + + steps: + - name: Clone godot-cpp + uses: actions/checkout@v4 + with: + repository: godotengine/godot-cpp + fetch-tags: true + path: godot-cpp + ref: ${{ inputs.godot-cpp-treeish }} + + - name: Clone LimboAI module + uses: actions/checkout@v4 + with: + path: limboai + fetch-tags: true + ref: ${{ inputs.limboai-treeish }} + + # Inits GDEXTENSION_VERSION, LIMBOAI_VERSION and NAME_PREFIX environment variables. + - uses: ./limboai/.github/actions/init-version-gdext + + - name: Set up Linux buildroot x86_64 + if: matrix.opts.platform == 'linux' && matrix.opts.arch == 'x86_64' + run: | + wget https://download.tuxfamily.org/godotengine/toolchains/linux/x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2 + tar -xjf x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2 + mv x86_64-godot-linux-gnu_sdk-buildroot buildroot + cd buildroot + ./relocate-sdk.sh + cd .. + + - name: Set up Linux buildroot x86_32 + if: matrix.opts.platform == 'linux' && matrix.opts.arch == 'x86_32' + run: | + wget https://download.tuxfamily.org/godotengine/toolchains/linux/i686-godot-linux-gnu_sdk-buildroot.tar.bz2 + tar -xjf i686-godot-linux-gnu_sdk-buildroot.tar.bz2 + mv i686-godot-linux-gnu_sdk-buildroot buildroot + cd buildroot + ./relocate-sdk.sh + cd .. + + - name: Set up Python 3.x + if: matrix.opts.platform == 'windows' || matrix.opts.platform == 'macos' + uses: actions/setup-python@v4 + with: + python-version: '3.x' + architecture: 'x64' + + - name: Set up scons + if: matrix.opts.platform == 'windows' || matrix.opts.platform == 'macos' + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons==4.4.0 + python --version + scons --version + + - name: Set up MSVC problem matcher on Windows + if: matrix.opts.platform == 'windows' + uses: ammaraskar/msvc-problem-matcher@master + + - name: Set up scons cache + uses: actions/cache@v3 + with: + path: ${{github.workspace}}/.scons_cache/ + key: ${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}} + restore-keys: | + ${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}} + ${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}} + ${{env.BIN}}-${{inputs.godot-cpp-treeish}} + + - name: Setup project structure for GDExtension + shell: bash + run: | + python ./limboai/gdextension/update_icons.py + mkdir -p demo/addons/limboai/bin + mv limboai/icons demo/addons/limboai/ + cp limboai/gdextension/SConstruct SConstruct + cp limboai/gdextension/limboai.gdextension demo/addons/limboai/bin + echo "---" + ls -l + ls -l -R ./demo/ + + - name: Compilation + shell: bash + env: + SCONS_CACHE: ${{github.workspace}}/.scons_cache/ + run: | + PATH=${GITHUB_WORKSPACE}/buildroot/bin:$PATH + scons platform=${{matrix.opts.platform}} target=${{matrix.opts.target}} arch=${{matrix.opts.arch}} ${{env.SCONSFLAGS}} + + - name: Prepare artifact + shell: bash + run: | + mkdir out + mv demo/addons/ out/ + rm -f out/addons/limboai/bin/*.{exp,lib,pdb} + ls -R out/ + + - name: Strip lib + if: matrix.opts.platform != 'windows' + run: | + ls -l -R out/addons/limboai/bin/ + echo "---" + if [ "$RUNNER_OS" == "macOS" ]; then + strip -u out/addons/limboai/bin/liblimboai*/liblimboai* + else + strip out/addons/limboai/bin/liblimboai* + fi + echo "---" + ls -l -R out/addons/limboai/bin/ + + - name: Upload artifact + uses: actions/upload-artifact@v3 + env: + NAME: ${{env.NAME_PREFIX}} + with: + name: ${{ env.NAME }} + path: out/* diff --git a/.github/workflows/gdextension_linux.yml b/.github/workflows/gdextension_linux.yml deleted file mode 100644 index 4977a1e..0000000 --- a/.github/workflows/gdextension_linux.yml +++ /dev/null @@ -1,140 +0,0 @@ -name: 🐧 Linux GDExtension builds -on: - workflow_call: - inputs: - godot-cpp-version: - description: Ref in the godot-cpp repository. - type: string - default: 4.2 - limboai-treeish: - description: A tag, branch or commit hash in the LimboAI repository. - type: string - default: master - # test-build: - # description: Should we perform only a limited number of test builds? - # type: boolean - # default: false - - workflow_dispatch: - inputs: - godot-cpp-version: - description: Ref in the godot-cpp repository. - type: string - default: 4.2 - limboai-treeish: - description: A tag, branch or commit hash in the LimboAI repository. - type: string - default: master - # test-build: - # description: Should we perform only a limited number of test builds? - # type: boolean - # default: false - -# Global Settings -env: - SCONS_CACHE_LIMIT: 4096 - SCONSFLAGS: dev_build=no debug_symbols=no symbol_visibility=auto - -jobs: - gdextension-linux: - runs-on: "ubuntu-20.04" - name: ${{ matrix.opts.name }} - strategy: - fail-fast: false - matrix: - opts: - - name: GDExtension (x86_64, release) - target: template_release - arch: x86_64 - should-build: true - - - name: GDExtension (x86_64, debug) - target: editor - arch: x86_64 - should-build: true - - exclude: - - { opts: {should-build: false }} - - env: - BIN: liblimboai.linux.${{matrix.opts.target}}.${{matrix.opts.arch}} - - steps: - - name: Clone godot-cpp - uses: actions/checkout@v4 - with: - repository: godotengine/godot-cpp - fetch-tags: true - path: godot-cpp - ref: ${{ inputs.godot-cpp-version }} - - - name: Clone LimboAI module - uses: actions/checkout@v4 - with: - path: limboai - ref: ${{ inputs.limboai-treeish }} - - # Inits GODOT_VERSION, LIMBOAI_VERSION and NAME_PREFIX environment variables. - - uses: ./limboai/.github/actions/init-version-gdext - - # About sed see: https://github.com/godotengine/buildroot/issues/6 - - name: Set up buildroot x86_64 - if: matrix.opts.arch == 'x86_64' - run: | - wget https://download.tuxfamily.org/godotengine/toolchains/linux/x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2 - tar -xjf x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2 - mv x86_64-godot-linux-gnu_sdk-buildroot buildroot - cd buildroot - sed -i x86_64-godot-linux-gnu/sysroot/usr/lib/pkgconfig/dbus-1.pc -e "s@/lib@/lib64@g" - ./relocate-sdk.sh - cd .. - - - name: Set up buildroot x86_32 - if: matrix.opts.arch == 'x86_32' - run: | - wget https://download.tuxfamily.org/godotengine/toolchains/linux/i686-godot-linux-gnu_sdk-buildroot.tar.bz2 - tar -xjf i686-godot-linux-gnu_sdk-buildroot.tar.bz2 - mv i686-godot-linux-gnu_sdk-buildroot buildroot - cd buildroot - ./relocate-sdk.sh - cd .. - - - name: Set up scons cache - uses: actions/cache@v3 - with: - path: ${{github.workspace}}/.scons_cache/ - key: ${{env.BIN}}-${{inputs.godot-cpp-version}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}} - restore-keys: | - ${{env.BIN}}-${{inputs.godot-cpp-version}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}} - ${{env.BIN}}-${{inputs.godot-cpp-version}}-${{inputs.limboai-treeish}} - ${{env.BIN}}-${{inputs.godot-cpp-version}} - - - name: Setup project structure for GDExtension - shell: bash - run: | - bash ./limboai/gdextension/setup_gdextension.sh - ls - ls -R demo/ - - - name: Compilation - env: - SCONS_CACHE: ${{github.workspace}}/.scons_cache/ - run: | - PATH=${GITHUB_WORKSPACE}/buildroot/bin:$PATH - scons platform=linux target=${{matrix.opts.target}} arch=${{matrix.opts.arch}} ${{env.SCONSFLAGS}} - - - name: Prepare artifact - run: | - mkdir -p out/ - cp -r --dereference demo/addons/ out/ - strip out/addons/limboai/bin/liblimboai* - chmod +x out/addons/limboai/bin/liblimboai* - ls -R out/ - - - name: Upload artifact - uses: actions/upload-artifact@v3 - env: - NAME: ${{env.NAME_PREFIX}} - with: - name: ${{ env.NAME }} - path: out/* diff --git a/.github/workflows/test_builds.yml b/.github/workflows/test_builds.yml index 353c757..5569c30 100644 --- a/.github/workflows/test_builds.yml +++ b/.github/workflows/test_builds.yml @@ -27,6 +27,7 @@ on: - "LICENSE" - "**/*.png" - "demo/*" + - "doc/*" inputs: godot-treeish: description: A tag, branch or commit hash in the Godot repository. @@ -116,7 +117,7 @@ jobs: bin/${{ env.BIN }} --test --headless linux-test-build: - name: 🐧 Linux test build + name: 🐧 Linux uses: ./.github/workflows/linux.yml with: godot-treeish: ${{ inputs.godot-treeish }} @@ -124,7 +125,7 @@ jobs: test-build: true windows-test-build: - name: 🪟 Windows test build + name: 🪟 Windows uses: ./.github/workflows/windows.yml with: godot-treeish: ${{ inputs.godot-treeish }} @@ -132,7 +133,7 @@ jobs: test-build: true macos-test-build: - name: 🍎 macOS test build + name: 🍎 macOS uses: ./.github/workflows/macos.yml with: godot-treeish: ${{ inputs.godot-treeish }} @@ -140,8 +141,9 @@ jobs: test-build: true gdextension: - name: 🔌 GDExtension test build - uses: ./.github/workflows/gdextension_linux.yml + name: 🔌 GDExtension + uses: ./.github/workflows/gdextension.yml with: - godot-cpp-version: 4.2 + godot-cpp-treeish: 4.2 limboai-treeish: ${{ github.sha }} + test-build: true diff --git a/gdextension/SConstruct b/gdextension/SConstruct index 17e3eba..3d1217e 100644 --- a/gdextension/SConstruct +++ b/gdextension/SConstruct @@ -34,7 +34,7 @@ sources += (Glob("limboai/util/*.cpp")) if env["platform"] == "macos": library = env.SharedLibrary( - "demo/addons/limboai/liblimboai.{}.{}.framework/liblimboai.{}.{}".format( + "demo/addons/limboai/bin/liblimboai.{}.{}.framework/liblimboai.{}.{}".format( env["platform"], env["target"], env["platform"], env["target"] ), source=sources, diff --git a/gdextension/limboai.gdextension b/gdextension/limboai.gdextension index 567ddc8..c71edd6 100644 --- a/gdextension/limboai.gdextension +++ b/gdextension/limboai.gdextension @@ -11,7 +11,7 @@ windows.debug.x86_32 = "res://addons/limboai/bin/liblimboai.windows.editor.x86_3 windows.release.x86_32 = "res://addons/limboai/bin/liblimboai.windows.template_release.x86_32.dll" windows.debug.x86_64 = "res://addons/limboai/bin/liblimboai.windows.editor.x86_64.dll" windows.release.x86_64 = "res://addons/limboai/bin/liblimboai.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://addons/limboai/bin/liblimboai.linux.editor.dev.x86_64.so" +linux.debug.x86_64 = "res://addons/limboai/bin/liblimboai.linux.editor.x86_64.so" linux.release.x86_64 = "res://addons/limboai/bin/liblimboai.linux.template_release.x86_64.so" linux.debug.arm64 = "res://addons/limboai/bin/liblimboai.linux.editor.arm64.so" linux.release.arm64 = "res://addons/limboai/bin/liblimboai.linux.template_release.arm64.so" diff --git a/gdextension/setup_gdextension.sh b/gdextension/setup_gdextension.sh index 4c5787e..480d07b 100755 --- a/gdextension/setup_gdextension.sh +++ b/gdextension/setup_gdextension.sh @@ -88,21 +88,22 @@ fi # exit 2 # fi -if [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then - mkdir -p demo/addons/limboai/bin/ - # cp limboai/gdextension/limboai.gdextension demo/addons/limboai/bin/limboai.gdextension - pushd demo/addons/limboai/bin/ > /dev/null - ln -s ../../../../gdextension/limboai.gdextension limboai.gdextension - popd > /dev/null +if [ ! -e "${PWD}/limboai/demo/addons/limboai/bin/limboai.gdextension" ]; then + ls -l + mkdir -p ./limboai/demo/addons/limboai/bin/ + cd ./limboai/demo/addons/limboai/bin/ + ln -s ../../../../gdextension/limboai.gdextension limboai.gdextension || ln -s ../../../../limboai/gdextension/limboai.gdextension limboai.gdextension + ls -l + cd - highlight -- Linked limboai.gdextension. else highlight -- Skipping limboai.gdextension. File already exists! fi -if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then - pushd demo/addons/limboai/ > /dev/null - ln -s ../../../icons icons - popd > /dev/null +if [ ! -e "${PWD}/limboai/demo/addons/limboai/icons/" ]; then + cd ./limboai/demo/addons/limboai/ + ln -s ../../../icons icons || ln -s ../../../limboai/icons icons + cd - highlight -- Linked icons. else highlight -- Skipping linking icons. File already exists!