File tree Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,19 @@ name: CI Tests
2
2
3
3
on :
4
4
push :
5
- branches : [ main ]
5
+ branches : [main]
6
6
pull_request :
7
7
# The branches below must be a subset of the branches above
8
- branches : [ main ]
8
+ branches : [main]
9
9
merge_group :
10
- types : [ checks_requested ]
10
+ types : [checks_requested]
11
11
12
12
jobs :
13
13
ci :
14
14
name : node
15
15
strategy :
16
16
matrix :
17
- os : [ windows-latest, macos-latest, ubuntu-latest ]
17
+ os : [windows-latest, macos-latest, ubuntu-latest]
18
18
runs-on : ${{ matrix.os }}
19
19
env :
20
20
DOTNET_NOLOGO : true
33
33
with :
34
34
path : vscode-powershell
35
35
36
+ - name : Make sure JSON files are valid
37
+ shell : pwsh
38
+ run : ./vscode-powershell/tools/testValidJson.ps1
39
+
36
40
- name : Install dotnet
37
41
uses : actions/setup-dotnet@v4
38
42
with :
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+ <#
4
+ . SYNOPSIS
5
+ Get all JSON files recursively and test if they are valid by trying to import them.
6
+
7
+ . EXAMPLE
8
+ & $psEditor.GetEditorContext().CurrentFile.Path -WorkingDir '.\'
9
+ #>
10
+
11
+ # Input and expected output
12
+ [OutputType ([System.Void ])]
13
+ Param (
14
+ [Parameter ()]
15
+ [ValidateScript ({[System.IO.Directory ]::Exists($_ )})]
16
+ [string ] $WorkingDir = ' .\'
17
+ )
18
+
19
+ # PowerShell preferences
20
+ $ErrorActionPreference = ' Stop'
21
+
22
+ # Try to import all JSON files in the repo
23
+ $TestValidJson = [PSCustomObject []](
24
+ [System.IO.Directory ]::GetFiles($WorkingDir , ' *.json' , [System.IO.SearchOption ]::AllDirectories).ForEach {
25
+ [PSCustomObject ]@ {
26
+ ' Path' = [string ] $_
27
+ ' IsValidJson' = [bool ]$ (
28
+ Try {
29
+ $null = ConvertFrom-Json - InputObject (Get-Content - Raw - Path $_ ) - AsHashtable
30
+ $?
31
+ }
32
+ Catch {
33
+ $false
34
+ }
35
+ )
36
+ }
37
+ }
38
+ )
39
+
40
+ # Output results
41
+ $TestValidJson | Format-Table
42
+
43
+ # Throw if errors were found
44
+ if ($TestValidJson.Where {-not $_ .' IsValidJson' }.' Count' -gt 0 ) {
45
+ Throw (' Found {0} non-valid JSON file(s).' -f $TestValidJson.Where {-not $_ .' IsValidJson' }.' Count' )
46
+ }
You can’t perform that action at this time.
0 commit comments