From 591c00d32160f566621c041fb6f729027f3fb8d6 Mon Sep 17 00:00:00 2001 From: florianvazelle Date: Wed, 3 Jan 2024 18:38:09 +0100 Subject: [PATCH] ci: run godot in ci with drivers --- .github/actions/setup-x11-drivers/action.yml | 32 ++++++++++++ .github/workflows/release-packaging.yml | 32 ++++++++++++ Justfile | 52 ++++++++++++++++---- 3 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 .github/actions/setup-x11-drivers/action.yml diff --git a/.github/actions/setup-x11-drivers/action.yml b/.github/actions/setup-x11-drivers/action.yml new file mode 100644 index 0000000..8ebc6db --- /dev/null +++ b/.github/actions/setup-x11-drivers/action.yml @@ -0,0 +1,32 @@ +name: Setup Godot X11 Drivers Emulators +description: Setup Godot X11 Drivers Emulators. +runs: + using: "composite" + steps: + ############################## + # Rendering Driver Emulators # + ############################## + + - name: Add Rendering Driver Emulators Source + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list + sudo add-apt-repository -n ppa:kisak/kisak-mesa + + - name: Install Rendering Driver Emulators + if: ${{ runner.os == 'Linux' }} + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: mesa-vulkan-drivers binutils + version: 1.0 + + ############################## + # Audito Driver Emulators # + ############################## + + - name: Install Audio Rendering Driver Emulators + if: ${{ runner.os == 'Linux' }} + shell: bash + run: sudo apt-get install -y pulseaudio + diff --git a/.github/workflows/release-packaging.yml b/.github/workflows/release-packaging.yml index 13bd7b1..1240a12 100644 --- a/.github/workflows/release-packaging.yml +++ b/.github/workflows/release-packaging.yml @@ -14,6 +14,9 @@ jobs: steps: - uses: actions/checkout@v4 + with: + lfs: true + - uses: extractions/setup-just@v1 - name: Load dotenv @@ -39,11 +42,24 @@ jobs: steps: - uses: actions/checkout@v4 + with: + lfs: true + - uses: extractions/setup-just@v1 - name: Load dotenv run: just ci-load-dotenv + - name: Cache Godot + uses: actions/cache@v3 + with: + path: | + ~/.mkflower/bin + ~/.local/share/godot/export_templates/${{ env.godot_version }}.stable + key: ${{ env.godot_version }} + + - uses: ./.github/actions/setup-x11-drivers + - name: Export run: just export @@ -63,8 +79,21 @@ jobs: steps: - uses: actions/checkout@v4 + with: + lfs: true + - uses: extractions/setup-just@v1 + - name: Cache Godot + uses: actions/cache@v3 + with: + path: | + ~/.mkflower/bin + ~/.local/share/godot/export_templates/${{ env.godot_version }}.stable + key: ${{ env.godot_version }} + + - uses: ./.github/actions/setup-x11-drivers + - name: Load dotenv run: just ci-load-dotenv @@ -92,6 +121,9 @@ jobs: steps: - uses: actions/checkout@v4 + with: + lfs: true + - uses: extractions/setup-just@v1 - name: Load dotenv diff --git a/Justfile b/Justfile index 8eec001..e2e11c3 100644 --- a/Justfile +++ b/Justfile @@ -27,7 +27,21 @@ dist_dir := justfile_directory() / "dist" # Godot variables godot_version := env_var('GODOT_VERSION') -godot_platform := if arch() == "x86" { "linux.x86_32" } else { if arch() == "x86_64" { "linux.x86_64" } else { "" } } +godot_platform := if arch() == "x86" { + "linux.x86_32" +} else { + if arch() == "x86_64" { + "linux.x86_64" + } else { + if arch() == "arm" { + "linux.arm32" + } else { + if arch() == "aarch64" { + "linux.arm64" + } else { "" } + } + } +} godot_filename := "Godot_v" + godot_version + "-stable_" + godot_platform godot_template := "Godot_v" + godot_version + "-stable_export_templates.tpz" godot_bin := bin_dir / godot_filename @@ -94,14 +108,12 @@ install-templates: # Download game plugins install-addons: - [ -f plug.gd ] && just godot --headless --script plug.gd install || true + [ -f plug.gd ] && just headless --script plug.gd install || true # Workaround from https://github.com/godotengine/godot/pull/68461 # Import game resources import-resources: - just godot --headless --export-pack null /dev/null - # timeout 60 just godot --editor || true - # just godot --headless --quit --editor + just headless --export-pack null /dev/null # Updates the game version for export @bump-version: @@ -117,7 +129,21 @@ import-resources: # Godot binary wrapper @godot *ARGS: makedirs install-godot install-templates - {{ godot_bin }} {{ ARGS }} + #!/usr/bin/env sh + if [ "{{ env("CI", "false") }}" = "true" ]; then + just ci-godot-x11 {{ ARGS }} + else + {{ godot_bin }} {{ ARGS }} + fi + +# Run godot binary in headless mode +@headless *ARGS: + #!/usr/bin/env sh + if [ "{{ env("CI", "false") }}" = "true" ]; then + just godot --audio-driver PulseAudio --rendering-driver vulkan {{ ARGS }} + else + just godot --headless {{ ARGS }} + fi # Open the Godot editor editor: @@ -131,19 +157,19 @@ fmt: # Export game on Windows export-windows: bump-version install-addons import-resources mkdir -p {{ build_dir }}/windows - just godot --export-release '"Windows Desktop"' --headless {{ build_dir }}/windows/{{ game_name }}.exe + just headless --export-release '"Windows Desktop"' {{ build_dir }}/windows/{{ game_name }}.exe (cd {{ build_dir }}/windows && zip {{ game_name }}-windows-v{{ game_version }}.zip -r .) mv {{ build_dir }}/windows/{{ game_name }}-windows-v{{ game_version }}.zip {{ dist_dir }}/{{ game_name }}-windows-v{{ game_version }}.zip rm -rf {{ build_dir }}/windows # Export game on MacOS export-mac: bump-version install-addons import-resources - just godot --export-release "macOS" --headless {{ dist_dir }}/{{ game_name }}-mac-v{{ game_version }}.zip + just headless --export-release "macOS" {{ dist_dir }}/{{ game_name }}-mac-v{{ game_version }}.zip # Export game on Linux export-linux: bump-version install-addons import-resources mkdir -p {{ build_dir }}/linux - just godot --export-release "Linux/X11" --headless {{ build_dir }}/linux/{{ game_name }}.x86_64 + just headless --export-release "Linux/X11" {{ build_dir }}/linux/{{ game_name }}.x86_64 (cd {{ build_dir }}/linux && zip {{ game_name }}-linux-v{{ game_version }}.zip -r .) mv {{ build_dir }}/linux/{{ game_name }}-linux-v{{ game_version }}.zip {{ dist_dir }}/{{ game_name }}-linux-v{{ game_version }}.zip rm -rf {{ build_dir }}/linux @@ -151,7 +177,7 @@ export-linux: bump-version install-addons import-resources # Export game for the web export-web: bump-version install-addons import-resources mkdir -p {{ build_dir }}/web - just godot --export-release "Web" --headless {{ build_dir }}/web/index.html + just headless --export-release "Web" {{ build_dir }}/web/index.html # Export on all platform export: export-windows export-mac export-linux @@ -184,6 +210,12 @@ ci-load-dotenv: echo "game_name={{ game_name }}" >> $GITHUB_ENV echo "game_version={{ game_version }}" >> $GITHUB_ENV +# Starts godot using Xvfb and pulseaudio +ci-godot-x11 *ARGS: + pulseaudio --check || pulseaudio -D + xvfb-run {{ godot_bin }} {{ ARGS }} + pulseaudio -k || true + # Download Butler [private] install-butler: makedirs