diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 94d6b357..7f699ec4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -46,6 +46,17 @@ jobs: - name: Test - PAModel run: dotnet bin/Debug/PAModelTests/PAModelTests.dll + - name: Test - YamlValidator + run: dotnet bin/Debug/YamlValidator.Tests/YamlValidator.Tests.dll + + - name: Test - Persistence.Tests Yaml Files (ubuntu & macos) + run: ./scripts/PersistenceValidate.sh + if: ${{ runner.os != 'Windows' }} + + - name: Test - Persistence.Tests Yaml Files (windows) + run: ./scripts/PersistenceValidate.ps1 + if: ${{ runner.os == 'Windows' }} + - name: Restore workloads for samples run: dotnet workload restore samples/MauiMsApp/MauiMsApp.csproj diff --git a/scripts/PersistenceValidate.ps1 b/scripts/PersistenceValidate.ps1 new file mode 100644 index 00000000..2edf3ff8 --- /dev/null +++ b/scripts/PersistenceValidate.ps1 @@ -0,0 +1,23 @@ +<# + Validate's the Yaml Controls used by Persistence's Unit Tests + Uses the repository's root as entry point (similar to how containers on github actions would) +#> + +$AppTestDir = "..\Persistence.Tests\_TestData\AppsWithYaml" +$ControlTestDir = "..\Persistence.Tests\_TestData\ValidYaml-CI" + +# come back to same directory after validation +Push-Location + +Set-Location -Path "bin\Debug\YamlValidator" + +$AppTestResults = dotnet YamlValidator.dll validate --path $AppTestDir +Write-Output "Validating Directory $AppTestDir `n" +$AppTestResults + +$ControlTestResults = dotnet YamlValidator.dll validate --path $ControlTestDir +Write-Output "Validating Directory $ControlTestDir `n" +$ControlTestResults + +# restore location +Pop-Location diff --git a/scripts/PersistenceValidate.sh b/scripts/PersistenceValidate.sh new file mode 100755 index 00000000..8d8794e4 --- /dev/null +++ b/scripts/PersistenceValidate.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# This script is used to validate whether persistence has valid tests + +cd bin/Debug/YamlValidator + +APP_TEST_DIR="../Persistence.Tests/_TestData/AppsWithYaml" +CONTROL_TEST_DIR="../Persistence.Tests/_TestData/ValidYaml-CI" + +app_test_results=$(dotnet YamlValidator.dll validate --path $APP_TEST_DIR) +printf "Validating Directory $APP_TEST_DIR \n" +printf "$app_test_results" + +control_test_results=$(dotnet YamlValidator.dll validate --path $CONTROL_TEST_DIR) +printf "Validating Directory $CONTROL_TEST_DIR \n" +printf "$control_test_results" diff --git a/src/YamlValidator.Tests/YamlValidator.Tests.csproj b/src/YamlValidator.Tests/YamlValidator.Tests.csproj index d77e2bc4..e7f23ef3 100644 --- a/src/YamlValidator.Tests/YamlValidator.Tests.csproj +++ b/src/YamlValidator.Tests/YamlValidator.Tests.csproj @@ -4,6 +4,8 @@ net8.0 enable enable + true + Exe false true @@ -18,8 +20,8 @@ - - + + diff --git a/src/YamlValidator/InputProcessor.cs b/src/YamlValidator/InputProcessor.cs index a8b3fd7a..2045643f 100644 --- a/src/YamlValidator/InputProcessor.cs +++ b/src/YamlValidator/InputProcessor.cs @@ -43,13 +43,6 @@ public static RootCommand GetRootCommand() { result.ErrorMessage = $"The path '{inputFilePath}' does not exist"; } - else if (Directory.Exists(inputFilePath)) - { - if (Directory.GetFiles(inputFilePath, $"*{Constants.YamlFileExtension}").Length == 0) - { - result.ErrorMessage = $"The folder '{inputFilePath}' does not contain any yaml files"; - } - } else if (File.Exists(inputFilePath)) { if (!inputFilePath.EndsWith(Constants.YamlFileExtension, StringComparison.OrdinalIgnoreCase))