Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Yaml Validator into the CI to validate Persistence Test cases #694

Merged
merged 31 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0dd2f74
add ci testing for yaml validation
abaskk-msft Jun 26, 2024
5cff03b
modifications to ci to run yaml validator on persistence tests. Also …
abaskk-msft Jun 27, 2024
b0be73b
test CI validator update
abaskk-msft Jun 27, 2024
df36869
add test runner, update CI filepaths
abaskk-msft Jun 28, 2024
d36b692
Merge branch 'master' into users/t-abaskar/yaml-validator-ci
abaskk-msft Jul 2, 2024
de22930
update ci script and add changes from master to test ci
abaskk-msft Jul 2, 2024
6591461
use absolute paths for ci script to work
abaskk-msft Jul 2, 2024
4b74b55
file unable to access give sudo perms
abaskk-msft Jul 2, 2024
ae653cb
debug output
abaskk-msft Jul 2, 2024
78a15ae
show all files in yamlValidator dir
abaskk-msft Jul 2, 2024
b48df29
add schema folder to ls echo. Comment out thins that consume CI minutes
abaskk-msft Jul 2, 2024
eeb40f3
cat file
abaskk-msft Jul 2, 2024
177c300
change file format
abaskk-msft Jul 2, 2024
2487b09
see if file inacessible due to permissions
abaskk-msft Jul 2, 2024
9bb1754
check if ci docker container doesn't have perms to access file
abaskk-msft Jul 3, 2024
b8e88cf
test ci with debug print statements
abaskk-msft Jul 3, 2024
669c4f0
=( ci file check again
abaskk-msft Jul 3, 2024
ad5c4cc
cd into running directory
abaskk-msft Jul 3, 2024
f069f29
cleaning out script
abaskk-msft Jul 3, 2024
7157971
add execute perms to shell script
abaskk-msft Jul 3, 2024
7e3ff87
relative filepath issue (maybe?)
abaskk-msft Jul 3, 2024
f3eeb11
more debugging
abaskk-msft Jul 3, 2024
34cac77
All paths from CI relative to root of repo
abaskk-msft Jul 3, 2024
1e5e4c8
run ci validation on windows
abaskk-msft Jul 3, 2024
0cfce9d
add powershell script for windows validation
abaskk-msft Jul 3, 2024
90666f8
run full updated CI workflow
abaskk-msft Jul 3, 2024
43f336c
remove unecessary validation
abaskk-msft Jul 3, 2024
381193b
small name change
abaskk-msft Jul 3, 2024
3818485
change CI test order
abaskk-msft Jul 3, 2024
d39f50c
run dll before yaml validation tests
abaskk-msft Jul 8, 2024
35b2ee9
Merge branch 'master' into users/t-abaskar/yaml-validator-ci
abaskk-msft Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
abaskk-msft marked this conversation as resolved.
Show resolved Hide resolved
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

Expand Down
23 changes: 23 additions & 0 deletions scripts/PersistenceValidate.ps1
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions scripts/PersistenceValidate.sh
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 4 additions & 2 deletions src/YamlValidator.Tests/YamlValidator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand All @@ -18,8 +20,8 @@
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestTestAdapterVersion)" />
<PackageReference Include="MSTest" Version="$(MSTest)" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions src/YamlValidator/InputProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading