-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (53 loc) · 2.11 KB
/
instance_validator.yml
File metadata and controls
64 lines (53 loc) · 2.11 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
name: Instance Validator
on:
workflow_call:
jobs:
validate-instance:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to compare against the base branch
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Checkout openMINDS_actions repository
uses: actions/checkout@v3
with:
repository: openMetadataInitiative/openMINDS_actions
ref: main
path: openMINDS_actions # Checkout in a dedicated folder
- name: Validate instance
run: |
git checkout HEAD
git diff -M --name-only --diff-filter=AMR HEAD^ HEAD | grep '\.jsonld' > changed_files.txt || true
validation_failed=false
uv pip install --system -r openMINDS_actions/requirements.txt
if [ -s changed_files.txt ]; then
while IFS= read -r file; do
validation_output=$(python openMINDS_actions/validate_instance.py "$file" 2>&1 || true)
if echo "$validation_output" | grep -iE "SyntaxError|ValueError|Error|Invalid|JSONDecodeError" > /dev/null; then
echo "$validation_output"
echo "❌ Validation failed for $file"
validation_failed=true
elif echo "$validation_output" | grep -iE "WARNING" > /dev/null; then
echo "$validation_output"
echo "⚠️ Validation passed with warnings for $file"
fi
done < changed_files.txt
# If any validation failed, exit with a non-zero status
if [ "$validation_failed" = true ]; then
echo "❌ Some instances failed validation."
exit 1
else
echo "✅ All instances passed validation."
fi
else
echo "No instance to validate."
fi
shell: bash