Skip to content

Commit

Permalink
Fix Unit Test CI (#1986)
Browse files Browse the repository at this point in the history
* Clone the gdUnit4 project.

* Perform builds for every branch.

* Adjust path.

* Move out addons folder.

* Adjust path.

* Fix path.

* Fix path.

* Add structure print.

* Fix path.

* Use `rsync`.

* Use `v4.2.0` tag.

* Remove cloned `gdUnit4`.

* Fix paths.

* Fix paths.

* Adjust path.

* Revert paths.

* Change project update.

* Try without project runner.

* Revert steps.

* Try Godot 4.2.1.

* Copy `project.godot`.

* Add example test.
  • Loading branch information
CakeVR authored Jan 3, 2024
1 parent fcef073 commit 15ee301
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/resources/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=5

[application]

config/name="dialogic"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"

[rendering]

renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
21 changes: 16 additions & 5 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ run-name: ${{ github.head_ref || github.ref_name }}-unit-test

on:
push:
branches:
- main

paths-ignore:
- '**.yml'
Expand All @@ -29,7 +27,7 @@ jobs:
fail-fast: false
matrix:
# Insert here the Godot version you want to run your tests with.
godot-version: ['4.2']
godot-version: ['4.2.1']

name: "CI Unit Test v${{ matrix.godot-version }}"
runs-on: 'ubuntu-22.04'
Expand Down Expand Up @@ -64,6 +62,19 @@ jobs:
echo "GODOT_HOME=$GODOT_HOME" >> "$GITHUB_ENV"
echo "GODOT_BIN=$GODOT_BIN" >> "$GITHUB_ENV"
- name: "Copy `project.godot`"
run: cp .github/workflows/resources/project.godot .

- name: "Clone the gdUnit4 repository"
run: |
git clone --branch v4.2.0 --single-branch https://github.com/MikeSchulze/gdUnit4
rsync -av gdUnit4/addons/ ./addons/
rm -rf ./gdUnit4
- name: Print Directory Structure
run: |
ls -R
# We need to update the project before running tests, Godot has actually issues with loading the plugin.
- name: "Update Project"
if: ${{ !cancelled() }}
Expand All @@ -72,7 +83,7 @@ jobs:
continue-on-error: true
shell: bash
run: |
${{ env.GODOT_BIN }} -e --path . -s res://addons/gdUnit4/bin/ProjectScanner.gd --headless --audio-driver Dummy
xvfb-run --auto-servernum ${{ env.GODOT_BIN }} -e --path . -s res://addons/gdUnit4/bin/ProjectScanner.gd --headless --audio-driver Dummy
- name: "Run Unit Tests"
if: ${{ !cancelled() }}
Expand All @@ -83,7 +94,7 @@ jobs:
shell: bash
run: |
chmod +x ./addons/gdUnit4/runtest.sh
xvfb-run --auto-servernum ./addons/gdUnit4/runtest.sh --add "res://test" --audio-driver Dummy --display-driver x11 --rendering-driver opengl3 --screen 0 --continue
xvfb-run --auto-servernum ./addons/gdUnit4/runtest.sh --add "res://addons/dialogic/Tests/" --audio-driver Dummy --display-driver x11 --rendering-driver opengl3 --screen 0 --continue
- name: "Publish Test Report"
if: ${{ always() }}
Expand Down
9 changes: 9 additions & 0 deletions addons/dialogic/Tests/Unit/test_example.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class_name GdUnitExampleTest
extends GdUnitTestSuite

func test_example() -> void:
const EXAMPLE_STRING := "Dialogic!"

assert_str(EXAMPLE_STRING)\
.has_length(EXAMPLE_STRING.length())\
.starts_with("Dia")
1 change: 1 addition & 0 deletions addons/dialogic/test-project
Submodule test-project added at c94593

0 comments on commit 15ee301

Please sign in to comment.