-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (40 loc) · 1.41 KB
/
build_and_test.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
name: Build and Test Fluree.NET
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test with Code Coverage
run: |
dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
dotnet tool install --global dotnet-reportgenerator-globaltool
reportgenerator -reports:"/tests/IntegrationTests/coverage.opencover.xml" -targetdir:"./coverage" -reporttypes:Html
continue-on-error: true
- name: Create the Coverage Directory
run: mkdir -p ./coverage
- name: Check Code Coverage
run: |
coverage_threshold=90
coverage_file=$(find ./coverage -name index.htm)
coverage_percentage=$(grep -oP "Total\s*:\s*\K\d+\.\d+" "$coverage_file")
if (( $(echo "$coverage_percentage >= $coverage_threshold" | bc -l) )); then
echo "Code coverage is above $coverage_threshold% ($coverage_percentage%)"
else
echo "Code coverage is below $coverage_threshold% ($coverage_percentage%), failing the build."
exit 1
fi