Skip to content

Switch Deployment to Use New Function #54

Switch Deployment to Use New Function

Switch Deployment to Use New Function #54

Workflow file for this run

name: Unit Test
on:
pull_request:
workflow_dispatch:
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Self Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup NodeJs20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Dependencies
run: npm ci
timeout-minutes: 5
- name: Run Unit Tests
run: |
$pattern = '(?<=\/[v][0-9]\/).*'
$changes = git diff --name-only origin/main... ./plugins
$pluginsToTest = $changes -replace $pattern | Sort-Object -Unique
if ( $null -eq $pluginsToTest ) {
Write-Output "Nothing to Test as no changes were found in plugins folder..."
exit 0
}
elseif ( $pluginsToTest.Count -eq 1 ) {
$pluginName = ($pluginsToTest.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
Write-Output "Only Testing $pluginsToTest"
npm test -- --ci --path="./$pluginsToTest" --pluginName="$pluginName"
Write-Output "Tested $pluginsToTest"
}
else {
Write-Output "Testing $($pluginsToTest.Count) Plugins..."
foreach ( $plugin in $pluginsToTest ) {
Write-Output "Testing $plugin"
$pluginName = ($plugin.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
npm test -- --ci --path="./$plugin" --pluginName="$pluginName"
Write-Output "Tested $plugin"
}
}
shell: pwsh
timeout-minutes: 10
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
pluginUnitTests/test_output/*.xml
pluginUnitTests/test_output/html/*.html