-
Notifications
You must be signed in to change notification settings - Fork 354
172 lines (156 loc) · 7.4 KB
/
test.yaml
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
name: Test
on:
schedule:
- cron: "0 11 * * *" # 11am UTC = 3`am PST
pull_request:
types: [ labeled, closed ]
workflow_dispatch:
inputs:
unity_version:
description: 'Unity version (value: 2018, 2019, 2020)'
default: '2019'
required: true
include_test_types:
description: 'Specify the only types of tests to run, separated by comma. See TestTypesEnum in build.gradle for options.'
default: ''
required: false
exclude_test_types:
description: 'Specify the types of tests to exclude, separated by comma. See TestTypesEnum in build.gradle for options.'
default: ''
required: false
include_test_modules:
description: 'Specify the only modules to test against, separated by comma. See TestModulesEnum in build.gradle for options.'
default: ''
required: false
exclude_test_modules:
description: 'Specify the modules to exclude from testing against, separated by comma. See TestModulesEnum in build.gradle for options.'
default: ''
required: false
exclude_tests:
description: 'Specify the tests to exclude, separated by comma. See the tasks in build.gradle for options.'
default: ''
required: false
env:
pythonVersion: '3.7'
artifactRetentionDays: 2
jobs:
check_and_prepare:
runs-on: ubuntu-latest
outputs:
unity_version: ${{ steps.set_outputs.outputs.unity_version }}
include_test_types: ${{ steps.set_outputs.outputs.include_test_types }}
exclude_test_types: ${{ steps.set_outputs.outputs.exclude_test_types }}
include_test_modules: ${{ steps.set_outputs.outputs.include_test_modules }}
exclude_test_modules: ${{ steps.set_outputs.outputs.exclude_test_modules }}
exclude_tests: ${{ steps.set_outputs.outputs.exclude_tests }}
steps:
- id: set_outputs
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "unity_version=${{ github.event.inputs.unity_version }}" >> $GITHUB_OUTPUT
echo "include_test_types=${{ github.event.inputs.include_test_types }}" >> $GITHUB_OUTPUT
echo "exclude_test_types=${{ github.event.inputs.exclude_test_types }}" >> $GITHUB_OUTPUT
echo "include_test_modules=${{ github.event.inputs.include_test_modules }}" >> $GITHUB_OUTPUT
echo "exclude_test_modules=${{ github.event.inputs.exclude_test_modules }}" >> $GITHUB_OUTPUT
echo "exclude_tests=${{ github.event.inputs.exclude_tests }}" >> $GITHUB_OUTPUT
else
# inputs are not available for non "workflow_dispatch" events. Therefore, set default value here.
echo "unity_version=2019" >> $GITHUB_OUTPUT
echo "include_test_types=" >> $GITHUB_OUTPUT
echo "exclude_test_types=" >> $GITHUB_OUTPUT
echo "include_test_modules=" >> $GITHUB_OUTPUT
echo "exclude_test_modules=" >> $GITHUB_OUTPUT
echo "exclude_tests=" >> $GITHUB_OUTPUT
# This is currently checking for invalid trigger only.
if [[ "${{ github.event_name }}" == "schedule" ]]; then
# Do nothing for now
:
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.event.action }}" == "labeled" && "${{ github.event.label.name }}" == "tests-requested" ]]; then
# Do nothing for now
:
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged == true}}" == "true" ]]; then
# Do nothing for now
:
else
echo "invalid_trigger=1" >> $GITHUB_OUTPUT
fi
else
echo "invalid_trigger=1" >> $GITHUB_OUTPUT
fi
fi
- name: Cancel workflow
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
uses: andymckay/[email protected]
- name: Wait for workflow cancellation
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
run: |
sleep 300
exit 1 # fail out if the cancellation above somehow failed.
- name: Print output
run: |
echo outputs.unity_version : ${{ steps.set_outputs.outputs.unity_version }}
echo outputs.include_test_types : ${{ steps.set_outputs.outputs.include_test_types }}
echo outputs.exclude_test_types : ${{ steps.set_outputs.outputs.exclude_test_types }}
echo outputs.include_test_modules : ${{ steps.set_outputs.outputs.include_test_modules }}
echo outputs.exclude_test_modules : ${{ steps.set_outputs.outputs.exclude_test_modules }}
echo outputs.exclude_tests : ${{ steps.set_outputs.outputs.exclude_tests }}
test_on_macos:
name: test-macOS-unity${{ needs.check_and_prepare.outputs.unity_version }}
runs-on: macos-latest
needs: [check_and_prepare]
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- id: build_setup
uses: ./gha/build_setup
timeout-minutes: 30
with:
unity_version: ${{ needs.check_and_prepare.outputs.unity_version }}
platform: macOS
python_version: ${{ env.pythonVersion }}
unity_username: ${{ secrets.UNITY_USERNAME }}
unity_password: ${{ secrets.UNITY_PASSWORD }}
unity_serial_id: ${{ secrets.SERIAL_ID }}
- name: Set Unity Env for EDM4U build script
shell: bash
run: echo "UNITY_EXE=${{ env.UNITY_ROOT_DIR }}/Unity.app/Contents/MacOS/Unity" >> $GITHUB_ENV
- name: Run tests
shell: bash
timeout-minutes: 60
run: |
./gradlew test -q \
-PINTERACTIVE_MODE_TESTS_ENABLED=0 \
-PINCLUDE_TEST_TYPES="${{ needs.check_and_prepare.outputs.include_test_types }}" \
-PEXCLUDE_TEST_TYPES="${{ needs.check_and_prepare.outputs.exclude_test_types }}" \
-PINCLUDE_TEST_MODULES="${{ needs.check_and_prepare.outputs.include_test_modules }}" \
-PEXCLUDE_TEST_MODULES="${{ needs.check_and_prepare.outputs.exclude_test_modules }}" \
-PEXCLUDE_TESTS="${{ needs.check_and_prepare.outputs.exclude_tests }}"
- name: Print test log
if: always()
shell: bash
continue-on-error: true
run: cat test_output/test*IntegrationTestsBatchMode/*.log
- name: Obtain Failed tests from Integration tests and NUnit tests
if: always()
shell: bash
continue-on-error: true
run: |
# Quick and dirty way to get all failed tests in granular level.
# TODO: better parser for more information, ex. error message.
{ cat test_output/test*/*_test.log || true; } | { grep "^Test .* FAILED$" || true; }
{ cat test_output/test*/test*/results.xml || true; } | { grep '^ *<test-case.*result="Failed"' || true; } | sed 's/^.* name="\([^\"]*\)".*$/Test \1: FAILED/'
- name: Return Unity license
if: always()
uses: firebase/firebase-unity-sdk/gha/unity@main
with:
version: ${{ needs.check_and_prepare.outputs.unity_version }}
release_license: "true"
- name: Upload build logs
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: logs
path: test_output/test*/*.log
retention-days: ${{ env.artifactRetentionDays }}