forked from FHIR/ig-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
104 lines (88 loc) · 3.17 KB
/
Copy pathazure-pipelines.yml
File metadata and controls
104 lines (88 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
trigger:
- master
pr:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
addToPath: true
architecture: 'x64'
- task: UseNode@1
inputs:
version: '18.x'
displayName: 'Install Node.js'
# Legacy Python validation - keeping for backward compatibility
- task: PythonScript@0
displayName: 'Test fhir-ig-list.json is valid JSON'
inputs:
scriptSource: 'inline'
script: |
import json
f = open("fhir-ig-list.json","r")
file_contents = f.read()
print("File contents preview:")
print(file_contents[:500] + "..." if len(file_contents) > 500 else file_contents)
json_object = json.loads(file_contents)
print("✅ fhir-ig-list.json is valid JSON")
- task: PythonScript@0
displayName: 'Test all fhir-version fields are lists'
inputs:
scriptSource: 'inline'
script: |
import json
def item_generator(json_input, lookup_key):
if isinstance(json_input, dict):
for k, v in json_input.items():
if k == lookup_key:
yield v
else:
yield from item_generator(v, lookup_key)
elif isinstance(json_input, list):
for item in json_input:
yield from item_generator(item, lookup_key)
json_file = open("fhir-ig-list.json", "r")
file_contents = json_file.read()
jdata = json.loads(file_contents)
fhir_version_count = 0
for fhir_version in item_generator(jdata, "fhir-version"):
fhir_version_count += 1
if type(fhir_version) != list:
raise Exception(f"fhir-version field has a non-list value: {fhir_version} (type: {type(fhir_version).__name__})")
print(f"✅ All {fhir_version_count} fhir-version fields are lists")
# New comprehensive validation
- script: |
echo "Getting changed files..."
if [ "$(Build.Reason)" == "PullRequest" ]; then
echo "Pull Request detected - comparing with target branch"
git fetch origin $(System.PullRequest.TargetBranch)
git diff --name-only HEAD origin/$(System.PullRequest.TargetBranch) | grep '\.json$' || echo "No JSON files changed"
else
echo "Push detected - comparing with previous commit"
git diff --name-only HEAD~1 HEAD | grep '\.json$' || echo "No JSON files changed"
fi > changed_files.txt
echo "Changed JSON files:"
cat changed_files.txt
export CHANGED_FILES=$(cat changed_files.txt | tr '\n' ' ')
echo "##vso[task.setvariable variable=changedFiles]$CHANGED_FILES"
displayName: 'Get changed files'
- script: |
if grep -q '\\u' *.json 2>/dev/null; then
echo "❌ Error: Escaped Unicode characters found in JSON files"
echo "Failing lines:"
grep -n '\\u' *.json
exit 1
else
echo "✅ No escaped Unicode characters found."
fi
displayName: 'Check for escaped Unicode characters'
- script: |
echo "Running comprehensive validation..."
echo "Changed files: $(changedFiles)"
export CHANGED_FILES="$(changedFiles)"
node validation.js
displayName: 'Run comprehensive validation'
env:
CHANGED_FILES: $(changedFiles)