Repository navigation
91 lines (77 loc) · 3.22 KB
/
Copy pathcodecoverage.yml
File metadata and controls
91 lines (77 loc) · 3.22 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
name: Code Coverage
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
workflow_dispatch:
jobs:
codecoverage:
name: "Code Coverage"
env:
ASPNETCORE_ENVIRONMENT: "Production"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Restore Nuget Packages
run: dotnet restore Shared.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
- name: Build Code
run: dotnet build Shared.sln --configuration Release
- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "Shared.Tests/Shared.Tests.csproj" \
--results-directory "coverage/Shared.Tests" \
--coverlet --coverlet-output-format lcov --coverlet-file-prefix Shared.Tests \
--coverlet-exclude "[xunit*]*" \
--coverlet-exclude-by-attribute Obsolete \
--coverlet-exclude-by-attribute GeneratedCodeAttribute \
--coverlet-exclude-by-attribute CompilerGeneratedAttribute \
--coverlet-exclude-by-attribute ExcludeFromCodeCoverageAttribute
dotnet test "Shared.EventStore.Tests/Shared.EventStore.Tests.csproj" \
--results-directory "coverage/Shared.EventStore.Tests" \
--coverlet --coverlet-output-format lcov --coverlet-file-prefix Shared.EventStore.Tests \
--coverlet-exclude "[xunit*]*" \
--coverlet-exclude-by-attribute Obsolete \
--coverlet-exclude-by-attribute GeneratedCodeAttribute \
--coverlet-exclude-by-attribute CompilerGeneratedAttribute \
--coverlet-exclude-by-attribute ExcludeFromCodeCoverageAttribute
- name: Inspect coverage reports
run: |
echo "Files produced under coverage/:"
find coverage -type f -print
mapfile -t reports < <(find coverage -type f -name '*.info' -print)
if [ ${#reports[@]} -eq 0 ]; then
echo "::error::No LCOV reports were generated by the test runs."
exit 1
fi
for report in "${reports[@]}"; do
echo "--- $report ($(wc -c < "$report") bytes) ---"
if [ ! -s "$report" ]; then
echo "::error::LCOV report is empty: $report"
exit 1
fi
grep '^SF:' "$report" || true
done
- name: Install LCOV merger
run: npm install -g lcov-result-merger
- name: Merge LCOV reports
run: |
set -euo pipefail
mapfile -t reports < <(find coverage -type f -name '*.info' -print)
if [ ${#reports[@]} -eq 0 ]; then
echo "::error::No LCOV reports found to merge."
exit 1
fi
lcov-result-merger "coverage/**/*.info" > lcov.info
if [ ! -s lcov.info ] || ! grep -q '^SF:' lcov.info; then
echo "::error::The merged LCOV report is empty or has no source-file records."
exit 1
fi
echo "Merged report source files:"
grep '^SF:' lcov.info
- name: Upload merged coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./lcov.info