-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontinuous-integration-dotnet.yml
More file actions
76 lines (63 loc) · 3.05 KB
/
Copy pathcontinuous-integration-dotnet.yml
File metadata and controls
76 lines (63 loc) · 3.05 KB
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
name: .NET Build and Test
on:
push:
branches:
- main
- develop
pull_request:
env:
JAVA_VERSION: 21
DOTNET_VERSION: 10.0.x
jobs:
build-test:
runs-on: ubuntu-latest
env:
# Note: The database name may be overridden by the tests
CONNECTION_STRING: 'Server=localhost,1433;Database=integrationtests;User Id=sa;Password=P1swrd!$;TrustServerCertificate=True;integrated security=false;'
CONNECTION_STRING_KEY: 'ConnectionStrings:DefaultConnection'
services:
sql-server:
image: mcr.microsoft.com/mssql/server@sha256:86cc6144ef39bb0fbed2329e1ad79b13ee82e7b2e4739213a0db0800e668a74a
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: P1swrd!$
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis
- name: Setup .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@d9cee638f295eca3c446655c8785a383cf94bbc3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'microsoft'
- name: Add nuget package source
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json"
- name: Cache SonarCloud packages
uses: actions/cache@1513bf9d27bd268e7fde1197dedbe54ff66f1e0c # v5.0.0
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Install SonarCloud scanners
run: dotnet tool install --global dotnet-sonarscanner
- name: Install dotnet reportgenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Restore dependencies
run: dotnet restore Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.sln
- name: Build solution, test and run SonarCloud scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"DFE-Digital_manage-free-schools-projects" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /s:${{ github.workspace }}/SonarQube.Analysis.xml
dotnet build Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.sln --no-restore
dotnet test Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.sln --no-build --verbosity normal --collect:"XPlat Code Coverage" --environment "${{ env.CONNECTION_STRING_KEY }}"="${{ env.CONNECTION_STRING }}"
reportgenerator -reports:"./**/coverage.cobertura.xml" -targetdir:./Dfe.ManageFreeSchoolProjects/CoverageReport -reporttypes:SonarQube
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"