Skip to content

Update unittests.yml #124

Update unittests.yml

Update unittests.yml #124

Workflow file for this run

name: Run Unit Tests
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
env:
LINUX_64_TARGET: x86_64-unknown-linux-gnu
LINUX_64_LIB: libglecs.so
WINDOWS_64_TARGET: x86_64-pc-windows-gnu
WINDOWS_64_LIB: libglecs.dll
jobs:
compile_glecs:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
glecs_lib: libglecs.so
# - os: ubuntu-latest
# target: x86_64-pc-windows-gnu
# glecs_lib: libglecs.dll
# - os: ubuntu-latest
# target: x86_64-pc-windows-gnu
# glecs_lib: libglecs.dll
runs-on: ${{ matrix.os }}
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 mingw for Windows build
if: ${{ matrix.target }} == x86_64-pc-windows-gnu
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 }}
# Copy library for use in test suite
cp -r ./addons/glecs/bin/${TARGET}/release ./addons/glecs/bin/debug
- 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: glecslib.${{ matrix.target }}
run_godot_test_suite:
needs: compile_glecs
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
glecs_lib: libglecs.so
# - os: ubuntu-latest
# target: x86_64-pc-windows-gnu
# glecs_lib: libglecs.dll
# - os: ubuntu-latest
# target: x86_64-pc-windows-gnu
# glecs_lib: libglecs.dll
runs-on: ${{ matrix.os }}
steps:
- name: πŸ™ Settup git environment
uses: actions/checkout@v4
- name: ⏳ Load 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: glecslib.${{ matrix.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: Move lib
run: |
cp ./addons/glecs/bin/${{ matrix.target }}/release/${{ matrix.glecs_lib }} ./addons/glecs/bin/release/${{ matrix.glecs_lib }}
cp ./addons/glecs/bin/${{ matrix.target }}/release/${{ matrix.glecs_lib }} ./addons/glecs/bin/debug/${{ matrix.glecs_lib }}
- name: πŸ€– Run Godot unit tests
uses: croconut/godot-tester@v5
with:
# required
version: "4.2"
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"
update_nightly:
needs: run_godot_test_suite
runs-on: windows-latest
steps:
# Run only if new commits were pushed
- name: πŸ“ Proceed if action is "push"
if: ${{ github.action }} != "push"
run: |
exit 0
- 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/${{ env.LINUX_64_TARGET }}/release/${{ env.LINUX_64_LIB }}
# An explicit key for restoring and saving the cache
key: glecslib.${{ env.LINUX_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/${{ env.WINDOWS_64_TARGET }}/release/${{ env.WINDOWS_64_LIB }}
# An explicit key for restoring and saving the cache
key: glecslib.${{ env.WINDOWS_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/
cp ../nightly_tmp/README.md ../nightly/README.md
cp ../nightly_tmp/.gitignore ../nightly/.gitignore
- name: πŸ–¨οΈ Copy dev branch plugin to nightly
run: |
cp -r -force ./addons/glecs/* ../nightly/
- name: βž• Add / 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 }}"
# Prevent error
echo ""
- name: πŸ“€ Push to nightly
if: steps.add-and-commit.outcome == 'success'
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