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

Add Unit Test GitHub Workflow #1980

Merged
merged 3 commits into from
Jan 1, 2024
Merged
Changes from 2 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
114 changes: 114 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: unit-test
run-name: ${{ github.head_ref || github.ref_name }}-unit-test

on:
push:
branches:
- main

paths-ignore:
- '**.yml'
- '**.md'

pull_request:
paths-ignore:
- '**.yml'
- '**.md'

workflow_dispatch:


concurrency:
group: unit-test${{ github.event.number }}
cancel-in-progress: true


jobs:
unit-test:
strategy:
fail-fast: false
matrix:
godot-version: ['4.1.1'] # Insert here the Godot version you want to run your tests with
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we use Godot 4.2 instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, I updated the version!


name: "CI Unit Test v${{ matrix.godot-version }}"
runs-on: 'ubuntu-22.04'
timeout-minutes: 10 # The overall timeout

steps:
- name: "Checkout your Repository"
uses: actions/checkout@v3
with:
lfs: true

- name: "Download and Install Godot ${{ matrix.godot-version }}"
continue-on-error: false
shell: bash
run: |
GODOT_HOME=$HOME/bin
GODOT_BIN=$GODOT_HOME/godot
mkdir -p $GODOT_HOME
chmod 770 $GODOT_HOME
GODOT_CONF_PATH=$HOME/.config/godot
if [ ! -d $GODOT_CONF_PATH ]; then
mkdir -p $GODOT_CONF_PATH
chmod 770 $GODOT_CONF_PATH
fi

GODOT_PACKAGE=Godot_v${{ matrix.godot-version }}-stable_linux.x86_64
wget https://github.com/godotengine/godot/releases/download/${{ matrix.godot-version }}-stable/$GODOT_PACKAGE.zip -P ${{ runner.temp }}
unzip ${{ runner.temp }}/$GODOT_PACKAGE.zip -d $GODOT_HOME
mv $GODOT_HOME/$GODOT_PACKAGE $GODOT_BIN
chmod u+x $GODOT_BIN
echo "GODOT_HOME=$GODOT_HOME" >> "$GITHUB_ENV"
echo "GODOT_BIN=$GODOT_BIN" >> "$GITHUB_ENV"

# We need to update the project before running tests, Godot has actually issues with loading the plugin
- name: "Update Project"
if: ${{ !cancelled() }}
timeout-minutes: 1
continue-on-error: true # we still ignore the timeout, the script is not quit and we run into a timeout
shell: bash
run: |
${{ env.GODOT_BIN }} -e --path . -s res://addons/gdUnit4/bin/ProjectScanner.gd --headless --audio-driver Dummy

- name: "Run Unit Tests"
if: ${{ !cancelled() }}
timeout-minutes: 8 # set your expected test timeout
env:
GODOT_BIN: ${{ env.GODOT_BIN }}
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

- name: "Publish Test Report"
if: ${{ always() }}
uses: dorny/[email protected]
with:
name: "test_report_${{ matrix.godot-version }}"
path: "reports/**/results.xml"
reporter: java-junit
fail-on-error: 'false'

- name: "Upload Unit Test Reports"
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: "test_report_${{ matrix.godot-version }}"
path: |
reports/**
/var/lib/systemd/coredump/**
/var/log/syslog

finalize:
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
name: Final Results
needs: [unit-test]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}