diff --git a/.gdunit4_action/.runsettings b/.gdunit4_action/.runsettings new file mode 100644 index 0000000..f81d390 --- /dev/null +++ b/.gdunit4_action/.runsettings @@ -0,0 +1,39 @@ + + + + 1 + ./TestResults + net7.0;net8.0 + 180000 + true + + + + + + + detailed + + + + + test-result.html + + + + + test-result.trx + + + + + + + + + --audio-driver Dummy --display-driver x11 --rendering-driver opengl3 --screen 0 --verbose + + FullyQualifiedName + + diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 0c9928c..55716b5 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -23,7 +23,7 @@ jobs: fail-fast: false max-parallel: 10 matrix: - godot-version: ['4.1.3', '4.2', '4.2.1'] + godot-version: ['4.1.3', '4.2', '4.2.1', '4.2.2'] godot-status: ['stable'] godot-net: ['', '.Net'] version: ['master', 'latest', 'v4.2.0'] diff --git a/.github/workflows/resources/test.csproj b/.github/workflows/resources/test.csproj index b45a802..4a4c6c0 100644 --- a/.github/workflows/resources/test.csproj +++ b/.github/workflows/resources/test.csproj @@ -10,6 +10,6 @@ - + - \ No newline at end of file + diff --git a/action.yml b/action.yml index 366a87b..9340a91 100644 --- a/action.yml +++ b/action.yml @@ -133,14 +133,24 @@ runs: echo -e "\e[34m -----------------\e[0m" - name: 'Restore .Net Project' - if: ${{ !cancelled() }} + if: ${{ !cancelled() && inputs.godot-net == 'true' }} shell: bash run: | - if ${{ inputs.godot-net == 'true' }}; then - cd "${{ inputs.project_dir }}" - dotnet restore - dotnet build + cd "${{ inputs.project_dir }}" + # install required packages + dotnet add package Microsoft.NET.Test.Sdk + # for gdunit version less than 4.2.2 we need to load api version 4.2.1.1 + gdUnitVersion=$(echo "${{ inputs.version }}" | sed 's/^v//; s/\.//g') + if [[ ${gdUnitVersion} < 422 ]]; then + echo "gdUnit4 version ${gdUnitVersion} less 4.2.2, update project to gdUnit4.api v4.2.1" + dotnet add package gdUnit4.api --version 4.2.1 + dotnet add package gdUnit4.test.adapter --version 1.0.0 + else + dotnet add package gdUnit4.api + dotnet add package gdUnit4.test.adapter fi + dotnet restore + dotnet build - name: 'Restore Godot project cache' if: ${{ !cancelled() }} @@ -153,8 +163,8 @@ runs: $GODOT_BIN --path ./ -e --headless --quit-after 2000 echo -e "\e[94mProject cache successfully restored.\e[0m" - - name: 'Run Tests' - if: ${{ !cancelled() }} + - name: 'Run GDScript Tests' + if: ${{ !cancelled() && inputs.godot-net == 'false' }} env: GODOT_BIN: '/home/runner/godot-linux/godot' uses: actions/github-script@v7 @@ -170,6 +180,22 @@ runs: }; await runTests(args, core); + - name: 'Run C# Tests' + if: ${{ !cancelled() && inputs.godot-net == 'true' }} + env: + GODOT_BIN: '/home/runner/godot-linux/godot' + shell: bash + run: | + cd "${{ inputs.project_dir }}" + # test if a .runsettings file exists, if not use the action provided default .runsettings + if [ -f .runsettings ]; then + echo "Found `.runsettings` file." + else + echo "No project specific '.runsettings' found, using action default '.runsettings'" + cp $GITHUB_ACTION_PATH/.gdunit4_action/.runsettings . + fi + xvfb-run --auto-servernum dotnet test --no-build --settings .runsettings --results-directory ./reports --logger "trx;LogFileName=results.xml" + - name: 'Publish Unit Test Reports' if: ${{ !cancelled() && inputs.publish-report == 'true' }} uses: ./.gdunit4_action/publish-test-report