Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA: Run unit tests in CI #37

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build_gdextension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: libsentrysdk.${{matrix.platform}}.${{matrix.target}}.${{matrix.arch}}
path: project/
path: |
project/
!project/addons/gdUnit4
!project/test/

package:
name: 📦 Package GDExtension
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ jobs:
build-extension:
name: 🔌 Build GDExtension
uses: ./.github/workflows/build_gdextension.yml

unit-tests:
name: 🧪 Unit tests
needs: build-extension
uses: ./.github/workflows/unit_tests.yml
83 changes: 83 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 🧪 Unit tests

on:
workflow_call:

jobs:
unit-tests:
name: Test on ${{matrix.runner}}
runs-on: ${{matrix.runner}}
strategy:
fail-fast: false
matrix:
include:
- runner: windows-latest
godot-suffix: win64.exe
- runner: ubuntu-latest
godot-suffix: linux.x86_64
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: false # don't initialize submodules automatically

- name: Checkout required submodules
run: |
git submodule update --init --depth 1 modules/gdUnit4
git submodule update --init --depth 1 modules/godot-cpp

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: sentry-godot-gdextension
path: project/

- name: Install SCons
run: |
python -m pip install scons
python --version
scons --version

- name: Set up Godot
shell: bash
run: |
version=$(sed -n 's/compatibility_minimum = "\([^"]*\)"/\1-stable/p' project/addons/sentrysdk/bin/sentrysdk.gdextension)
bin=Godot_v${version}_${{matrix.godot-suffix}}
url=https://github.com/godotengine/godot/releases/download/${version}/${bin}.zip
mkdir godot/
cd godot/
curl -L -o godot.zip "${url}"
unzip godot.zip
rm godot.zip
chmod u+x ${bin}
ls -l
./${bin} --version
echo "GODOT_BIN=${GITHUB_WORKSPACE}/godot/${bin}" >> $GITHUB_ENV

- name: Diagnostic info
shell: bash
run: |
ls -lR project/

- name: Prepare project
shell: bash
timeout-minutes: 5
run: |
scons project/addons/gdUnit4
chmod +x project/addons/sentrysdk/bin/crashpad_handler
echo "--- Rebuilding import cache.."
${GODOT_BIN} --headless --editor --path project/ --quit-after 2000 || true
echo "--- Finished rebuilding import cache."

- name: Run tests
shell: bash
timeout-minutes: 5
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this step fails if the tests fail?

Copy link
Collaborator Author

@limbonaut limbonaut Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about timeout-minutes - docs don't specify if it fails the step. Need to check it. (Works as expected).
According to docs, the process should return:

0   = all tests success
100 = ends with test failures
101 = ends with test warnings

${GODOT_BIN} --headless --path project/ -s -d "res://addons/gdUnit4/bin/GdUnitCmdTool.gd" --ignoreHeadlessMode -c -a test

- name: Upload results
if: always() # do this step even if the tests fail
uses: actions/upload-artifact@v4
with:
name: test-results-${{matrix.runner}}
path: project/reports
Loading