-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (130 loc) · 5.17 KB
/
TestExamples.yml
File metadata and controls
151 lines (130 loc) · 5.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: TestExamples
on:
push:
branches:
- main
- develop
workflow_dispatch:
env:
WORKING_DIR: ./examples
APP_PORT: 5005
APP_MODE: development
SSL_VERIFY: True
jobs:
TestExamples:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Start services
run: |
docker compose -f compose.dev.yml up -d --build
echo "Waiting for services to be ready..."
sleep 30
docker compose ps
- name: Check service health
run: |
echo "Checking if MapToMethod API is responding..."
curl -s http://localhost:${APP_PORT}/info | jq .
echo "✓ Service is healthy"
- name: Test entity queries
working-directory: ${{ env.WORKING_DIR }}
run: |
echo "================================================"
echo "Testing /api/entities endpoint"
echo "================================================"
# Query data entities (columns and annotations)
echo "→ Querying data entities from CSVW metadata..."
curl -s -X POST "http://localhost:${APP_PORT}/api/entities" \
-H "Content-Type: application/json" \
-d '{
"url": "https://raw.githubusercontent.com/Mat-O-Lab/CSVToCSVW/main/examples/example-metadata.json",
"entity_classes": [
"http://www.w3.org/ns/csvw#Column",
"http://www.w3.org/ns/oa#Annotation"
]
}' | jq . > bearingentities.json
if [ -s bearingentities.json ]; then
echo "✓ Generated bearingentities.json"
else
echo "✗ Failed to generate bearingentities.json"
fi
# Query method template entities
echo "→ Querying method template entities..."
curl -s -X POST "http://localhost:${APP_PORT}/api/entities" \
-H "Content-Type: application/json" \
-d '{
"url": "https://github.com/Mat-O-Lab/MSEO/raw/main/methods/DIN_EN_ISO_527-3.drawio.ttl",
"entity_classes": [
"https://spec.industrialontologies.org/ontology/core/Core/InformationContentEntity",
"http://purl.obolibrary.org/obo/BFO_0000008"
]
}' | jq . > contententities.json
if [ -s contententities.json ]; then
echo "✓ Generated contententities.json"
else
echo "✗ Failed to generate contententities.json"
fi
echo ""
- name: Test mapping generation with example request
working-directory: ${{ env.WORKING_DIR }}
run: |
echo "================================================"
echo "Testing /api/mapping endpoint with request.json"
echo "================================================"
if [ -f request.json ]; then
echo "→ Creating YARRRML mapping from request.json..."
# Make API call and capture both headers and body
RESPONSE=$(curl -s -X POST "http://localhost:${APP_PORT}/api/mapping" \
-H "Content-Type: application/json" \
-d @request.json \
-D - -o mapping-output.yaml)
# Extract filename from Content-Disposition if present
FILENAME=$(echo "$RESPONSE" | grep -i "Content-Disposition" | sed -n 's/.*filename=\(.*\)/\1/p' | tr -d '\r\n' || echo "example-map.yaml")
if [ -s mapping-output.yaml ]; then
mv mapping-output.yaml "$FILENAME"
echo "✓ Generated $FILENAME"
echo "Preview (first 20 lines):"
head -n 20 "$FILENAME"
else
echo "✗ Failed to generate mapping file"
cat mapping-output.yaml
fi
else
echo "⚠ request.json not found, skipping this test"
fi
echo ""
- name: Test all YAML mappings can be read
working-directory: ${{ env.WORKING_DIR }}
run: |
echo "================================================"
echo "Validating existing YAML mapping files"
echo "================================================"
for file in *.yaml
do
if [ -f "$file" ]; then
echo "→ Checking $file..."
# Basic YAML syntax validation
if python3 -c "import yaml; yaml.safe_load(open('$file'))" 2>/dev/null; then
echo " ✓ Valid YAML syntax"
else
echo " ✗ Invalid YAML syntax"
fi
fi
done
echo ""
- name: Print service logs
if: always()
run: docker compose logs
- name: Commit generated files
uses: EndBug/add-and-commit@v9
with:
message: updated example outputs
add: "*.json *.yaml --force"
cwd: ./examples/