Skip to content

Commit

Permalink
GD-40: Add property to force run GDScript test with Godot Mono
Browse files Browse the repository at this point in the history
# Why

see #40

# What
- Added new optional property ` godot-force-mono` to enforce running GDScript tests by using the Godot Mono executable
  • Loading branch information
MikeSchulze committed May 11, 2024
1 parent e53176f commit 2dc42ca
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 9 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,43 @@ jobs:
timeout: 2
report-name: gdUnit4-custom-working-directory-net


# run gdscript tests with using Godot Mono executable
unit-tests-force-godot-mono:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
permissions:
actions: read
contents: read
checks: write
pull-requests: write
statuses: write
name: 'GdUnit4 action with force run Godot Mono'

steps:
- name: 'Checkout gdUnit4-action'
uses: actions/checkout@v4
with:
lfs: true

- name: 'Install custom test project'
shell: bash
run: |
mv -f .github/workflows/resources/* .
- name: 'Test gdUnit4-action: force run Godot Mono'
timeout-minutes: 5
uses: ./
with:
godot-version: 4.2.1
godot-force-mono : 'true'
paths: |
res://tests/
timeout: 2
report-name: gdUnit4-force-mono


# tests if the action reports test failures the action must fail
action-fail-test:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -178,7 +215,7 @@ jobs:
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
name: 'Final Results'
needs: [unit-tests, action-fail-test]
needs: [unit-tests, unit-tests-force-godot-mono, unit-tests-custom-working-directory, action-fail-test]
steps:
- run: exit 1
if: >-
Expand Down
39 changes: 38 additions & 1 deletion .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,43 @@ jobs:
report-name: gdUnit4-custom-working-directory-net


# run gdscript tests with using Godot Mono executable
unit-tests-force-godot-mono:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
permissions:
actions: read
contents: read
checks: write
pull-requests: write
statuses: write
name: 'GdUnit4 action with force run Godot Mono'

steps:
- name: 'Checkout gdUnit4-action'
uses: actions/checkout@v4
with:
lfs: true

- name: 'Install custom test project'
shell: bash
run: |
mv -f .github/workflows/resources/* .
- name: 'Test gdUnit4-action: force run Godot Mono'
id: test-force-mono
timeout-minutes: 5
uses: ./
with:
godot-version: 4.2.1
godot-force-mono : 'true'
paths: |
res://tests/
timeout: 2
report-name: gdUnit4-force-mono


# tests if the action reports test failures the action must fail
action-fail-test:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -208,7 +245,7 @@ jobs:
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
name: 'Final Results'
needs: [unit-tests, action-fail-test]
needs: [unit-tests, unit-tests-custom-working-directory, unit-tests-force-godot-mono, action-fail-test]
steps:
- run: exit 1
if: >-
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ A GdUnit4 **version** should be specified as a string, such as `v4.2.1`. To run
# Default: false
godot-net: ''

# Set to true to force running GDScript tests by using the Godot Mono executable
# Default: false
godot-force-mono: ''

# The project directory in which the action is to be executed.
# The specified directory must end with a path separator. e.g. ./MyProject/
# Default: './'
Expand Down
20 changes: 13 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
description: 'Set to true for Godot .Net (C#).'
required: false
default: 'false'
godot-force-mono:
description: 'Force test run to use Godot Mono version'
required: false
default: 'false'
version:
description: 'The version of GdUnit4 to use. (e.g. "v4.2.0", "latest", "master").'
required: false
Expand Down Expand Up @@ -65,12 +69,14 @@ runs:
- name: 'Set Cache Name'
shell: bash
run: |
if ${{inputs.godot-net == 'true'}}; then
if ${{inputs.godot-net == 'true' || inputs.godot-force-mono == 'true'}}; then
echo "CACHE_NAME=${{ runner.OS }}-Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status }}_NET" >> "$GITHUB_ENV"
else
echo "CACHE_NAME=${{ runner.OS }}-Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status }}" >> "$GITHUB_ENV"
fi
echo "RUN_GDSCRIPT_TESTS=${{inputs.godot-net == 'false'}}" >> "$GITHUB_ENV"
- name: 'Build Cache'
uses: actions/cache@v4
id: godot-cache-binary
Expand Down Expand Up @@ -123,7 +129,7 @@ runs:
fi
# Install requested gdUnit4 version
echo -e "\e[34m Install GdUnit4 \e[92m${gdunit_version} \e[34mplugin in the project \e[0m"
echo -e "\e[34m Install GdUnit4 \e[92m${gdunit_version} \e[34m plugin in the project \e[0m"
mkdir -p ./addons/gdUnit4/
cp -R ./.install-gdunit4/addons/gdUnit4 ./addons
chmod +x ./addons/gdUnit4/runtest.sh
Expand All @@ -133,7 +139,7 @@ runs:
echo -e "\e[34m -----------------\e[0m"
- name: 'Restore .Net Project'
if: ${{ !cancelled() && inputs.godot-net == 'true' }}
if: ${{ !cancelled() && (inputs.godot-net == 'true' || inputs.godot-force-mono == 'true')}}
shell: bash
run: |
cd "${{ inputs.project_dir }}"
Expand Down Expand Up @@ -165,7 +171,7 @@ runs:
## GDScript test run
- name: 'Run GDScript Tests'
if: ${{ !cancelled() && inputs.godot-net == 'false' }}
if: ${{ !cancelled() && env.RUN_GDSCRIPT_TESTS == 'true'}}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
uses: actions/github-script@v7
Expand All @@ -182,7 +188,7 @@ runs:
await runTests(args, core);
- name: 'Publish GDScript Unit Test Reports'
if: ${{ !cancelled() && inputs.publish-report == 'true' && inputs.godot-net == 'false'}}
if: ${{ !cancelled() && inputs.publish-report == 'true' && env.RUN_GDSCRIPT_TESTS == 'true'}}
uses: ./.gdunit4_action/publish-test-report
with:
project_dir: ${{ inputs.project_dir }}
Expand All @@ -191,7 +197,7 @@ runs:

## .Net test run
- name: 'Run C# Tests'
if: ${{ !cancelled() && inputs.godot-net == 'true' }}
if: ${{ !cancelled() && env.RUN_GDSCRIPT_TESTS == 'false' }}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
shell: bash
Expand All @@ -207,7 +213,7 @@ runs:
xvfb-run --auto-servernum dotnet test --no-build --settings .runsettings --results-directory ./reports --logger "trx;LogFileName=results.xml" -- GdUnit4.Parameters="--audio-driver Dummy --display-driver x11 --rendering-driver opengl3 --screen 0"
- name: 'Publish .Net Unit Test Reports'
if: ${{ !cancelled() && inputs.publish-report == 'true' && inputs.godot-net == 'true'}}
if: ${{ !cancelled() && inputs.publish-report == 'true'}} && env.RUN_GDSCRIPT_TESTS == 'false'
uses: ./.gdunit4_action/publish-test-report
with:
project_dir: ${{ inputs.project_dir }}
Expand Down

0 comments on commit 2dc42ca

Please sign in to comment.