Skip to content

Commit 59f6583

Browse files
committed
gh-65 Update sonarqube ci job
Signed-off-by: Victor Chang <[email protected]>
1 parent 536581f commit 59f6583

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
uses: github/codeql-action/analyze@v1
9090

9191
unit-test:
92-
runs-on: windows-latest
92+
runs-on: ubuntu-latest
9393
steps:
9494
- name: Set up JDK 11
9595
uses: actions/setup-java@v1
@@ -111,43 +111,41 @@ jobs:
111111
- uses: actions/checkout@v2
112112
with:
113113
fetch-depth: 0
114-
115-
- name: Cache SonarCloud packages
116-
uses: actions/cache@v1
117-
with:
118-
path: ~\sonar\cache
119-
key: ${{ runner.os }}-sonar
120-
restore-keys: ${{ runner.os }}-sonar
121-
122-
- name: Cache SonarCloud scanner
123-
id: cache-sonar-scanner
124-
uses: actions/cache@v1
125-
with:
126-
path: .\.sonar\scanner
127-
key: ${{ runner.os }}-sonar-scanner
128-
restore-keys: ${{ runner.os }}-sonar-scanner
129-
114+
130115
- name: Install SonarCloud scanner
131116
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
132-
shell: powershell
133-
run: |
134-
New-Item -Path .\.sonar\scanner -ItemType Directory
135-
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
117+
run: dotnet tool install --global dotnet-sonarscanner
136118

137119
- name: Restore dependencies
138120
run: dotnet restore
139121
working-directory: ./src
140122

141-
- name: Build & Test
123+
- name: Begin SonarScanner
142124
env:
143125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144126
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
145-
shell: powershell
146-
run: |
147-
..\.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" /d:sonar.cs.opencover.reportsPaths="src\${{ env.TEST_RESULTS }}\**\*.xml"
148-
dotnet build -c ${{ env.BUILD_CONFIG }} --nologo "${{ env.SOLUTION }}"
149-
Get-ChildItem -Recurse | Where-Object { $_.Name -like "*Test.csproj" } | ForEach-Object { dotnet test -c ${{ env.BUILD_CONFIG }} -v=minimal -r "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings $_.FullName }
150-
..\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
127+
run: 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" /d:sonar.cs.opencover.reportsPaths="${{ env.TEST_RESULTS }}/**/*.xml"
128+
working-directory: ./src
129+
130+
- name: Build
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
134+
run: dotnet build -c ${{ env.BUILD_CONFIG }} --nologo "${{ env.SOLUTION }}"
135+
working-directory: ./src
136+
137+
- name: Test
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
141+
run: find ~+ -type f -name "*.Test.csproj" | xargs -L1 dotnet test -c ${{ env.BUILD_CONFIG }} -v=minimal -r "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings
142+
working-directory: ./src
143+
144+
- name: End SonarScanner
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
148+
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
151149
working-directory: ./src
152150

153151
- uses: codecov/codecov-action@v2

0 commit comments

Comments
 (0)