Skip to content

Commit d77a2ea

Browse files
Merge pull request #663 from PathfinderHonorManager/develop
SQ CI integration
2 parents 265868f + d140222 commit d77a2ea

File tree

3 files changed

+59
-91
lines changed

3 files changed

+59
-91
lines changed

.github/workflows/develop_codeql_analysis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/develop_pathfinderhonormanager.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/main_pathfinderhonormanager.yml

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,74 @@
11
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
22
# More GitHub Actions for Azure: https://github.com/Azure/actions
33

4-
name: Analyze, build and deploy to Azure prod
4+
name: Build, Analyze and Deploy
55

66
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
79
push:
810
branches:
911
- main
10-
# workflow_dispatch:
12+
workflow_dispatch:
1113

1214
jobs:
15+
# Quality checks that can run in parallel
16+
sonar:
17+
name: SonarQube Analysis
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- uses: ./.github/actions/setup-dotnet
25+
26+
- name: Cache SonarQube packages
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.sonar/cache
30+
key: ${{ runner.os }}-sonar
31+
restore-keys: ${{ runner.os }}-sonar
32+
33+
- name: Cache SonarQube scanner
34+
id: cache-sonar-scanner
35+
uses: actions/cache@v4
36+
with:
37+
path: ./.sonar/scanner
38+
key: ${{ runner.os }}-sonar-scanner
39+
restore-keys: ${{ runner.os }}-sonar-scanner
40+
41+
- name: Install SonarQube scanner
42+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
43+
run: |
44+
mkdir -p ./.sonar/scanner
45+
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
46+
47+
- name: Run SonarQube analysis
48+
env:
49+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
50+
run: |
51+
./.sonar/scanner/dotnet-sonarscanner begin /k:"PathfinderHonorManager_PathfinderHonorManagerAPI" /o:"pathfinderhonormanager" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="PathfinderHonorManager.Tests/TestResults/coverage.opencover.xml"
52+
dotnet build
53+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
54+
1355
test:
1456
name: Test
1557
runs-on: ubuntu-latest
16-
1758
steps:
1859
- uses: actions/checkout@v4
1960

2061
- uses: ./.github/actions/setup-dotnet
2162

22-
- name: Test with the dotnet CLI
23-
run: dotnet test
24-
63+
- name: Test with the dotnet CLI (OpenCover)
64+
run: dotnet test PathfinderHonorManager.Tests/PathfinderHonorManager.Tests.csproj /p:CollectCoverage=true /p:CoverletOutput=TestResults/coverage.opencover.xml /p:CoverletOutputFormat=opencover
65+
66+
- name: Upload coverage report
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: coverage-report
70+
path: PathfinderHonorManager.Tests/TestResults/coverage.opencover.xml
71+
2572
analyze:
2673
name: Analyze
2774
runs-on: ubuntu-latest
@@ -51,10 +98,11 @@ jobs:
5198

5299
- name: Perform CodeQL Analysis
53100
uses: github/codeql-action/analyze@v3
101+
102+
# Build job that depends on quality checks
54103
build:
55-
needs: [analyze, test]
104+
needs: [sonar, test, analyze]
56105
runs-on: ubuntu-latest
57-
58106
steps:
59107
- uses: actions/checkout@v4
60108

@@ -66,7 +114,6 @@ jobs:
66114
- name: dotnet publish
67115
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
68116

69-
#substitute production appsettings entries to appsettings json file
70117
- name: App Settings Variable Substitution
71118
uses: microsoft/variable-substitution@v1
72119
with:
@@ -81,12 +128,14 @@ jobs:
81128
name: .net-app
82129
path: ${{env.DOTNET_ROOT}}/myapp
83130

131+
# Deployment job that only runs on main
84132
deploy:
85-
runs-on: ubuntu-latest
86133
needs: build
134+
runs-on: ubuntu-latest
87135
environment:
88136
name: 'Production'
89137
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
138+
if: github.ref == 'refs/heads/main'
90139

91140
steps:
92141
- name: Download artifact from build job

0 commit comments

Comments
 (0)