-
Notifications
You must be signed in to change notification settings - Fork 887
133 lines (117 loc) · 4.57 KB
/
Component.BuildTest.yml
File metadata and controls
133 lines (117 loc) · 4.57 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
125
126
127
128
129
130
131
132
133
# Called by ci.yml to build & test project files
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
name: Build Component
on:
workflow_call:
inputs:
project-name:
required: true
type: string
project-build-commands:
default: ''
required: false
type: string
code-cov-name:
required: true
type: string
code-cov-prefix:
default: 'unittests'
required: false
type: string
os-list:
default: '[ "windows-latest", "windows-11-arm", "ubuntu-22.04", "ubuntu-22.04-arm" ]'
required: false
type: string
tfm-list:
default: '[ "net462", "net8.0", "net9.0", "net10.0" ]'
required: false
type: string
permissions:
contents: read
jobs:
build-test:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
os: ${{ fromJSON(inputs.os-list) }}
version: ${{ fromJSON(inputs.tfm-list) }}
exclude:
- os: ubuntu-22.04
version: net462
- os: ubuntu-22.04-arm
version: net462
- os: ubuntu-22.04-arm
version: net10.0
- os: windows-11-arm
version: net10.0
runs-on: ${{ matrix.os }}
timeout-minutes: 30
env:
PROJECT_NAME: ${{ inputs.project-name }}
PROJECT_BUILD_COMMANDS: ${{ inputs.project-build-commands }}
TARGET_FRAMEWORK: ${{ matrix.version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Note: By default GitHub only fetches 1 commit. MinVer needs to find
# the version tag which is typically NOT on the first commit so we
# retrieve them all.
fetch-depth: 0
- name: Setup previous .NET runtimes
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: |
8.0.x
9.0.x
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
- name: dotnet restore ${{ inputs.project-name }}
shell: pwsh
run: dotnet restore ${env:PROJECT_NAME} ${env:PROJECT_BUILD_COMMANDS}
- name: dotnet build ${{ inputs.project-name }}
shell: pwsh
run: dotnet build ${env:PROJECT_NAME} --configuration Release --no-restore ${env:PROJECT_BUILD_COMMANDS}
- name: dotnet test ${{ inputs.project-name }}
shell: pwsh
run: >
dotnet test ${env:PROJECT_NAME}
--collect:"Code Coverage"
--results-directory:TestResults
--framework ${env:TARGET_FRAMEWORK}
--configuration Release
--no-restore
--no-build
--logger:"console;verbosity=detailed"
--logger:"GitHubActions;report-warnings=false"
--logger:"junit;LogFilePath=TestResults/junit.xml"
-- RunConfiguration.DisableAppDomain=true
- name: Install coverage tool
shell: pwsh
env:
# renovate: datasource=nuget depName=dotnet-coverage
DOTNET_COVERAGE_VERSION: '18.6.2'
run: dotnet tool install -g dotnet-coverage --version ${env:DOTNET_COVERAGE_VERSION}
- name: Merging test results
run: dotnet-coverage merge -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/**/*.coverage
- name: Upload code coverage ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
continue-on-error: true # Note: Don't fail for upload failures
env:
OS: ${{ matrix.os }}
TFM: ${{ matrix.version }}
with:
files: TestResults/Cobertura.xml
env_vars: OS,TFM
flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
name: Code Coverage for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}]
codecov_yml_path: .github/codecov.yml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
if: ${{ !cancelled() && hashFiles('./**/TestResults/junit.xml') != '' }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
env_vars: OS,TFM
flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
name: Test results for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}]
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}