abarichello / godot-ci

Docker image to export Godot Engine games. Templates for Gitlab CI and GitHub Actions to deploy to GitLab Pages/GitHub Pages/Itch.io.
https://hub.docker.com/r/barichello/godot-ci
MIT License
734 stars 130 forks source link

"A valid Java SDK path is required in Editor Settings", editor settings are not being read #151

Open NetSysFire opened 1 month ago

NetSysFire commented 1 month ago

All builds (linux, mac and windows) export well (thanks for your work on this project!), except Android, which fails with the error in the title. I thought this was going to be an easy fix and did the following, as the value is also missing from your dockerfile:

echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.tres

But it still complained about the same error. I tried different editor settings paths, including /root/.config/godot and copying editor_settings-4.tres to editor_settings-4.3.tres (in both /root and ~/) but none worked. Then I set JAVA_HOME to the same value as in the config and the exporter was mostly happy. Since this environment variable is independent from the config, see the godot source code, this strongly suggests that, for whatever reason, the editor settings are not being read. There is no option in godot, that I found at least, to make it dump the editor settings it sees for additional debugging.

Since the ANDROID_HOME env var is in the dockerfile, I believe this is why it did not complain about the Android SDK path. It also says WARNING: Code Signing: Could not find keystore, unable to export., indicating again that the editor settings are not being applied. $XDG_DATA_HOME and $XDG_DATA_CONFIG are unset or empty.

This is on github actions. You can find the file here: https://github.com/sourceofmana/sourceofmana-ci-test/blob/master/.github/workflows/godot-ci.yml But for the sake of of saving you a click, here is a tidied up version which has some of my debug attempts removed:

name: "godot-ci export"
on:
  push:
    branches:
    - master

env:
  GODOT_VERSION: 4.3
  EXPORT_NAME: "Source of Mana"
  PROJECT_PATH: "."

jobs:
  release:
    name: Create Release
    runs-on: ubuntu-latest
    permissions: write-all
    outputs:
      timestamp: ${{ steps.get-timestamp.outputs.time }}
    steps:
      - name: Get build timestamp
        id: get-timestamp
        run: |
          echo "time=$(/bin/date -u "+%Y-%m-%d-%H%M")" >> $GITHUB_OUTPUT
      - name: Get env vars
        id: generate_env_vars
        run: |
          echo "tag_name=som-experimental-"${{ steps.get-timestamp.outputs.time }} >> $GITHUB_OUTPUT
          echo "release_name=Source of Mana experimental build ${{ steps.get-timestamp.outputs.time }}" >> $GITHUB_OUTPUT
      - uses: actions/checkout@v4
      - run: gh release create ${{ steps.generate_env_vars.outputs.tag_name }} --prerelease --title "${{ steps.generate_env_vars.outputs.release_name }}" --target "$(git log -1 --format='%H')"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  builds:
    needs: release
    strategy:
      fail-fast: false
      matrix:
        include:
        - name: Linux
          artifact: linux
          export_template: "Linux/X11"
          ext: "x86_64"
        - name: Linux (Headless Server)
          artifact: linux-server-headless
          export_template: "Linux/X11 Headless Server"
          ext: "x86_64"
        - name: Windows
          artifact: windows
          export_template: "Windows Desktop"
          ext: "exe"
        - name: macOS
          artifact: macos
          export_template: "macOS"
          ext: "zip"
        - name: Android
          artifact: android
          export_template: "Android"
          ext: "apk"
    runs-on: ubuntu-latest
    permissions: write-all
    container:
      image: barichello/godot-ci:4.3
    name: Export ${{ matrix.name }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          lfs: true
      - name: Setup
        run: |
          mkdir -v -p ~/.local/share/godot/export_templates/
          mkdir -v -p ~/.config/
          echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> /root/.config/godot/editor_settings-4.tres
          cp /root/.config/godot/editor_settings-4.tres /root/.config/godot/editor_settings-4.3.tres
          cp -r /root/.config/godot ~/.config/godot
          cp -r /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
      - name: ${{ matrix.name }} Build
        run: |
          mkdir -v -p "build/${{ matrix.artifact }}"
          cd "$PROJECT_PATH"
          godot --headless --verbose --export-release "${{ matrix.export_template }}" "build/${{ matrix.artifact }}/${EXPORT_NAME}-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }}"
      - name: Ensure github cli is present
        run: |
          wget https://github.com/cli/cli/releases/download/v2.55.0/gh_2.55.0_linux_amd64.deb
          dpkg -i gh_2.55.0_linux_amd64.deb
      - name: Upload artifact to release
        run: |
          git config --global --add safe.directory '*'
          gh release upload som-experimental-${{ needs.release.outputs.timestamp }} "build/${{ matrix.artifact }}/${EXPORT_NAME}-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }}"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NetSysFire commented 2 weeks ago

I have found the issue! Credits to paulguy for suggesting that.

You run godot and apparently this has created a dummy config in the past:

https://github.com/abarichello/godot-ci/blob/db6fb8b4f6a3b42524a6f5b775e502a25d10e5b5/Dockerfile#L59-L60

However, it does not do that anymore and it is missing the headers. I solved the issue by prepending this to the file:

[gd_resource type="EditorSettings" format=3]

[resource]

I'll PR that here real quick.

Spengreb commented 2 weeks ago

For me the first thing you posted actually worked when pointed to the current version: echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.3.tres

This is the complete debug step I have now

# Android Debug Job. It will use the generated debug.keystore.
android_debug:
  stage: export
  script:
    - echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.3.tres
    - godot --headless --verbose --export-debug "Android Debug" ./build/android/$EXPORT_NAME.apk
  artifacts:
    name: $EXPORT_NAME-$CI_JOB_NAME
    paths:
      - build/android

Somehow this passes

NetSysFire commented 2 weeks ago

Curious. What user/home does that run in? Maybe invoking godot and exiting immediately does place a config but not in a place where you'd expect it.