From 8bb1e2a35691248da598c47a25e8fec8870fa710 Mon Sep 17 00:00:00 2001 From: Naren Soni Date: Wed, 2 Jan 2019 13:37:13 -0800 Subject: [PATCH] Adding json validation build (#51) --- appveyor.yml | 13 +++++++++++++ build.ps1 | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 appveyor.yml create mode 100644 build.ps1 diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..a1769ee5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,13 @@ +version: 1.0.3.{build} +pull_requests: + do_not_increment_build_number: true +branches: + only: + - dev + - master + - v2.x +max_jobs: 1 +image: Visual Studio 2017 +build_script: +- ps: >- + .\build.ps1 \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000..767f4b31 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,34 @@ +$ErrorActionPreference = "Stop" + +function LogOperationStart($message) { + Write-Host $message -NoNewline +} + +function LogSuccess() { + Write-Host -ForegroundColor Green "...Done" +} + +function LogErrorAndExit($errorMessage, $exception) { + Write-Host -ForegroundColor Red "...Failed" + Write-Host $errorMessage -ForegroundColor Red + if ($exception -ne $null) { + Write-Host $exception -ForegroundColor Red | format-list -force + } + Exit +} + +Function validateFeedJson() +{ + try { + $file = Get-Content ".\cli-feed-v3.json" -Raw + $jsonObj = ConvertFrom-Json $file + } catch { + LogErrorAndExit "The feed content is not valid JSON" $_.Exception + } +} + +# start tests + +LogOperationStart "Checking if the feed content is valid json" +validateFeedJson +LogSuccess \ No newline at end of file