-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (156 loc) · 6.56 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: 'Unit Tests'
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
SONAR_PROJECT_KEY: "dk307_HSPI_ZWaveParameters"
SONAR_SCANNER_DOWNLOAD_URL: "https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.4.0.40033/sonar-scanner-msbuild-5.4.0.40033-net46.zip"
DOTCOVER_DOWNLOAD_URL: "https://download.jetbrains.com/resharper/dotUltimate.2021.2.2/JetBrains.dotCover.CommandLineTools.2021.2.2.zip"
SLN_FILE: "HSPI_ZWaveParameters.sln"
TEST_FILE_WIN: "tests\\bin\\Debug\\HSPI_ZWaveParametersTest.dll"
TEST_FILE_UBUNTU: "./tests/bin/Debug/HSPI_ZWaveParametersTest.dll"
jobs:
build-cache-test-win:
name: Build, cache and test on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Navigate to Workspace
run: cd $GITHUB_WORKSPACE
- name: Setup VS Dev Environment
uses: seanmiddleditch/gha-setup-vsdevenv@v4
- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5
- name: Set up JDK for Sonarcloud
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'oracle'
- name: Cache Nuget Packages
uses: actions/cache@v3
id: nuget
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Cache Sonar Scanner
uses: actions/cache@v3
id: sonar-scanner
with:
path: ~/.sonar
key: ${{ runner.os }}-${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
restore-keys: |
${{ runner.os }}-${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
- name: Cache DotCover
uses: actions/cache@v3
id: dotCover
with:
path: ~/.dotCover
key: ${{ runner.os }}-${{ env.DOTCOVER_DOWNLOAD_URL }}
restore-keys: |
${{ runner.os }}-${{ env.DOTCOVER_DOWNLOAD_URL }}
- name: Download and set up sonar-scanner
if: steps.sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Force -ItemType directory -Path $HOME\.sonar
Invoke-WebRequest -Uri ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} -OutFile $HOME\.sonar\sonar-scanner.zip
unzip -o $HOME\.sonar\sonar-scanner.zip -d $HOME\.sonar\
Remove-Item -Path $HOME\.sonar\sonar-scanner.zip
- name: Download and set up dotCover
if: steps.dotCover.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Force -ItemType directory -Path $HOME\.dotCover
Invoke-WebRequest -Uri ${{ env.DOTCOVER_DOWNLOAD_URL }} -OutFile $HOME\.dotCover\dotCover.zip
unzip -o $HOME\.dotCover\dotCover.zip -d $HOME\.dotCover\
Remove-Item -Path $HOME\.dotCover\dotCover.zip
- name: Restore Nuget Packages
run: nuget restore ${{ env.SLN_FILE }}
- name: Set Paths
run: |
echo "$HOME\.sonar" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "$HOME\.dotCover" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Start Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: SonarScanner.MSBuild.exe begin /k:"${{ env.SONAR_PROJECT_KEY }}" /o:"dk307" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:"sonar.cs.dotcover.reportsPaths=**\dotCover.html" /d:"sonar.cs.vstest.reportsPaths=**\*.trx"
- name: Build Debug
shell: powershell
run: msbuild.exe ${{ env.SLN_FILE }} /p:platform="Any CPU" /p:configuration="Debug"
- name: Upload unit tests binaries
id: unit-test-binaries
uses: actions/upload-artifact@v3
with:
path: .\tests\bin\Debug
name: Test-Files-${{ github.sha }}
- name: Upload binaries
id: test-binaries
uses: actions/upload-artifact@v3
with:
path: .\plugin\bin\Debug
name: Dll-Files-${{ github.sha }}
- name: Run tests
shell: powershell
run: dotCover.exe analyse /ReportType=HTML /Output="dotCover.html" "/TargetExecutable=%VSINSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" /TargetWorkingDir=. "/TargetArguments=${{ env.TEST_FILE_WIN }} /Parallel /logger:trx" /DisableNGen
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Windows Unit Tests
path: TestResults/*.trx
reporter: dotnet-trx
- name: End Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: SonarScanner.MSBuild.exe end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
cache-use-build-ubuntu:
name: Test on Ubuntu
runs-on: ubuntu-latest
needs: [build-cache-test-win]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Setup mono
run: |
sudo apt install dirmngr ca-certificates gnupg
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
- name: Navigate to Workspace
run: cd $GITHUB_WORKSPACE
- name: Download binaries
id: test-binaries
uses: actions/download-artifact@v2
with:
path: ./plugin/bin/Debug
name: Dll-Files-${{ github.sha }}
- name: Download unit tests binaries
uses: actions/download-artifact@v2
with:
path: ./tests/bin/Debug
name: Test-Files-${{ github.sha }}
- run: ls -l ./tests/bin/Debug
- name: Run Unit Tests
run: dotnet vstest --Parallel --logger:trx ${{ env.TEST_FILE_UBUNTU }}
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Ubuntu Unit Tests
path: TestResults/*.trx
reporter: dotnet-trx