-
Notifications
You must be signed in to change notification settings - Fork 4
139 lines (118 loc) · 4.76 KB
/
ci.yml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
schedule:
- cron: '1 0 * * 1' # * is a special character in YAML, therefore this string needs to be quoted
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
ARTIFACT_DIR: ./Artifacts
PROJECT_NAME: DotnetCombine
PROJECT_ALIAS: dotnet-combine
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup .NET 5 fpr sonar
uses: actions/setup-dotnet@v3
if: matrix.os == 'windows-latest'
with:
dotnet-version: 5.0.x
- name: Setup java (for SonarCloud)
uses: actions/setup-java@v3
if: matrix.os == 'windows-latest'
with:
java-version: 11
distribution: 'zulu'
- name: '[Windows] Cache SonarCloud packages'
uses: actions/cache@v3
if: matrix.os == 'windows-latest'
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: '[Windows] Cache SonarCloud scanner'
id: cache-sonar-scanner
if: matrix.os == 'windows-latest'
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: '[Windows] Install SonarCloud scanner'
if: matrix.os == 'windows-latest' && steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: '[Windows] Prepare SonarCloud analysis'
if: matrix.os == 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN2 }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"eduherminio_dotnet-combine" /o:"eduherminio-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.scanner.force-deprecated-java-version=true
- name: '[Ubuntu] Set version to -ci-${{ github.run_number }}'
if: matrix.os == 'ubuntu-latest'
shell: pwsh
run: |
$input_path = "Directory.Build.props"
$regex = "(?<=<Version>).*(?=</Version>)"
(Get-Content $input_path) -Replace $regex, '$0-ci-${{ github.run_number }}' | Out-File $input_path
- name: Build
run: dotnet build -c Release /p:DeterministicBuild=true
- name: Run tests
run: dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
- name: '[Ubuntu] Pack'
if: matrix.os == 'ubuntu-latest'
run: |
dotnet pack -c Release --no-build src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj --include-symbols -o ${{ env.ARTIFACT_DIR }}
- name: '[Ubuntu] Upload Artifact'
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_ALIAS }}-ci-${{ github.run_number }}
path: |
${{ env.ARTIFACT_DIR }}/*.nupkg
${{ env.ARTIFACT_DIR }}/*.snupkg
if-no-files-found: error
- name: '[Windows] Generate test coverage report'
if: matrix.os == 'windows-latest'
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: 'tests/**/*.cobertura.xml'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline_AzurePipelines_Dark;SonarQube'
assemblyfilters: '+*'
classfilters: '+*;-*Exception;-*Program'
filefilters: '+*'
verbosity: 'Info'
title: '${{ env.PROJECT_ALIAS }} #${{ github.run_number }} (${{ env.GITHUB_REF_SLUG }})'
tag: '${{ github.run_number }}_${{ github.run_id }}'
customSettings: 'numberOfReportsParsedInParallel=3;numberOfReportsMergedInParallel=3'
- name: '[Windows] Upload test coverage report'
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_ALIAS }}-coverage-ci-${{ github.run_number }}
path: coveragereport/
if-no-files-found: error
- name: '[Windows] Perform SonarCloud analysis'
if: matrix.os == 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN2 }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"