Skip to content

Commit

Permalink
Updated docs and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Dec 27, 2023
1 parent 4fc8aea commit 8dd3f5b
Show file tree
Hide file tree
Showing 56 changed files with 1,341 additions and 401 deletions.
37 changes: 20 additions & 17 deletions .github/actions/compile_gdextension/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ inputs:
description: Arch (universal|x86_32|x86_64|arm32|arm64|rv64|ppc32|ppc64|wasm32)
required: true
default: ""
artifact:
description: Artifact name. This name will be used for caching.
required: true
default: "bin"
additional:
description: Any additional arguments
default: ""
additional_enabled_dd3d:
description: Use force_enabled_dd3d if possible
default: "true"
output_libs_path:
description: Path to compiled libraries
required: true
default: "bin"
use_cache:
description: Use cache
default: "true"
artifact:
description: Artifact name
required: true
default: "bin"
additional:
description: Any additional arguments
default: ""
runs:
using: "composite"
using: composite
steps:
- name: Get godot-cpp SHA
shell: bash
Expand All @@ -40,10 +43,10 @@ runs:
uses: actions/cache/restore@v3
with:
path: ${{env.SCONS_CACHE}}
key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}}
key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}
${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}
${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}
${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}
continue-on-error: true

- name: Set up Python 3.x
Expand All @@ -64,11 +67,11 @@ runs:
- name: Linux dependencies
shell: bash
if: runner.os == 'Linux'
if: (runner.os == 'Linux') && (inputs.platform == 'linux')
run: |
sudo apt-get update
sudo apt update
if [[ "${{inputs.arch}}" == *"32" ]];then
sudo apt-get install gcc-multilib g++-multilib
sudo apt install gcc-multilib g++-multilib
fi
- name: Compilation
Expand All @@ -81,7 +84,7 @@ runs:
git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch
cd ..
scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} ${{inputs.additional}}
if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.platform}}" != "android" ]; then
if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.additional_enabled_dd3d}}" == "true" ]; then
scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} force_enabled_dd3d=yes ${{inputs.additional}}
fi
echo "::endgroup::"
Expand All @@ -103,7 +106,7 @@ runs:
Remove-Item ${{inputs.output_libs_path}}/* -Recurse -Include *.exp,*.lib,*.pdb -Force
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{inputs.artifact}}
retention-days: 7
Expand All @@ -114,5 +117,5 @@ runs:
uses: actions/cache/save@v3
with:
path: ${{env.SCONS_CACHE}}
key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}}
key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}}
continue-on-error: true
31 changes: 31 additions & 0 deletions .github/actions/delete_artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Delete the artifact if it exists
description: Delete an artifact by its name if it exists. 'actions/upload-artifact@v4' usually removes artifacts itself when restarting jobs.
inputs:
artifact:
description: Any name of artifact
required: true
runs:
using: composite
steps:
- name: Delete `${{inputs.artifact}}`
shell: bash
continue-on-error: true
run: |
res=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/actions/runs/${{github.run_id}}/artifacts?name="${{inputs.artifact}}")
artifact_id=$(echo "$res" | jq -r 'if .total_count > 0 then .artifacts[0].id else 0 end')
if [ "$artifact_id" == "0" ]; then
echo "No artifact to remove was found."
else
echo "Found the artifact ID $artifact_id for the ${{inputs.artifact}}."
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/actions/artifacts/$artifact_id
echo "The artifact with the ID $artifact_id has been removed."
fi
85 changes: 50 additions & 35 deletions .github/workflows/gdextension_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ on:
description: Use Cache
default: true
type: boolean
repository_dispatch:

# Stop the same workflow actions
concurrency:
group: ${{github.workflow}}-${{github.event.pull_request.number || github.run_id}}
group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true

permissions:
actions: write

env:
SCONS_CACHE: ${{github.workspace}}/.scons-cache/
USE_CACHE: ${{!format('{0}', inputs.use_cache) && 'true' || format('{0}', inputs.use_cache)}} # Default true
OUTPUT_LIBS_PATH: bin
FORCE_DISABLE_UNITY: yes
GH_TOKEN: ${{ github.token }}

jobs:
windows-gdextension:
name: 🏁 Windows
runs-on: "windows-latest"
runs-on: windows-latest

strategy:
fail-fast: false
Expand All @@ -35,7 +39,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
Expand All @@ -46,16 +50,16 @@ jobs:
platform: windows
target: ${{matrix.target}}
arch: ${{matrix.arch}}
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{format('{0}', inputs.use_cache)}} # Cast to string
artifact: windows
artifact: windows.${{matrix.target}}.${{matrix.arch}}
additional: lto=yes
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{env.USE_CACHE}}

# ============================================

linux-gdextension:
name: 🐧 Linux
runs-on: "ubuntu-20.04"
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand All @@ -65,7 +69,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
Expand All @@ -76,16 +80,16 @@ jobs:
platform: linux
target: ${{matrix.target}}
arch: ${{matrix.arch}}
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{format('{0}', inputs.use_cache)}}
artifact: linux
artifact: linux.${{matrix.target}}.${{matrix.arch}}
additional: lto=yes
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{env.USE_CACHE}}

# ============================================

macos-gdextension:
name: 🍏 MacOS
runs-on: "macos-latest"
runs-on: macos-latest

strategy:
fail-fast: false
Expand All @@ -95,7 +99,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
Expand All @@ -106,16 +110,16 @@ jobs:
platform: macos
target: ${{matrix.target}}
arch: ${{matrix.arch}}
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{format('{0}', inputs.use_cache)}}
artifact: macos
artifact: macos.${{matrix.target}}.${{matrix.arch}}
additional: lto=yes macos_deployment_target=10.14
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{env.USE_CACHE}}

# ============================================

android-gdextension:
name: 🤖 Android
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -125,7 +129,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
Expand Down Expand Up @@ -156,16 +160,17 @@ jobs:
platform: android
target: ${{matrix.target}}
arch: ${{matrix.arch}}
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{format('{0}', inputs.use_cache)}}
artifact: android
artifact: android.${{matrix.target}}.${{matrix.arch}}
additional: lto=yes
additional_enabled_dd3d: false
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{env.USE_CACHE}}

# ============================================

web-gdextension:
name: 🕸 Web
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -178,25 +183,30 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive

- uses: mymindstorm/setup-emsdk@v12
- name: Download Emscripten
uses: mymindstorm/setup-emsdk@v12
# Continue if failed to cache
# https://github.com/mymindstorm/setup-emsdk/issues/20
continue-on-error: true
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: obj/emsdk_cache

- name: Compile GDExtension
uses: ./.github/actions/compile_gdextension
with:
platform: web
target: ${{matrix.target}}
arch: ${{matrix.arch}}
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{format('{0}', inputs.use_cache)}}
artifact: web
artifact: web.${{matrix.target}}.${{matrix.arch}}
additional: lto=yes
output_libs_path: ${{env.OUTPUT_LIBS_PATH}}
use_cache: ${{env.USE_CACHE}}

# ============================================

Expand All @@ -213,25 +223,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

# https://github.com/actions/download-artifact/issues/249
- name: Download Binaries
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: extracted_files

- name: Remove `gdextension_libs` if the action was restarted
run: |
rm -rf extracted_files/gdextension_libs/
- name: Store all libraries in one directory
run: |
ls -R extracted_files/
mv -f extracted_files/**/* extracted_files
rm -rf extracted_files/**/
touch extracted_files/.gdignore
- name: Output file information
run: |
cd extracted_files
echo "Total size: $(du -ch -b | grep total | cut -f1 | awk '{printf "%.2f", $1/1048576}') MB, Total number of files: $(find . -type f | wc -l)" >> $GITHUB_STEP_SUMMARY
- name: Upload GDExtension
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: gdextension_libs
name: .gdextension_libs
retention-days: 7
path: extracted_files/*
Loading

0 comments on commit 8dd3f5b

Please sign in to comment.