Skip to content

PR#2 - Continuous Testing (Matrix) - (ReflectiveCreation-to-main) #3

PR#2 - Continuous Testing (Matrix) - (ReflectiveCreation-to-main)

PR#2 - Continuous Testing (Matrix) - (ReflectiveCreation-to-main) #3

Workflow file for this run

name: Testing Matrix
run-name: PR#${{ github.event.number }}${{ github.event.pull_request.draft && ' [DRAFT]' || '' }} - Continuous Testing (Matrix) - (${{ github.event.pull_request.head.ref }}-to-${{ github.event.pull_request.base.ref }})
on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
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:
buildAndRunTests:
name: Continuous Testing
permissions: write-all
runs-on: windows-2022
if: ${{ !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
solution: [ Testing.sln ]
steps:
- name: Checkout [${{ github.event.pull_request.head.ref }}]
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, LICENSE, .gitignore, GitHub Workflows & Actions, etc.
- name: Check for Changes to Determine if Tests can be Skipped
id: getChanges
uses: tj-actions/changed-files@v44.5.2
with:
files_ignore: |
README.md
LICENSE
.github/**
.gitignore
- name: Check if Tests can be Skipped
id: getCanSkip
uses: actions/github-script@v7.0.1
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 MS-Build
uses: microsoft/setup-msbuild@v2
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.0
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
- name: Restore Packages for ${{ matrix.solution }}
shell: cmd
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
run: nuget restore "${{ matrix.solution }}"
####################################################################################################
### Run Tests ###
####################################################################################################
# Test 1 - Build Project
- name: Build ${{ matrix.solution }}
shell: cmd
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
run: msbuild "${{ matrix.solution }}" -t:rebuild -property:Configuration=Release -p:OutputPath=${{ env.build_directory }}
- 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
# Note: This Action Requires Windows
- name: Run Tests for ${{ matrix.solution }}
if: ${{ !fromJSON(steps.getCanSkip.outputs.result) }}
uses: microsoft/vstest-action@v1.0.0
with:
testAssembly: \*${{ env.test_project_suffix }}.dll
searchFolder: .\*\${{ env.build_directory }}\
runInParallel: true
ifNoFilesFound: ignore
- name: Error - Tests Failed for ${{ matrix.solution }}
if: failure()
uses: ./.github/actions/tools/annotation/error
with:
message: '[Error] Tests Failed for ${{ matrix.solution }}'
####################################################################################################
### 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 }}'