Skip to content

Refactor unittests.yml #215

Refactor unittests.yml

Refactor unittests.yml #215

Workflow file for this run

name: Build Process
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
initialize_variables:
outputs:
LINUX_I686_TARGET: ${{ steps.set_variables.outputs.LINUX_I686_TARGET }}
LINUX_I686_LIB: ${{ steps.set_variables.outputs.LINUX_I686_LIB }}
LINUX_X86_64_TARGET: ${{ steps.set_variables.outputs.LINUX_X86_64_TARGET }}
LINUX_X86_64_LIB: ${{ steps.set_variables.outputs.LINUX_X86_64_LIB }}
MAC_ARCH_TARGET: ${{ steps.set_variables.outputs.MAC_ARCH_TARGET }}
MAC_ARCH_LIB: ${{ steps.set_variables.outputs.MAC_ARCH_LIB }}
MAC_X86_64_TARGET: ${{ steps.set_variables.outputs.MAC_X86_64_TARGET }}
MAC_X86_64_LIB: ${{ steps.set_variables.outputs.MAC_X86_64_LIB }}
WINDOWS_X86_64_TARGET: ${{ steps.set_variables.outputs.WINDOWS_X86_64_TARGET }}
WINDOWS_X86_64_LIB: ${{ steps.set_variables.outputs.WINDOWS_X86_64_LIB }}
runs-on: ubuntu-latest
steps:
- name: Set variables
id: set_variables
run: |
echo "LINUX_I686_TARGET=i686-unknown-linux-gnu" >> $GITHUB_ENV
echo "LINUX_I686_LIB=libglecs.so" >> $GITHUB_ENV
echo "LINUX_X86_64_TARGET=x86_64-unknown-linux-gnu" >> $GITHUB_ENV
echo "LINUX_X86_64_LIB=libglecs.so" >> $GITHUB_ENV
echo "MAC_ARCH_TARGET=aarch64-apple-darwin" >> $GITHUB_ENV
echo "MAC_ARCH_LIB=libglecs.dylib" >> $GITHUB_ENV
echo "MAC_X86_64_TARGET=x86_64-apple-darwin" >> $GITHUB_ENV
echo "MAC_X86_64_LIB=libglecs.dylib" >> $GITHUB_ENV
echo "WINDOWS_X86_64_TARGET=x86_64-pc-windows-gnu" >> $GITHUB_ENV
echo "WINDOWS_X86_64_LIB=ubuntu-latest" >> $GITHUB_ENV
compile_glecs:
needs: initialize_variables
strategy:
matrix:
include:
# Linux
- target: ${{ needs.initialize_variables.outputs.LINUX_X86_64_TARGET }}
os: ubuntu-latest
glecs_lib: ${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }}
- target: ${{ needs.initialize_variables.outputs.LINUX_I686_TARGET }}
os: ubuntu-latest
glecs_lib: ${{ needs.initialize_variables.outputs.LINUX_I686_LIB }}
# Mac
- target: ${{ needs.initialize_variables.outputs.MAC_ARCH_TARGET }}
os: macos-latest
glecs_lib: ${{ needs.initialize_variables.outputs.MAC_ARCH_LIB }}
- target: ${{ needs.initialize_variables.outputs.MAC_X86_64_TARGET }}
os: macos-latest
glecs_lib: ${{ needs.initialize_variables.outputs.MAC_X86_64_LIB }}
# Windows
- target: ${{ needs.initialize_variables.outputs.WINDOWS_X86_64_TARGET }}
os: ubuntu-latest
glecs_lib: ${{ needs.initialize_variables.outputs.WINDOWS_X86_64_LIB }}
runs-on: ${{ matrix.os }}
outputs:
# Linux
i686-unknown-linux-gnu: ${{ steps.set_cache_key.outputs[needs.initialize_variables.outputs.LINUX_I686_TARGET] }}
x86_64-unknown-linux-gnu: ${{ steps.set_cache_key.outputs[needs.initialize_variables.outputs.LINUX_X86_64_TARGET] }}
# Mac
aarch64-apple-darwin: ${{ steps.set_cache_key.outputs[needs.initialize_variables.outputs.MAC_ARCH_TARGET] }}
x86_64-apple-darwin: ${{ steps.set_cache_key.outputs[needs.initialize_variables.outputs.MAC_X86_64_TARGET] }}
# Windows
x86_64-pc-windows-gnu: ${{ steps.set_cache_key.outputs[needs.initialize_variables.outputs.WINDOWS_X86_64_TARGET] }}
steps:
- name: πŸ™ Settup git environment
uses: actions/checkout@v4
- name: πŸ—³οΈ Initialize git submodules
run: git submodule update --init --recursive
- name: πŸ’Ύ Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "./addons/glecs/rust/glecs"
cache-on-failure: true
- name: πŸ—οΈ Update Rust
run: |
rustup update
rustup target add ${{ matrix.target }}
- name: 🐧 Install GCC multilib for Linux i686 build
if: ${{ matrix.target == 'i686-unknown-linux-gnu' && runner.os == 'Linux'}}
run: sudo apt-get install gcc-multilib
- name: πŸͺŸ Install mingw for Windows build
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' && runner.os == 'Linux' }}
run: sudo apt install gcc-mingw-w64
- name: πŸ¦€ Build Rust code
run: |
cargo build \
--release \
--manifest-path ./addons/glecs/rust/glecs/Cargo.toml \
--features compile_bindings \
--target-dir ./addons/glecs/bin \
--target ${{ matrix.target }}
- name: πŸ”οΈ Set Glecs library cache key ENV variable
run: |
echo "lib_cache_key=glecslib.${{ matrix.target }}.${{ hashFiles('addons/glecs/bin') }}" >> $GITHUB_ENV
- name: πŸ”‘ Set Glecs library cache key
id: set_cache_key
run: |
echo "${{ matrix.TARGET }}=$lib_cache_key" >> $GITHUB_OUTPUT
- name: πŸ’Ύ Cache compiled library
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ matrix.target }}/release/${{ matrix.glecs_lib }}
# An explicit key for restoring and saving the cache
key: ${{ env.lib_cache_key }}
enableCrossOsArchive: true
run_test_suite:
needs: [compile_glecs, initialize_variables]
runs-on: ubuntu-latest
steps:
- name: πŸ™ Settup git environment
uses: actions/checkout@v4
- name: πŸ’Ύ Load cached library
uses: actions/cache/[email protected]
with:
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.LINUX_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }}
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.LINUX_X86_64_TARGET] }}
enableCrossOsArchive: true
- name: β†ͺ️ Move lib
if: ${{ runner.os == 'Linux'}}
run: |
mkdir ./addons/glecs/bin/release/
mkdir ./addons/glecs/bin/debug/
cp ./addons/glecs/bin/${{ needs.initialize_variables.outputs.LINUX_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }} ./addons/glecs/bin/release/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }}
cp ./addons/glecs/bin/${{ needs.initialize_variables.outputs.LINUX_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }} ./addons/glecs/bin/debug/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }}
- name: πŸ€– Run Godot unit tests
id: run-godot-tests
uses: croconut/godot-tester@v5
with:
# required
version: "4.2.1"
is-mono: "false"
# the folder with your project.godot file in it
path: "./"
# the ratio of tests that must pass for this action to pass
# e.g. 0.6 means 60% of your tests must pass
minimum-pass: "1.0"
# the directory containing Gut tests
test-dir: "res://unittests"
# default is GUTs default: 'res://.gutconfig.json'; set this to load a different config file
config-file: "res://.gut_editor_config.json"
# relative path to the xml file to read / write GUT's results from, recommended
# for direct-scene users to check this file if you have issues
result-output-file: "test_results.xml"
- name: πŸ“„ Print Godot logs
if: failure() && steps.run-godot-tests.outcome != 'success'
run: echo "$(cat logs/godot.log)"
update_nightly:
if: ${{ github.event_name == 'push' || github.event_name == 'closed' }}
needs: [compile_glecs, run_test_suite, initialize_variables]
runs-on: windows-latest
steps:
- name: πŸ™ Settup git environment
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: 🐧 Load compiled library, Linux i686
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.LINUX_I686_TARGET }}/release/${{ needs.initialize_variables.outputs.LINUX_I686_LIB }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.LINUX_I686_TARGET] }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true
- name: 🐧 Load compiled library, Linux x86_64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.LINUX_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.LINUX_X86_64_LIB }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.LINUX_X86_64_TARGET] }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true
- name: 🍎 Load compiled library, Mac aarch64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.MAC_ARCH_TARGET }}/release/${{ needs.initialize_variables.outputs.MAC_ARCH_LIB }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.MAC_ARCH_TARGET] }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true
- name: 🍎 Load compiled library, Mac x86_64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.MAC_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.MAC_X86_64_LIB }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.MAC_X86_64_TARGET] }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true
- name: πŸͺŸ Load compiled library, Windows x86_64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/${{ needs.initialize_variables.outputs.WINDOWS_X86_64_TARGET }}/release/${{ needs.initialize_variables.outputs.WINDOWS_X86_64_LIB }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs[needs.initialize_variables.outputs.WINDOWS_X86_64_TARGET] }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true
- name: 🐍 Setup Python
uses: actions/[email protected]
with:
python-version: 3.11.2
cache: pip
- name: πŸš£β€β™‚οΈ Convert dev plugin to nightly format
run: |
cd addons/glecs
pip install regex
python _build_for_nightly.py
- name: πŸŒ™ Clone nightly branch
run: |
git clone https://github.com/${{ github.repository }} ../nightly_tmp -b nightly
mkdir ../nightly
mkdir ../nightly/.git
cp -r ../nightly_tmp/.git/* ../nightly/.git/
- name: πŸ–¨οΈ Copy dev branch plugin to nightly
run: |
cp -r -force ./addons/glecs/* ../nightly/
- name: βž• Add and commit to nightly
id: add-and-commit
continue-on-error: true
run: |
cd ../nightly
git config --global user.name github-actions[bot]
git config --global user.email [email protected]
git add .
git commit --all -m "(AUTO) ${{ github.event.head_commit.message }}"
- name: πŸ“€ Push to nightly
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
branch: nightly
directory: ../nightly
- name: 🏁 Finish
run: exit 0