-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (120 loc) · 4.3 KB
/
test.yml
File metadata and controls
141 lines (120 loc) · 4.3 KB
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
name: Test
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/develop' || !contains(github.event.pull_request.body, '#no-test') }}
strategy:
fail-fast: false
matrix:
worker: [0, 1, 2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@v4
- name: Install vendor
run: ./install_vendor.sh ${{ secrets.vendor_url }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install Ruby dependencies
run: bundle install
# PulseAudio does not work in Docker container
- name: Patch FMOD to disable sound
run: |
sed -i'' \
's/result = coreSystem.setOutput(outputType);/result = coreSystem.setOutput(FMOD.OUTPUTTYPE.NOSOUND);/' \
Assets/Plugins/FMOD/src/RuntimeManager.cs
- name: Cache Library
uses: actions/cache@v4
with:
path: Library
key: Library-${{ matrix.worker }}
- name: Get tests for the current worker
id: get_tests
run: |
tests=$(cat Assets/test/*.test.cs |
perl -ne 'm/public class (\w+) : ABaseTest/ && print "$1\n"' |
awk "NR % $WORKER_COUNT == $WORKER" |
paste -sd ';' -)
echo "tests=$tests" | tee -a $GITHUB_OUTPUT
env:
WORKER_COUNT: 8
WORKER: ${{ matrix.worker }}
- name: Run tests
id: tests
uses: 12joan/ci-unity-test-runner@main
continue-on-error: true
env:
# gh secret set UNITY_LICENSE < /Library/Application\ Support/Unity/Unity_lic.ulf
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
customParameters: -testFilter ${{ steps.get_tests.outputs.tests }}
# Caching Library may be causing an intermittent error "Unable to find
# type [UnityEngine.CoreModule.dll]". A symptom of this is that
# playmode-results.yml is never created. If this happens, delete Library
# and re-run the tests.
- name: Check if re-run is necessary
id: check_rerun
if: steps.tests.outcome == 'failure'
run: |
test -f artifacts/playmode-results.xml && exit 1
sudo rm -rf Library
- name: Re-run tests
if: steps.check_rerun.outcome == 'success'
uses: 12joan/ci-unity-test-runner@main
env:
# gh secret set UNITY_LICENSE < /Library/Application\ Support/Unity/Unity_lic.ulf
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
customParameters: -testFilter ${{ steps.get_tests.outputs.tests }}
- name: Report test results
if: always()
run: |
bundle exec ruby report_test_results.rb | tee -a results.txt
cat results.txt | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' >> $GITHUB_STEP_SUMMARY
- name: Upload Percy screenshots
uses: actions/upload-artifact@v4
with:
name: Percy (${{ matrix.worker }})
path: Percy
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test results (${{ matrix.worker }})
path: artifacts
percy:
name: 'Percy'
runs-on: ubuntu-latest
needs: test
if: ${{ github.ref == 'refs/heads/develop' || !contains(github.event.pull_request.body, '#no-percy') }}
steps:
- uses: actions/checkout@v4
- name: Install Yarn dependencies
run: yarn install
- name: Download screenshot artifacts
uses: actions/download-artifact@v4
with:
path: Percy
pattern: Percy (*)
merge-multiple: true
- name: Upload screenshots to Percy
run: yarn percy:upload
env:
# gh secret set PERCY_TOKEN <a Percy Web token>
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}