-
-
Notifications
You must be signed in to change notification settings - Fork 749
170 lines (142 loc) · 4.64 KB
/
coverage.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Main Branch Coverage
on:
push:
branches:
- main
paths:
- 'src/**'
concurrency:
group: main-coverage
cancel-in-progress: true
jobs:
configure:
name: Generate Test Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout to repository
uses: actions/checkout@v3
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.x
8.x
- name: Generate Test Matrix
run: dotnet run --project ./.build -- GenerateMatrix
- name: Export Test Matrix
id: set-matrix
run: echo "matrix=$(jq -c . < ./matrix.json)" >> $GITHUB_OUTPUT
library-tests:
name: Run ${{ matrix.name }}
runs-on: ubuntu-latest
needs: configure
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.x
7.x
8.x
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Run Build
id: run-build
run: dotnet build ${{ matrix.path }} --framework net7.0 --verbosity q --property WarningLevel=0
timeout-minutes: 5
- name: Run tests
id: run-tests
timeout-minutes: 15
continue-on-error: true
run: dotnet test ${{ matrix.path }} --no-build --framework net7.0 --verbosity q /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./.coverage/${{ matrix.name }}.xml --logger "trx;LogFileName=./.test-results/${{ matrix.name }}.trx" /p:ExcludeByFile="**/test/**"
env:
CI_BUILD: true
- name: Upload Test Results as Artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results-${{ matrix.name }}
path: ./.test-results/*.trx
- name: Upload mismatch files as Artifacts
if: failure()
uses: actions/upload-artifact@v2
with:
name: mismatch-files-${{ matrix.name }}
path: |
**/__mismatch__/*
- name: Copy test results
continue-on-error: true
run: |
mkdir -p ./output/coverage
cp "${{ matrix.directoryPath }}/.coverage/${{ matrix.name }}.net7.0.xml" ./output/coverage/
- name: Upload Individual Coverage Files as Artifacts
uses: actions/upload-artifact@v2
with:
name: coverage-${{ matrix.name }}
path: ./output/coverage/*.xml
- name: Fail if tests failed or were cancelled
run: exit 1
if: |
steps.run-tests.outcome == 'failure' ||
steps.run-tests.outcome == 'cancelled'
merge-coverage:
name: Merge and Upload Coverage
needs: library-tests
if: always() && needs.library-tests.result != 'cancelled'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.x
7.x
8.x
- uses: actions/cache@v3
if: ${{ !cancelled() }}
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Create All.sln
if: ${{ !cancelled() }}
run: ./build.sh CreateAllSln
- name: Build
if: ${{ !cancelled() }}
run: dotnet build ./src/All.sln
- name: Download all coverage artifacts
uses: actions/download-artifact@v2
with:
path: ./output/download
- name: Merge Coverage Files
if: ${{ !cancelled() }}
timeout-minutes: 10
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator "-reports:./output/download/**/*.xml" "-targetdir:./output/coverage/merged" -reporttypes:Opencover -license:$ReportGenerator_License
env:
ReportGenerator_License: ${{ secrets.REPORTGENERATOR_LICENSE }}
- name: Upload Combined Coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v2
timeout-minutes: 10
with:
file: ./output/coverage/merged/OpenCover.xml
token: ${{ secrets.CODECOV_TOKEN }}
name: graphql-platform
flags: unittests
fail_ci_if_error: true