-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (95 loc) · 4.11 KB
/
tests.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
name: 'Tests'
on:
workflow_dispatch: # To can dispatch manually
pull_request:
types: [opened, reopened, edited, synchronize]
branches:
- main
env:
SDK_VERSION_8: '8.0.404'
SDK_VERSION_7: '7.0.410'
SDK_VERSION_6: '6.0.428'
SDK_VERSION_5: '5.0.408'
SDK_VERSION_3: '3.1.426'
TEST_RESULTS_DIRECTORY: './TestResults'
jobs:
test-project:
name: "Test nuget"
runs-on: ubuntu-22.04
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: "Checkout"
uses: actions/checkout@v4.2.2
- name: "Setup .NET"
uses: actions/setup-dotnet@v4.3.0
with:
global-json-file: 'global.json'
dotnet-version: |
${{ env.SDK_VERSION_8 }}
${{ env.SDK_VERSION_7 }}
${{ env.SDK_VERSION_6 }}
${{ env.SDK_VERSION_5 }}
${{ env.SDK_VERSION_3 }}
- name: "Restore dependencies"
run: dotnet restore
- name: "Build"
run: dotnet build --configuration Release --no-restore
- name: "Run tests"
run: dotnet test --configuration Release --no-build --verbosity normal --results-directory ${{ env.TEST_RESULTS_DIRECTORY }} --collect:"XPlat Code Coverage"
- name: "Combine Coverage Reports" # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/ReportGenerator-GitHub-Action@5.4.4
with:
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
reporttypes: "Cobertura" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "Code Coverage" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
- name: "Upload Combined Coverage"
uses: actions/upload-artifact@v4
with:
name: 'Coverage'
path: ${{ github.workspace }}/Cobertura.xml
- name: "Publish code coverage report"
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false # just informative for now
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30"
- name: "Add Coverage PR Comment"
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: "Upload Test Results"
uses: actions/upload-artifact@v4
with:
name: 'TestResults'
path: ${{ env.TEST_RESULTS_DIRECTORY }}/**/*
- name: "Publish Test Tesults"
uses: dorny/test-reporter@v1
if: always()
with:
name: "Test Results"
path: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"
reporter: dotnet-trx
- name: "Publish Test Summary"
uses: EnricoMi/publish-unit-test-result-action@v2.18.0
if: always()
with:
check_name: "Test Summary"
# NOTE: using trx_files instead of files due to https://github.com/EnricoMi/publish-unit-test-result-action/issues/424
trx_files: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"