-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (104 loc) · 3.51 KB
/
Copy pathunit-tests.yml
File metadata and controls
117 lines (104 loc) · 3.51 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
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Unit Tests
on:
push:
branches-ignore: [master]
pull_request:
branches: [master]
workflow_dispatch:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
check-duplicate:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- id: check
run: |
count=$(gh pr list --repo "${{ github.repository }}" \
--head "${{ github.ref_name }}" --base master \
--json number --jq 'length')
echo "skip=$([ "$count" -gt 0 ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
unit-tests:
needs: [check-duplicate]
if: always() && (github.event_name != 'push' || needs.check-duplicate.outputs.skip == 'false')
runs-on: windows-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup dotnet
id: setup-dotnet
uses: actions/setup-dotnet@v6
with:
global-json-file: src/global.json
- name: Setup report generator
run: dotnet.exe tool install -g dotnet-reportgenerator-globaltool
- name: Run CLI tests
run: |
cd src
dotnet.exe test `
--project .\Tests.Cli\Tests.Cli.csproj `
--configuration Release `
--runtime win-x64 `
--output Detailed `
--diagnostic `
--diagnostic-output-directory diags `
--config-file .\testconfig.json `
--coverage
- name: Run Application tests
run: |
cd src
dotnet.exe test `
--project .\Tests.Application\Tests.Application.csproj `
--configuration Release `
--runtime win-x64 `
--output Detailed `
--diagnostic `
--diagnostic-output-directory diags `
--config-file .\testconfig.json `
--coverage
- name: Run report generator
if: always()
run: |
reportgenerator.exe `
-reports:**/*.cobertura.xml `
-targetdir:${{ github.workspace }}/coveragereport `
-reporttypes:'HtmlInline;MarkdownSummaryGithub' `
-title:'Code Coverage' `
-tag:${{ github.run_number }}_${{ github.run_id }}
- name: Upload test result artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results
path: |
${{ github.workspace }}/**/diags/**/*
${{ github.workspace }}/**/TestResults/**/*
if-no-files-found: error
- name: Upload coverage report artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: coverage-report
path: ${{ github.workspace }}/**/coveragereport/**/*
if-no-files-found: error
- name: Add coverage pr comment
if: github.event_name == 'pull_request'
run: gh pr comment $env:PR_NUMBER --edit-last --create-if-none --body-file coveragereport/SummaryGithub.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Publish coverage in build summary
run: Get-Content coveragereport/SummaryGithub.md -Raw |Add-Content $env:GITHUB_STEP_SUMMARY