-
Notifications
You must be signed in to change notification settings - Fork 82
61 lines (57 loc) · 1.93 KB
/
build.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
name: Build and test
on:
push:
paths-ignore:
- '**.md'
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.head_ref || github.sha }}
cancel-in-progress: true
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_DOTNET_ENABLE_CONCURRENT_EXECUTION: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'microsoft' # See 'Supported distributions' for available options
java-version: '17'
- name: Setup dotnet
uses: actions/[email protected]
with:
dotnet-version: '8.x'
- name: Install dotnet-sonarscanner
run: |
dotnet tool install --global dotnet-sonarscanner
- name: Install dotnet-coverage
run: |
dotnet tool install --global dotnet-coverage
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
key: nuget-${{ hashFiles('Directory.Packages.props') }}
path: ~/.nuget/packages
- name: Build the project, run all tests and publish to SonarCloud
run: |
dotnet sonarscanner begin \
/k:"yanpitangui_dotnet-api-boilerplate" \
/o:"yanpitangui" \
/d:sonar.token="$SONAR_TOKEN" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build WebApiBoilerplate.sln --no-incremental
dotnet-coverage collect 'dotnet test WebApiBoilerplate.sln' -f xml -o 'coverage.xml'
dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"