-
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (84 loc) · 2.95 KB
/
ci.yml
File metadata and controls
104 lines (84 loc) · 2.95 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
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
build:
runs-on: windows-latest
name: Build & Test
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
dotnet-quality: "preview"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore -p:Platform=x64
- name: Lint (Check format)
run: dotnet format --verify-no-changes --no-restore
- name: Build Solution (Release)
run: dotnet build CopyPaste.slnx -c Release -p:Platform=x64 --no-restore
- name: Run Tests
run: dotnet test CopyPaste.slnx -c Release -p:Platform=x64 --no-build --verbosity normal --logger "console;verbosity=detailed"
sonarcloud:
name: SonarCloud
runs-on: windows-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
dotnet-quality: "preview"
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Install SonarScanner
run: dotnet tool install --global dotnet-sonarscanner
- name: SonarScanner Begin
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
dotnet sonarscanner begin
/k:"${{ vars.SONAR_PROJECT_KEY }}"
/o:"${{ vars.SONAR_ORGANIZATION }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
- name: Restore dependencies
run: dotnet restore -p:Platform=x64
- name: Build Solution
run: dotnet build CopyPaste.slnx -c Release -p:Platform=x64 --no-restore
- name: Run Tests with Coverage
run: >
dotnet test CopyPaste.slnx -c Release -p:Platform=x64 --no-build
--collect:"XPlat Code Coverage"
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: SonarScanner End
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"