-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (153 loc) · 6.73 KB
/
ct-matrix.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# This workflow is used test the project, by doing the following
# 1. Ensure the project builds
# 2. Run all tests
# 3. Upload code coverage
---
name: Testing Matrix
run-name: >-
${{
format(
'{0} - Continuous Testing (Matrix){1}',
github.event_name == 'pull_request'
&& format('PR#{0}{1}',github.event.number, github.event.pull_request.draft && ' [DRAFT]' || '')
|| format('Push [{0}]', github.ref_name),
github.event_name == 'pull_request'
&& format(' - [{0}-to-{1}]', github.event.pull_request.head.ref, github.event.pull_request.base.ref)
|| ''
)
}}
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
types:
- opened
- reopened
- synchronize
- ready_for_review
# Trigger if target branch was changed to a trunk
pull_request_target:
types:
- edited
branches:
- main
- develop
env:
build_directory: Build
test_project_suffix: Tests
concurrency:
group: Continuous-Testing-${{ github.event.pull_request.head.ref }}-to-${{ github.event.pull_request.base.ref }}
cancel-in-progress: true
jobs:
tests:
name: Continuous Testing # Note: This name & matrix are used within the status checks - do not change
permissions:
contents: read # Read access to code and content in the repository
pull-requests: read # Read access to pull request metadata for the event
checks: write # Write access to report check results
runs-on: windows-2022
if: ${{ !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
solution: [Testing.sln]
dotnet-version: ["8.0.x"]
steps:
- name: ${{ format('Checkout [{0}]', github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name) }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }}
submodules: recursive
####################################################################################################
### Initialize ###
####################################################################################################
# Check for Changes in the Non-Ignored Files; If there are none, then Skip Tests
# Skip: README, CHANGELOG, LICENSE, THIRD-PARTY-LICENSES, .gitignore, GitHub Workflows & Actions, etc.
- name: Check for Changes to Determine if Tests can be Skipped
id: getChanges
uses: tj-actions/[email protected]
with:
files_ignore: |
README.md
CHANGELOG.md
LICENSE
THIRD-PARTY-LICENSES
.github/**
.gitignore
- name: Check if Tests can be Skipped
id: getCanSkip
uses: actions/[email protected]
with:
result-encoding: string
script: |
var changes = '${{ fromJSON(steps.getChanges.outputs.any_modified) }}'
var skip = changes == 'false'
console.log('Skip:', skip)
return skip
####################################################################################################
### Prepare to Run Tests ###
####################################################################################################
- name: Setup .NET [${{ matrix.dotnet-version }}]
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Setup NuGet
uses: NuGet/[email protected]
- name: Restore NuGet
run: nuget restore
- name: Restore Dependencies
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
run: dotnet restore
####################################################################################################
### Run Tests ###
####################################################################################################
# Test 1 - Build Solution
- name: Build
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
run: dotnet build --no-restore
- name: Error - Build Failed for ${{ matrix.solution }}
if: failure()
uses: ./.github/actions/tools/annotation/error
with:
message: "[Error] Build Failed for ${{ matrix.solution }}"
# Test 2 - Run All Unit Tests within Project
- name: Run Tests for [${{ matrix.solution }}]
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
run: dotnet test --no-build --verbosity normal --collect "XPlat Code Coverage"
- name: Error - Tests Failed for ${{ matrix.solution }}
if: failure()
uses: ./.github/actions/tools/annotation/error
with:
message: "[Error] Tests Failed for ${{ matrix.solution }}"
####################################################################################################
### Code Coverage ###
####################################################################################################
# Upload results to codecov if the actor is the repository owner
- name: Upload Results to Codecov (Optional) [${{ github.actor }}]
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) && github.actor == 'TylerCarrol' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "**/TestResults/**/coverage.cobertura.xml"
flags: unit-tests
fail_ci_if_error: true
verbose: true
####################################################################################################
### Notify Success ###
####################################################################################################
- name: Success - Successfully Built & Ran Tests for ${{ matrix.solution }}
if: success() && !fromJSON(steps.getCanSkip.outputs.result)
uses: ./.github/actions/tools/annotation/notice
with:
message: "[Success] Built & Ran Tests for ${{ matrix.solution }}"
- name: Success - Skipped Tests for ${{ matrix.solution }}
if: success() && fromJSON(steps.getCanSkip.outputs.result)
uses: ./.github/actions/tools/annotation/notice
with:
message: "[Success] Skipped Tests for ${{ matrix.solution }}"