Repository navigation
50 lines (41 loc) · 2.24 KB
/
Copy pathcodecoverage.yml
File metadata and controls
50 lines (41 loc) · 2.24 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
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 CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
- name: Build Code
run: dotnet build CallbackHandler.sln --configuration Release
- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
mkdir -p coverage/cob1 coverage/cob2 coverage/cob3
dotnet test "CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj" --configuration Release --no-build --verbosity normal --coverlet --coverlet-output-format cobertura --results-directory "${{ github.workspace }}/coverage/cob1"
dotnet test "CallbackHandler.CallbackMessageAggregate.Tests/CallbackHandler.CallbackMessageAggregate.Tests.csproj" --configuration Release --no-build --verbosity normal --coverlet --coverlet-output-format cobertura --results-directory "${{ github.workspace }}/coverage/cob2"
dotnet test "CallbackHandler.Tests/CallbackHandler.Tests.csproj" --configuration Release --no-build --verbosity normal --coverlet --coverlet-output-format cobertura --results-directory "${{ github.workspace }}/coverage/cob3"
for directory in coverage/cob1 coverage/cob2 coverage/cob3; do
report=$(find "$directory" -type f -name 'coverage*.xml' -print -quit)
if [ -z "$report" ]; then
echo "No Cobertura coverage report found in $directory"
exit 1
fi
if [ "$report" != "$directory/coverage.cobertura.xml" ]; then
cp "$report" "$directory/coverage.cobertura.xml"
fi
done
- name: Upload merged coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage/cob1/coverage.cobertura.xml,./coverage/cob2/coverage.cobertura.xml,./coverage/cob3/coverage.cobertura.xml