Skip to content

Update unittests.yml #204

Update unittests.yml

Update unittests.yml #204

Workflow file for this run

name: Build Process
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
compile_glecs:
strategy:
matrix:
include:
# Linux
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
glecs_lib: libglecs.so
- target: i686-unknown-linux-gnu
os: ubuntu-latest
glecs_lib: libglecs.so
# Mac
- target: x86_64-apple-darwin
os: macos-latest
glecs_lib: libglecs.rlib
# Windows
- target: x86_64-pc-windows-gnu
os: ubuntu-latest
glecs_lib: glecs.dll
runs-on: ${{ matrix.os }}
outputs:
x86_64-linux_lib_cache_key: ${{ steps.set_cache_key.outputs.x86_64-unknown-linux-gnu_lib_cache_key }}
i686-linux_lib_cache_key: ${{ steps.set_cache_key.outputs.i686-unknown-linux-gnu_lib_cache_key }}
x86_64-mac_lib_cache_key: ${{ steps.set_cache_key.outputs.x86_64-apple-darwin_lib_cache_key }}
x86_64-windows_lib_cache_key: ${{ steps.set_cache_key.outputs.x86_64-pc-windows-gnu_lib_cache_key }}
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=$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
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/x86_64-unknown-linux-gnu/release/libglecs.so
key: ${{ needs.compile_glecs.outputs.x86_64-linux_lib_cache_key }}
enableCrossOsArchive: true
- name: β†ͺ️ Move lib
if: ${{ matrix.os }} == "ubuntu-latest"
run: |
mkdir ./addons/glecs/bin/release/
mkdir ./addons/glecs/bin/debug/
cp ./addons/glecs/bin/x86_64-unknown-linux-gnu/release/libglecs.so ./addons/glecs/bin/release/libglecs.so
cp ./addons/glecs/bin/x86_64-unknown-linux-gnu/release/libglecs.so ./addons/glecs/bin/debug/libglecs.so
- 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"]
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 x86_64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/x86_64-unknown-linux-gnu/release/libglecs.so
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.x86_64-linux_lib_cache_key }}
# 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 i686
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/i686-unknown-linux-gnu/release/libglecs.so
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.i686-linux_lib_cache_key }}
# 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/x86_64-apple-darwin/release/libglecs.rlib
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.x86_64-mac_lib_cache_key }}
# 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/x86_64-pc-windows-gnu/release/glecs.dll
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.x86_64-windows_lib_cache_key }}
# 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