-
Notifications
You must be signed in to change notification settings - Fork 20
124 lines (107 loc) · 3.97 KB
/
Copy pathbuild-test-template.yml
File metadata and controls
124 lines (107 loc) · 3.97 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
118
119
120
121
122
123
124
---
name: Build and run tests
on:
workflow_call:
inputs:
configuration:
description: "dotnet build configuration"
required: false
type: string
default: "Debug"
publish-coverage:
description: "publish coverage to codecov"
required: false
type: boolean
default: true
run-js-tests:
description: "Run JS/TS tests"
required: false
type: boolean
default: false
secrets:
CODECOV_TOKEN:
required: true
permissions:
contents: read
id-token: write
env:
CONFIGURATION: ${{ inputs.configuration }}
jobs:
build_and_test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup .NET 10, 9, 8, 7, 6
uses: actions/setup-dotnet@v5.0.0
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x
- name: Install WASM tools Workloads
run: |
dotnet workload install wasm-tools --ignore-failed-sources
- name: Restore dependencies
run: dotnet restore
working-directory: src/Cropper.Blazor
- name: Restore dotnet tool
run: dotnet tool restore
working-directory: src/Cropper.Blazor/Cropper.Blazor
- name: DotNet Build
run: dotnet build -c "$CONFIGURATION" --no-restore
working-directory: src/Cropper.Blazor
- name: Test
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByAttribute='ExcludeFromCodeCoverage' /p:SkipAutoProps=true /p:Exclude="[*]Cropper.Blazor.Testing.*"
working-directory: src/Cropper.Blazor/Cropper.Blazor.UnitTests
- name: Run JS/TS tests and generate coverage
if: ${{ inputs.run-js-tests == true }}
run: |
cd Cropper.Blazor
npm run coverage
working-directory: src/Cropper.Blazor
- name: Verify coverage files
working-directory: src/Cropper.Blazor
run: |
FILES=(
Cropper.Blazor.UnitTests/coverage.net6.0.cobertura.xml
Cropper.Blazor.UnitTests/coverage.net7.0.cobertura.xml
Cropper.Blazor.UnitTests/coverage.net8.0.cobertura.xml
Cropper.Blazor.UnitTests/coverage.net9.0.cobertura.xml
Cropper.Blazor.UnitTests/coverage.net10.0.cobertura.xml
)
if [ "${{ inputs.run-js-tests }}" = "true" ]; then
FILES+=("Cropper.Blazor/coverage/cobertura-coverage.xml")
fi
for file in "${FILES[@]}"; do
if [ ! -f "$file" ]; then
echo "❌ Coverage file missing: $file"
exit 1
fi
echo "✅ Found $file"
done
- name: Upload DotNet coverage to Codecov
if: ${{ inputs.publish-coverage == true }}
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/Cropper.Blazor/Cropper.Blazor.UnitTests/coverage.net6.0.cobertura.xml,src/Cropper.Blazor/Cropper.Blazor.UnitTests/coverage.net7.0.cobertura.xml,src/Cropper.Blazor/Cropper.Blazor.UnitTests/coverage.net8.0.cobertura.xml,src/Cropper.Blazor/Cropper.Blazor.UnitTests/coverage.net9.0.cobertura.xml,src/Cropper.Blazor/Cropper.Blazor.UnitTests/coverage.net10.0.cobertura.xml
flags: DotNet
fail_ci_if_error: true
disable_search: true
verbose: true
- name: Upload TypeScript coverage to Codecov
if: ${{ inputs.publish-coverage == true && inputs.run-js-tests == true }}
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/Cropper.Blazor/Cropper.Blazor/coverage/cobertura-coverage.xml
flags: TypeScript
fail_ci_if_error: true
disable_search: true
verbose: true