Skip to content

Commit 7ee6d03

Browse files
committed
gh-65 combine unit test job with sonarqube
Signed-off-by: Victor Chang <[email protected]>
1 parent 203b8a8 commit 7ee6d03

File tree

2 files changed

+28
-45
lines changed

2 files changed

+28
-45
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99
push:
1010
paths-ignore:
1111
- 'demos/**'
12-
pull_request:
13-
paths-ignore:
14-
- 'demos/**'
1512

1613
# Allows you to run this workflow manually from the Actions tab
1714
workflow_dispatch:
@@ -90,19 +87,15 @@ jobs:
9087

9188
- name: Perform CodeQL Analysis
9289
uses: github/codeql-action/analyze@v1
90+
9391

9492
unit-test:
95-
runs-on: ${{ matrix.os }}
96-
strategy:
97-
matrix:
98-
os: [ubuntu-latest]
99-
fail-fast: true
100-
93+
runs-on: windows-latest
10194
steps:
102-
- name: Checkout repository
103-
uses: actions/checkout@v2
95+
- name: Set up JDK 11
96+
uses: actions/setup-java@v1
10497
with:
105-
fetch-depth: 0
98+
java-version: 1.11
10699

107100
- uses: actions/setup-dotnet@v1
108101
with:
@@ -116,67 +109,57 @@ jobs:
116109
restore-keys: |
117110
${{ runner.os }}-nuget
118111
119-
- name: Restore dependencies
120-
run: dotnet restore
121-
working-directory: ./src
122-
123-
- name: Build Solution
124-
run: dotnet build -c ${{ env.BUILD_CONFIG }} --nologo ${{ env.SOLUTION }}
125-
working-directory: ./src
126-
127-
- name: Run Unit Test
128-
run: dotnet test --filter FullyQualifiedName\!~Monai.Deploy.InformaticsGateway.Integration.Test -c ${{ env.BUILD_CONFIG }} -v=minimal --results-directory "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings ${{ env.SOLUTION }}
129-
working-directory: ./src
130-
131-
- uses: codecov/codecov-action@v2
132-
with:
133-
token: ${{ secrets.CODECOV_TOKEN }}
134-
directory: "src/${{ env.TEST_RESULTS }}"
135-
files: "**/coverage.opencover.xml"
136-
flags: unittests
137-
name: codecov-umbrella
138-
fail_ci_if_error: true
139-
verbose: true
140-
141-
sonar-qube:
142-
runs-on: windows-latest
143-
steps:
144-
- name: Set up JDK 11
145-
uses: actions/setup-java@v1
146-
with:
147-
java-version: 1.11
148112
- uses: actions/checkout@v2
149113
with:
150114
fetch-depth: 0
115+
151116
- name: Cache SonarCloud packages
152117
uses: actions/cache@v1
153118
with:
154119
path: ~\sonar\cache
155120
key: ${{ runner.os }}-sonar
156121
restore-keys: ${{ runner.os }}-sonar
122+
157123
- name: Cache SonarCloud scanner
158124
id: cache-sonar-scanner
159125
uses: actions/cache@v1
160126
with:
161127
path: .\.sonar\scanner
162128
key: ${{ runner.os }}-sonar-scanner
163129
restore-keys: ${{ runner.os }}-sonar-scanner
130+
164131
- name: Install SonarCloud scanner
165132
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
166133
shell: powershell
167134
run: |
168135
New-Item -Path .\.sonar\scanner -ItemType Directory
169-
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
136+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
137+
138+
- name: Restore dependencies
139+
run: dotnet restore
140+
working-directory: ./src
141+
170142
- name: Build and analyze
171143
env:
172144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173145
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
174146
shell: powershell
175147
run: |
176-
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Project-MONAI_monai-deploy-informatics-gateway" /o:"project-monai" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
148+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Project-MONAI_monai-deploy-informatics-gateway" /o:"project-monai" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
177149
dotnet build -c ${{ env.BUILD_CONFIG }} --nologo "src\${{ env.SOLUTION }}"
150+
dotnet test --filter FullyQualifiedName\!~Monai.Deploy.InformaticsGateway.Integration.Test -c ${{ env.BUILD_CONFIG }} -v=minimal --results-directory "src\${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings src\coverlet.runsettings "src\${{ env.SOLUTION }}"
178151
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
179152
153+
- uses: codecov/codecov-action@v2
154+
with:
155+
token: ${{ secrets.CODECOV_TOKEN }}
156+
directory: "src/${{ env.TEST_RESULTS }}"
157+
files: "**/coverage.opencover.xml"
158+
flags: unittests
159+
name: codecov-umbrella
160+
fail_ci_if_error: true
161+
verbose: true
162+
180163
build:
181164
runs-on: ${{ matrix.os }}
182165
needs: [calc-version]

src/DicomWebClient/Services/WadoService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public async Task<DicomFile> Retrieve(
101101

102102
try
103103
{
104-
await response.ToDicomAsyncEnumerable().FirstOrDefaultAsync();
104+
return await response.ToDicomAsyncEnumerable().FirstOrDefaultAsync();
105105
}
106106
catch (Exception ex)
107107
{
@@ -237,7 +237,7 @@ public async Task<T> RetrieveMetadata<T>(
237237

238238
try
239239
{
240-
await GetMetadata<T>(instancMetadataUri).FirstOrDefaultAsync();
240+
return await GetMetadata<T>(instancMetadataUri).FirstOrDefaultAsync();
241241
}
242242
catch (Exception ex) when (ex is not UnsupportedReturnTypeException)
243243
{

0 commit comments

Comments
 (0)