OverviewFilesCommitsIssuesDocsReleasesPeers

nvidia-rtx-godot / .github / workflows / linux_builds.yml

299 lines · yaml ref:
name: 🐧 Linux Builds
on:
  workflow_call:
    inputs:
      changed-files:
        description: A list of changed files, pre-filtered for parsing by clangd-tidy.
        required: true
        type: string
  workflow_dispatch:

# Global Settings
env:
  SCONS_FLAGS: >-
    dev_mode=yes
    module_text_server_fb_enabled=yes
  GODOT_CPP_BRANCH: 4.5
  DOTNET_NOLOGO: true
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  ASAN_OPTIONS: color=always:print_suppressions=1:suppressions=${{ github.workspace }}/misc/error_suppressions/asan.txt
  LSAN_OPTIONS: color=always:print_suppressions=1:suppressions=${{ github.workspace }}/misc/error_suppressions/lsan.txt
  TSAN_OPTIONS: color=always:print_suppressions=1:suppressions=${{ github.workspace }}/misc/error_suppressions/tsan.txt
  UBSAN_OPTIONS: color=always:print_suppressions=1:suppressions=${{ github.workspace }}/misc/error_suppressions/ubsan.txt

jobs:
  build-linux:
    # Stay one LTS before latest to increase portability of Linux artifacts.
    runs-on: ubuntu-22.04
    name: ${{ matrix.name }}
    timeout-minutes: 120
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: Editor w/ Mono (target=editor)
            cache-name: linux-editor-mono
            target: editor
            scons-flags: module_mono_enabled=yes compiledb=yes
            bin: ./bin/godot.linuxbsd.editor.x86_64.mono
            build-mono: true
            doc-test: true
            proj-conv: true
            proj-export: true
            api-compat: true
            artifact: true
            # Validate godot-cpp compatibility on one arbitrary editor build.
            godot-cpp: true
            clangd-tidy: true

          - name: Editor with doubles and GCC sanitizers (target=editor, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=mold)
            cache-name: linux-editor-double-sanitizers
            target: editor
            # Debug symbols disabled as they're huge on this build and we hit the 14 GB limit for runners.
            scons-flags: >-
              dev_build=yes
              scu_build=yes
              debug_symbols=no
              precision=double
              use_asan=yes
              use_ubsan=yes
              linker=mold
            bin: ./bin/godot.linuxbsd.editor.dev.double.x86_64.san
            proj-test: true

          - name: Editor with clang sanitizers (target=editor, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)
            cache-name: linux-editor-llvm-sanitizers
            target: editor
            scons-flags: >-
              dev_build=yes
              use_asan=yes
              use_ubsan=yes
              use_llvm=yes
              linker=lld
            bin: ./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san
            # Test our oldest supported SCons/Python versions on one arbitrary editor build.
            legacy-scons: true

          - name: Editor with ThreadSanitizer (target=editor, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)
            cache-name: linux-editor-thread-sanitizer
            target: editor
            scons-flags: >-
              dev_build=yes
              use_tsan=yes
              use_llvm=yes
              linker=lld
            bin: ./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san

          - name: Template w/ Mono, release (target=template_release)
            cache-name: linux-template-mono
            target: template_release
            scons-flags: module_mono_enabled=yes
            bin: ./bin/godot.linuxbsd.template_release.x86_64.mono
            artifact: true

          - name: Template w/ Mono, debug (target=template_debug)
            cache-name: linux-template-mono-debug
            target: template_debug
            scons-flags: module_mono_enabled=yes
            bin: ./bin/godot.linuxbsd.template_debug.x86_64.mono
            artifact: true

          - name: Minimal template (target=template_release, everything disabled)
            cache-name: linux-template-minimal
            target: template_release
            scons-flags: >-
              modules_enabled_by_default=no
              module_text_server_fb_enabled=no
              disable_3d=yes
              disable_advanced_gui=yes
              disable_physics_2d=yes
              disable_physics_3d=yes
              deprecated=no
              minizip=no
              brotli=no
            bin: ./bin/godot.linuxbsd.template_release.x86_64
            artifact: true

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          submodules: recursive

      - name: Setup dependencies
        run: |
          sudo apt-get update
          sudo apt-get install libwayland-bin  # TODO: Figure out somehow how to embed this one.
          if [ "${{ matrix.proj-test }}" == "true" -o "${{ matrix.proj-export }}" == "true" ]; then
            sudo apt-get install mesa-vulkan-drivers
          fi

      - name: Free disk space on runner
        run: |
          echo "Disk usage before:" && df -h
          sudo rm -rf /usr/local/lib/android
          echo "Disk usage after:" && df -h

      - name: Restore Godot build cache
        uses: ./.github/actions/godot-cache-restore
        with:
          cache-name: ${{ matrix.cache-name }}
        continue-on-error: true

      - name: Setup Python and SCons
        if: "!matrix.legacy-scons"
        uses: ./.github/actions/godot-deps

      - name: Setup Python and SCons (legacy versions)
        if: matrix.legacy-scons
        uses: ./.github/actions/godot-deps
        with:
          # Sync with Ensure*Version in SConstruct.
          python-version: 3.9
          scons-version: 4.4

      - name: Force remove preinstalled .NET SDKs
        if: matrix.build-mono
        run: |
          sudo rm -rf /usr/share/dotnet/sdk/*

      - name: Setup older .NET SDK as baseline
        if: matrix.build-mono
        uses: actions/setup-dotnet@v5
        with:
          # Targeting the oldest version we want to support to ensure it still builds.
          dotnet-version: 8.0.100

      - name: Download pre-built AccessKit
        id: accesskit-download
        uses: ./.github/actions/fetch-gh-release-asset
        with:
          repo: godotengine/godot-accesskit-c-static
          version: tags/0.21.1
          file: accesskit-c-0.21.1.zip
          target: accesskit-c-0.21.1/accesskit_c.zip
        continue-on-error: true

      - name: Extract pre-built AccessKit
        if: steps.accesskit-download.outcome == 'success'
        run: unzip -o accesskit-c-0.21.1/accesskit_c.zip

      - name: Set AccessKit enabled
        id: accesskit-sdk
        run: |
          if [ "${{ steps.accesskit-download.outcome }}" = "success" ]; then
            echo "ACCESSKIT_ENABLED=yes" >> "$GITHUB_OUTPUT"
          else
            echo "::warning::AccessKit SDK download failed, building without AccessKit support."
            echo "ACCESSKIT_ENABLED=no" >> "$GITHUB_OUTPUT"
          fi

      - name: Install mold linker
        if: matrix.proj-test
        uses: ./.github/actions/setup-mold

      - name: Compilation
        uses: ./.github/actions/godot-build
        with:
          scons-flags: ${{ env.SCONS_FLAGS }} ${{ matrix.scons-flags }} accesskit=${{ steps.accesskit-sdk.outputs.ACCESSKIT_ENABLED }}
          platform: linuxbsd
          target: ${{ matrix.target }}

      - name: Style checks via clangd-tidy
        if: matrix.clangd-tidy
        uses: ./.github/actions/clangd-tidy
        with:
          changed-files: ${{ inputs.changed-files }}

      - name: Compilation (godot-cpp)
        uses: ./.github/actions/godot-cpp-build
        if: matrix.godot-cpp
        with:
          bin: ${{ matrix.bin }}
          scons-flags: target=template_debug dev_build=yes verbose=yes
          godot-cpp-branch: ${{ env.GODOT_CPP_BRANCH }}

      - name: Save Godot build cache
        uses: ./.github/actions/godot-cache-save
        with:
          cache-name: ${{ matrix.cache-name }}
        continue-on-error: true

      - name: Generate C# glue
        if: matrix.build-mono
        run: |
          ${{ matrix.bin }} --headless --generate-mono-glue ./modules/mono/glue

      - name: Build .NET solutions
        if: matrix.build-mono
        run: |
          dotnet --info
          ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=linuxbsd --werror

      - name: Prepare artifact
        if: matrix.artifact
        run: |
          rm -rf ./bin/build_deps
          strip bin/godot.*
          chmod +x bin/godot.*

      - name: Upload artifact
        uses: ./.github/actions/upload-artifact
        if: matrix.artifact
        with:
          name: ${{ matrix.cache-name }}

      - name: Unit tests
        run: |
          ${{ matrix.bin }} --version
          ${{ matrix.bin }} --help
          ${{ matrix.bin }} --headless --test --force-colors

      - name: .NET source generators tests
        if: matrix.build-mono
        run: |
          dotnet test modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests

      # Check class reference
      - name: Check for class reference updates
        if: matrix.doc-test
        run: |
          echo "Running --doctool to see if this changes the public API without updating the documentation."
          echo -e "If a diff is shown, it means that your code/doc changes are incomplete and you should update the class reference with --doctool.\n\n"
          ${{ matrix.bin }} --doctool --headless 2>&1 > /dev/null || true
          git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$'

      # Check API backwards compatibility
      - name: Check for GDExtension compatibility – JSON check
        if: matrix.api-compat
        run: |
          ./misc/scripts/validate_extension_api.sh "${{ matrix.bin }}"

      - name: Test GDExtension compatibility – load methods
        uses: ./.github/actions/godot-compat-test
        if: matrix.api-compat
        with:
          bin: ${{ matrix.bin }}
          reftags: "4.5-stable,4.4-stable"

      # Download and run the test project
      - name: Test Godot project
        uses: ./.github/actions/godot-project-test
        if: matrix.proj-test
        with:
          bin: ${{ matrix.bin }}

      # Test project export
      - name: Test project export
        uses: ./.github/actions/godot-project-export
        if: matrix.proj-export
        with:
          bin: ${{ matrix.bin }}

      # Test the project converter
      - name: Test project converter
        uses: ./.github/actions/godot-converter-test
        if: matrix.proj-conv
        with:
          bin: ${{ matrix.bin }}