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
758 stars 133 forks source link

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

Closed NetSysFire closed 1 month ago

NetSysFire commented 2 months 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 months 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 months 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 months 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.

ThunderFD commented 1 month ago

what would be a sample job to build a test project now? I'm trying to piece together how to get Android builds to work but no luck so far. (I don't have any github actions experience prior to this so excuse any obvious errors)

my .yml looks something like this: (mac exporting works fine)

name: "godot-ci export"
on: push

env:
  GODOT_VERSION: 4.3
  EXPORT_NAME: some-name

jobs:
  export-android:
    name: Android Export
    runs-on: ubuntu-20.04
    container:
      image: barichello/godot-ci:4.3
    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: Android Build
        run: |
          mkdir -v -p build/android
          godot --headless --verbose --export-release "Android" "build/android/$EXPORT_NAME.apk"
      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: android
          path: build/android

  export-mac:
    name: Mac Export
    runs-on: ubuntu-20.04
    container:
      image: barichello/godot-ci:4.3
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          lfs: true
      - name: Setup
        run: |
          mkdir -v -p ~/.local/share/godot/export_templates/
          mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
      - name: Mac Build
        run: |
          mkdir -v -p build/mac
          godot --headless --verbose --export-release "macOS" build/mac/$EXPORT_NAME.zip
      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: mac
          path: build/mac

the log looks as follows:

[...]
Loaded system CA certificates
EditorSettings: Save OK!
reimport: begin: (Re)Importing Assets steps: 1
    reimport: step 0: icon.svg
EditorFileSystem: Importing file: res://icon.svg
EditorFileSystem: "res://icon.svg" import took 3 ms.
reimport: end
ERROR: Cannot export project with preset "Android" due to configuration errors:
Could not find version of build tools that matches Target SDK, using 33.0.2
A valid Java SDK path is required in Editor Settings.

   at: _fs_changed (editor/editor_node.cpp:1012)
ERROR: Project export for preset "Android" failed.
   at: _fs_changed (editor/editor_node.cpp:1028)
EditorSettings: Save OK!
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
Orphan StringName: Start (static: 0, total: 1)
Orphan StringName: Node (static: 5, total: 6)
Orphan StringName: End (static: 0, total: 1)
StringName: 3 unclaimed string names at exit.
Error: Process completed with exit code 1.
NetSysFire commented 1 month ago
  1. Wrong config file. 4.3 changed the config file name. See the linked PR.
  2. All those fixes are now incorporated and are not needed anymore.

So the only thing you need to do now is copying the /root godot paths, which I also added to the sample workflow in said PR.

NetSysFire commented 1 month ago

I checked again. The new image has not yet been uploaded to the container registry as no changes have been applied yet. @Calinou, it looks like the workflow responsible for that was skipped. https://github.com/abarichello/godot-ci/actions/runs/11406172834/job/31739349244

ThunderFD commented 1 month ago

@NetSysFire oh, thanks for the follow-up! I was again trying all kinds of stuff haha.

so the sample file should just work when changing "Windows Desktop" to "Android Debug" (with an export template named that, and changing the flag to --export-debug? (I want to deal with the key for signing another day..)

Bummer that there is no sample for Android in the yml file

I'll just wait for the updated docker image then.

NetSysFire commented 1 month ago

In the meantime try the echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.3.tres

Make sure this runs after you copied /root/.config/godot or it'll create a file with missing headers.

Calinou commented 1 month ago

I've requested a manual build of 4.3: https://github.com/abarichello/godot-ci/actions/runs/11416728337

The Mono build is failing since Godot 4.x needs OpenJDK 17 to be exported, but it's not available in the Debian Buster (EOL) repositories, which the mono:latest image is based on. I don't think this image is needed nowadays, given the Dockerfile would need to be switched over to use .NET 8.

Bummer that there is no sample for Android in the yml file

There is one for GitLab CI, but I don't think one was ever added to the GitHub Actions workflow file. It should be straightforward to port it from GitLab CI to GitHub Actions, the main part that's different will be how you define the export secrets.

ThunderFD commented 1 month ago

In the meantime try the echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.3.tres

Make sure this runs after you copied /root/.config/godot or it'll create a file with missing headers.

yep, that did the trick, thanks!

Bummer that there is no sample for Android in the yml file

There is one for GitLab CI, but I don't think one was ever added to the GitHub Actions workflow file. It should be straightforward to port it from GitLab CI to GitHub Actions, the main part that's different will be how you define the export secrets.

I'll probably figure that out somehow, otherwise I'll open another issue for help with that

NetSysFire commented 1 month ago

The manual build of the mono image fails because of

#16 [11/23] RUN echo '[gd_resource type="EditorSettings" format=3]' > ~/.config/godot/editor_settings-${GODOT_VERSION:0:3}.tres
#16 0.213 /bin/sh: 1: Bad substitution

This should not happen. However!

https://github.com/abarichello/godot-ci/blob/b87499e4bd2590c2a40d5f0c4fc5cdfc0fbc17a0/Dockerfile#L1

Ubuntu uses dash and not sh. Only with dash this issue happens. I did not introduce this error, this happened with that earlier PR, #149, which added those substitutions in the editor settings file names. The solution for that is to enforce somehow that /bin/sh is actually /bin/sh and not /bin/dash. Or just use /bin/bash.

Calinou commented 1 month ago

@NetSysFire This should be fixed by https://github.com/abarichello/godot-ci/pull/158, can you check?

NetSysFire commented 1 month ago

For the people in this thread: This is fixed for good now. You can remove those temporary fixes, I just tested that myself.