-
-
Notifications
You must be signed in to change notification settings - Fork 64
214 lines (189 loc) · 7.68 KB
/
main.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
name: Main Test and Release
on:
workflow_dispatch:
push:
paths:
# run when unity asset is changed, or CI is updated
- 'Assets/**'
- 'Packages/**'
- 'ProjectSettings/**'
- '.releaserc.yml'
- '.github/workflows/main.yml'
- '.github/workflows/run-test.yml'
jobs:
Tests2020:
# note: reuseable workflow is a job, not a step
name: Run Tests 2020
uses: ./.github/workflows/run-test.yml
secrets:
unity_license: ${{ secrets.UNITY_LICENSE2 }}
access_token: ${{ secrets.GITHUB_TOKEN }}
with:
# available list of containers here:
# https://hub.docker.com/r/unityci/editor/tags?page=1&ordering=last_updated&name=ubuntu-2020.1.17f1-base
unity_container: unityci/editor:ubuntu-2020.3.30f1-base-3.0.0
cache_key: Library-2020.3.30
test_results_name: Test results 2020
Tests2021:
name: Run Tests 2021
uses: ./.github/workflows/run-test.yml
secrets:
unity_license: ${{ secrets.UNITY_LICENSE_2021_3_4 }}
access_token: ${{ secrets.GITHUB_TOKEN }}
with:
unity_container: unityci/editor:ubuntu-2021.3.5f1-base-3.0.0
cache_key: Library-2021.3.5
test_results_name: Test results 2021
Tests2022:
name: Run Tests 2022
uses: ./.github/workflows/run-test.yml
secrets:
# checking if same license will work
unity_license: ${{ secrets.UNITY_LICENSE_2021_3_4 }}
access_token: ${{ secrets.GITHUB_TOKEN }}
with:
unity_container: unityci/editor:ubuntu-2022.2.8f1-base-3.0.0
cache_key: Library-2022.2.8
test_results_name: Test results 2022
BuildIL2CPP:
name: BuildIL2CPP
runs-on: ubuntu-latest
# available list of containers here:
# https://hub.docker.com/r/unityci/editor/tags?page=1&ordering=last_updated&name=ubuntu-2020.1.17f1-base
container: unityci/editor:ubuntu-2020.3.30f1-linux-il2cpp-3.0.0
steps:
- name: Activate unity
# exit code is 1 for manual activation
continue-on-error: true
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE2 }}
run: |
echo "$UNITY_LICENSE" | tr -d '\r' > UnityLicenseFile.ulf
unity-editor -nographics -logFile /dev/stdout -manualLicenseFile UnityLicenseFile.ulf -quit
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Library
id: cache-library
uses: actions/cache@v4
with:
path: Library
key: Library-2020.3.30
- name: Run by Build with il2cpp
# checks that all weaver generate code in the test dlls also compiles for IL2CPP
run: unity-editor -nographics -logFile /dev/stdout -executeMethod Mirage.Tests.BuildIL2CPP.BuildTests.BuildWithIl2CPP -quit
timeout-minutes: 20
Publish:
# only run once both tests and il2cpp have passed
needs: [Tests2020, Tests2021, Tests2022, BuildIL2CPP]
# only run on main
if: github.ref == 'refs/heads/main'
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14'
- name: Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
extra_plugins: |
@semantic-release/exec
@semantic-release/changelog
@semantic-release/git
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# upload next version so that sonar job can use it
- run: echo ${{ steps.semantic.outputs.new_release_version }} > SemanticVersion.txt
- name: Archive Version
uses: actions/upload-artifact@v4
if: always()
with:
name: SemanticVersion
path: SemanticVersion.txt
SonarScan:
# needs coverage from test CI
# only need 2020 test because that is the container that this action uses
needs: [Tests2020]
name: SonarScan
runs-on: ubuntu-latest
# available list of containers here:
# https://hub.docker.com/r/unityci/editor/tags?page=1&ordering=last_updated&name=ubuntu-2020.1.17f1-base
container: unityci/editor:ubuntu-2020.3.30f1-base-3.0.0
env:
DOTNET_ROOT: '/opt/unity/Editor/Data/NetCore/Sdk-2.2.107'
steps:
- name: Activate unity
# exit code is 1 for manual activation
continue-on-error: true
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE2 }}
run: |
echo "$UNITY_LICENSE" | tr -d '\r' > UnityLicenseFile.ulf
unity-editor -nographics -logFile /dev/stdout -manualLicenseFile UnityLicenseFile.ulf -quit
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Library
id: cache-library
uses: actions/cache@v4
with:
path: Library
key: Library-2020.3.30
- name: Install sonar scanner
run: |
$DOTNET_ROOT/dotnet tool install dotnet-sonarscanner --tool-path . --version 5.4.0
apt update
apt install -y openjdk-11-jre-headless
- name: Generate Solution
run: unity-editor -nographics -logFile /dev/stdout -customBuildName Mirage -projectPath . -executeMethod UnityEditor.SyncVS.SyncSolution -quit
# unity 2020.3 outputs <ReferenceOutputAssembly>false</ReferenceOutputAssembly> on linux
# this breaks references to other csproj for docfx and sonar.
# This step is a work around for this so docfx runs in correctly
# replacing false with true in ReferenceOutputAssembly
- name: Fix Csproj
run: sed -i 's/<ReferenceOutputAssembly>false<\/ReferenceOutputAssembly>/<ReferenceOutputAssembly>true<\/ReferenceOutputAssembly>/g' *.csproj
- name: Get test coverages
uses: actions/download-artifact@v4
with:
name: Test results 2020
path: Tests
# Get version from Release step
# Run this as late as possible, to give time for publish job to finish and upload
- name: Get version
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: SemanticVersion
path: SemanticVersion
- name: Set SEM_VERSION
# see https://stackoverflow.com/a/57969570/8479976
# note if SemanticVersion does not exist SEM_VERSION will just stay empty
run: echo "SEM_VERSION=$(cat SemanticVersion/SemanticVersion.txt)" >> $GITHUB_ENV
# echo the version for debugging
- name: Echo Version
run: echo ${{ env.SEM_VERSION }}
- name: SonarQube analysis
env:
FrameworkPathOverride: /opt/unity/Editor/Data/MonoBleedingEdge/
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ls -l
./dotnet-sonarscanner begin \
/o:miragenet \
/k:MirageNet_Mirage \
/n:Mirage \
/d:sonar.verbose=false \
/d:sonar.login=$SONAR_TOKEN \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.exclusions=Assets/Mirage/Runtime/Sockets/Udp/NanoSockets/** \
/d:sonar.cpd.exclusions=Assets/Tests/** \
/d:sonar.coverage.exclusions=Assets/Tests/**,Assets/Mirage/Editor/** \
${{ env.SEM_VERSION != '' && format('/v:{0}',env.SEM_VERSION) || '' }} \
/d:sonar.cs.nunit.reportsPaths=Tests/editmode-results.xml,Tests/playmode-results.xml \
/d:sonar.cs.opencover.reportsPaths=Tests/Mirage-opencov/EditMode/TestCoverageResults_0000.xml,Tests/Mirage-opencov/PlayMode/TestCoverageResults_0000.xml
$DOTNET_ROOT/dotnet build Mirage.sln
./dotnet-sonarscanner end /d:sonar.login=$SONAR_TOKEN