-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (63 loc) · 2.25 KB
/
dotnet.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
name: .NET
# Save energy - only build main branch updates
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build and test
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dotnet global tools (coverlet, reportgenerator)
run: |
dotnet tool install --global coverlet.console
dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Debug --no-restore
- name: Run tests
run: dotnet test --configuration Debug --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput='./TestResults/coverage.cobertura.xml'
- name: Generate coverage reports
run: reportgenerator "-reports:src/SaveEnergy.Tests/TestResults/*.xml;src/SaveEnergy.Specs/TestResults/*.xml" \
"-targetdir:report" \
"-reporttypes:Html;lcov" \
"-title:Save Energy"
- name: Attach coverage reports to build artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: report
publish-reports:
runs-on: ubuntu-latest
name: Publish coverage reports
needs: build-and-test
# Only publish coverage reports when building the main branch.
#
# This avoids exposing the secrets to attackers who debug print the
# secrets during the pull request verification build.
if: github.ref == 'refs/heads/main'
steps:
# the repository is required by codeclimate-action
- uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: coverage-reports
path: coverage-reports
- name: Publish coverage report to CodeClimate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: coverage-reports/lcov.info:lcov