-
-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (142 loc) · 4.62 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
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.45f1
- 2022.3.55f1
- 2023.2.20f1
- 6000.0.32f1
steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
# Cache library folder for faster tests
- name: Cache library
uses: actions/cache@v4
with:
path: Library
key: Library-${{ matrix.unity-version }}
# 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-6000.0.32f1-base-3.1.0
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Cache library
uses: actions/cache@v4
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 .
# Download the coverage results
- name: Download coverage results
id: download-coverage
uses: actions/download-artifact@v4
with:
pattern: 'Coverage results - *'
path: Coverage
- name: LS
run: ls -R
- name: Generate report
uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: "${{ steps.download-coverage.outputs.download-path }}/*/workspace-opencov/*/*.xml"
targetdir: "CoverageReport"
reporttypes: "Html;Badges"
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: CoverageReport
- 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: Generate Solution
run: |
unity-editor -nographics -logFile /dev/stdout -customBuildName scriptable-values -projectPath . -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -quit
ls
# 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
- 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
dotnet build scriptable-values.sln
./dotnet-sonarscanner end /d:sonar.token=$SONAR_TOKEN