-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
238 lines (216 loc) · 9.3 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: 'GdUnit4 - Test Runner Action'
description: 'This GitHub Action automates the execution of GdUnit4 unit tests within the Godot Engine 4.x environment.'
author: Mike Schulze <mikeschulze.lpz@kabelmail.de>
inputs:
godot-version:
description: 'The version of Godot in which the tests should be run.'
required: true
godot-status:
description: 'The Godot status (e.g., "stable", "rc1", "dev1")'
required: false
default: 'stable'
godot-net:
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
default: latest
paths:
description: 'Comma-separated or newline-separated list of directories containing test to execute.'
required: true
arguments:
description: 'Additional arguments to run GdUnit4. (e.g. "--verbose")'
required: false
timeout:
description: 'The test execution timeout in minutes.'
required: false
default: '10'
retries:
description: 'The number of retries if the tests fail.'
required: false
default: '0'
publish-report:
description: 'Enable disable to publish the report. To disable to run on forked repositories.'
required: false
default: 'true'
upload-report:
description: 'Whether the report & logs should be uploaded.'
required: false
default: 'true'
project_dir:
description: 'The project directory in which the action is to be executed. The specified directory must end with a path separator. e.g. ./MyProject/'
required: false
default: './'
report-name:
description: 'The name of the test report file.'
required: false
default: 'test-report.xml'
branding:
icon: 'refresh-cw'
color: 'purple'
runs:
using: 'composite'
steps:
# FIXME: workaround until will be merged: https://github.com/actions/runner/pull/1684
- shell: bash
run: |
echo "GITHUB_ACTION_PATH: ${GITHUB_ACTION_PATH}"
[ -d ./.gdunit4_action ] || (mkdir -p ./.gdunit4_action/ && cp -r $GITHUB_ACTION_PATH/.gdunit4_action/* ./.gdunit4_action/)
- name: 'Set Cache Name'
shell: bash
run: |
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
with:
path: '/home/runner/godot-linux'
key: ${{ env.CACHE_NAME }}
restore-keys: ${{ env.CACHE_NAME }}
enableCrossOsArchive: true
- name: 'Install Godot ${{ inputs.godot-version }}'
if: steps.godot-cache-binary.outputs.cache-hit != 'true'
uses: ./.gdunit4_action/godot-install
with:
godot-version: ${{ inputs.godot-version }}
godot-net: ${{inputs.godot-net == 'true' || inputs.godot-force-mono == 'true'}}
godot-status-version: ${{ inputs.godot-status }}
install-path: '/home/runner/godot-linux'
- name: 'print restored version - ${{ inputs.version }}'
shell: bash
run: |
/home/runner/godot-linux/godot --version
- name: 'Install gdUnit4 plugin - ${{ inputs.version }}'
shell: bash
run: |
echo -e "\e[33m Change to project directory: ${{ inputs.project_dir }} \e[0m"
cd "${{ inputs.project_dir }}"
if ${{ inputs.version == 'installed' }}; then
echo -e "\e[33m Info: Using the installed GdUnit4 plugin. \e[0m"
gdunit_version="v$(grep -oP '^version="\K[^"]+' ./addons/gdUnit4/plugin.cfg)"
echo "GDUNIT_VERSION=${gdunit_version}" >> "$GITHUB_ENV"
chmod +x ./addons/gdUnit4/runtest.sh
exit 0
fi
if [[ -d ./addons/gdUnit4 ]]; then
echo -e "\e[33m Info: Found a previous installation of GdUnit4, deleting it now. \e[0m"
rm -rf ./addons/gdUnit4
fi
# Download requested gdUnit4 version
gdunit_version="${{ inputs.version }}"
if ${{ inputs.version == 'latest' }}; then
gdunit_version=$(git ls-remote --refs --tags https://github.com/MikeSchulze/gdUnit4 v* | sort -t '/' -k 3 -V | tail -n 1 | cut -d '/' -f 3)
fi
echo "GDUNIT_VERSION=${gdunit_version}" >> "$GITHUB_ENV"
echo "Checkout GdUnit4 from branch '${gdunit_version}'"
git clone --quiet --depth 1 --branch ${gdunit_version} --single-branch https://github.com/MikeSchulze/gdUnit4 ./.install-gdunit4
# Remove test if no self test requested
if [[ -d ./.install-gdunit4/addons/gdUnit4/test && ! "${{ env.GDUNIT_SELFTEST }}" ]]; then
echo "Delete 'addons/gdUnit4/test'"
rm -rf ./.install-gdunit4/addons/gdUnit4/test
fi
# Install requested gdUnit4 version
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
echo -e "\e[34m Installed plugins\e[0m"
echo -e "\e[34m -----------------\e[0m"
ls --color=auto -lsA ./addons
echo -e "\e[34m -----------------\e[0m"
- name: 'Restore .Net Project'
if: ${{ !cancelled() && (inputs.godot-net == 'true' || inputs.godot-force-mono == 'true') }}
shell: bash
run: |
cd "${{ inputs.project_dir }}"
dotnet add package Microsoft.NET.Test.Sdk --version 17.9.0
# 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
# install required packages
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 --version
dotnet restore
dotnet build
dotnet list package
- name: 'Restore Godot project cache'
if: ${{ !cancelled() }}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
shell: bash
run: |
cd "${{ inputs.project_dir }}"
echo -e "\e[94mStart of the recovery of the project cache ...\e[0m"
$GODOT_BIN --path ./ -e --headless --quit-after 2000
echo -e "\e[94mProject cache successfully restored.\e[0m"
## GDScript test run
- name: 'Run GDScript Tests'
if: ${{ !cancelled() && env.RUN_GDSCRIPT_TESTS == 'true'}}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
uses: actions/github-script@v7
with:
script: |
const { runTests } = require('./.gdunit4_action/unit-test/index.js')
const args = {
project_dir: `${{ inputs.project_dir }}`,
paths: `${{ inputs.paths }}`,
arguments: `${{ inputs.arguments }}`,
timeout: ${{ inputs.timeout }},
retries: ${{ inputs.retries }}
};
await runTests(args, core);
- name: 'Publish GDScript Unit Test Reports'
if: ${{ !cancelled() && inputs.publish-report == 'true' && env.RUN_GDSCRIPT_TESTS == 'true'}}
uses: ./.gdunit4_action/publish-test-report
with:
project_dir: ${{ inputs.project_dir }}
report-name: ${{ inputs.report-name }}
reporter: java-junit
## .Net test run
- name: 'Run C# Tests'
if: ${{ !cancelled() && env.RUN_GDSCRIPT_TESTS == 'false' }}
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" -- 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' && env.RUN_GDSCRIPT_TESTS == 'false' }}
uses: ./.gdunit4_action/publish-test-report
with:
project_dir: ${{ inputs.project_dir }}
report-name: ${{ inputs.report-name }}
reporter: dotnet-trx
## Finally upload the test result artifacts
- name: 'Upload Unit Test Reports'
if: ${{ !cancelled() && inputs.upload-report == 'true' }}
uses: ./.gdunit4_action/upload-test-report
with:
project_dir: ${{ inputs.project_dir }}
report-name: ${{ inputs.report-name }}