-
-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (144 loc) · 4.73 KB
/
tests.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
name: Unity Tests
on:
push:
branches: # Only run jobs if files changed on this branch
- master
paths: # Only run jobs if files changed at these paths
- '.github/workflows/**'
- 'Assets/**'
- 'Packages/**'
- 'ProjectSettings/**'
- 'ci/**'
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
jobs:
# Run the Unity tests
tests:
name: Run ${{ matrix.unity-version }} tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unity-version:
- 2021.3.34f1
- 2022.1.24f1
- 2022.2.21f1
- 2022.3.17f1
- 2023.1.20f1
- 2023.2.5f1
steps:
# Checkout the repo
- name: Checkout
uses: actions/[email protected]
with:
lfs: true
fetch-depth: 0
# Cache library folder for faster tests
- name: Cache library
uses: actions/[email protected]
with:
path: Library
key: Library-${{ matrix.unity-version }}
restore-keys: |
Library-
# Run tests
- name: Run tests
uses: game-ci/unity-test-runner@v4
id: tests
with:
unityVersion: ${{ matrix.unity-version }}
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+Hertzole.ScriptableValues'
# Upload test results
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test results - ${{ matrix.unity-version }}
path: ${{ steps.tests.outputs.artifactsPath }}
# Upload coverage results
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: Coverage results - ${{ matrix.unity-version }}
path: ${{ steps.tests.outputs.coveragePath }}
sonarscan:
needs: [tests]
name: SonarScan
runs-on: ubuntu-latest
container: unityci/editor:ubuntu-2021.3.34f1-base-3.0.1
steps:
- name: Activate Unity
continue-on-error: true
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
run: |
echo "$UNITY_LICENSE" | tr -d '\r' > License.ulf
unity-editor -nographics -logFile /dev/stdout -manualLicenseFile License.ulf -quit
- name: Checkout repository
uses: actions/[email protected]
with:
lfs: true
fetch-depth: 0
- name: Cache library
uses: actions/[email protected]
with:
path: Library
key: Library-Scanner
restore-keys: |
Library-Scanner
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install scanner
run: dotnet tool install dotnet-sonarscanner --tool-path . --version 6.0.0
- name: Generate Solution
run: unity-editor -nographics -logFile /dev/stdout -customBuildName scriptable-values -projectPath . -executeMethod GitTools.Solution.Sync -quit
# Get the coverage results from the artifacts
- name: Get test reports
uses: actions/download-artifact@v4
with:
name: Test results - 2021.3.34f1
path: Tests
# Get the test coverage results from the artifacts
- name: Get test coverage
uses: actions/download-artifact@v4
with:
name: Coverage results - 2021.3.34f1
path: Coverage
# The test results have a different path than what SonarQube can read.
# We need to remove the github/workspace/ path.
- name: Fix paths
run: |
chmod +x ./ci/fix_paths.sh
./ci/fix_paths.sh Coverage
# For now, just upload the fixed paths
- name: Upload fixed paths
uses: actions/upload-artifact@v4
with:
name: Fixed paths
path: Coverage
- name: SonarQube analysis
env:
FrameworkPathOverride: /opt/unity/Editor/Data/MonoBleedingEdge/
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./dotnet-sonarscanner begin \
/o:"hertzole" \
/k:"scriptable-values" \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.verbose=false \
/d:sonar.token=$SONAR_TOKEN \
/d:sonar.cs.nunit.reportsPaths=Tests/**.xml \
/d:sonar.cs.opencover.reportsPaths=Coverage/workspace-opencov/**.xml
dotnet build scriptable-values.sln
./dotnet-sonarscanner end /d:sonar.token=$SONAR_TOKEN