Skip to content

Commit f4d22f1

Browse files
author
Thomas Hanke
committed
fixed test workflow
1 parent 8934811 commit f4d22f1

1 file changed

Lines changed: 131 additions & 42 deletions

File tree

.github/workflows/TestExamples.yml

Lines changed: 131 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,148 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
workflow_dispatch:
89

910
env:
10-
WORKING_DIR: ./examples/
11-
DATA_URL: 'https://raw.githubusercontent.com/Mat-O-Lab/CSVToCSVW/main/examples/example-metadata.json'
12-
METHOD_URL: 'https://raw.githubusercontent.com/Mat-O-Lab/MSEO/main/methods/DIN_EN_ISO_527-3.ttl'
11+
WORKING_DIR: ./examples
1312
APP_PORT: 5005
13+
APP_MODE: development
14+
SSL_VERIFY: True
15+
1416
jobs:
1517
TestExamples:
1618
runs-on: ubuntu-latest
1719
steps:
18-
- uses: actions/checkout@v2
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
1922
with:
20-
fetch-depth: 0
21-
- name: run app
23+
fetch-depth: 0
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y jq curl
29+
30+
- name: Start services
31+
run: |
32+
docker compose -f docker-compose.dev.yml up -d --build
33+
echo "Waiting for services to be ready..."
34+
sleep 30
35+
docker compose ps
36+
37+
- name: Check service health
2238
run: |
23-
docker-compose up -d
24-
sleep 10
25-
docker ps -a
26-
- name: list entities
27-
working-directory: ${{env.WORKING_DIR}}
39+
echo "Checking if MapToMethod API is responding..."
40+
curl -s http://localhost:${APP_PORT}/info | jq .
41+
echo "✓ Service is healthy"
42+
43+
- name: Test entity queries
44+
working-directory: ${{ env.WORKING_DIR }}
45+
run: |
46+
echo "================================================"
47+
echo "Testing /api/entities endpoint"
48+
echo "================================================"
49+
50+
# Query data entities (columns and annotations)
51+
echo "→ Querying data entities from CSVW metadata..."
52+
curl -s -X POST "http://localhost:${APP_PORT}/api/entities" \
53+
-H "Content-Type: application/json" \
54+
-d '{
55+
"url": "https://raw.githubusercontent.com/Mat-O-Lab/CSVToCSVW/main/examples/example-metadata.json",
56+
"entity_classes": [
57+
"http://www.w3.org/ns/csvw#Column",
58+
"http://www.w3.org/ns/oa#Annotation"
59+
]
60+
}' | jq . > bearingentities.json
61+
62+
if [ -s bearingentities.json ]; then
63+
echo "✓ Generated bearingentities.json"
64+
else
65+
echo "✗ Failed to generate bearingentities.json"
66+
fi
67+
68+
# Query method template entities
69+
echo "→ Querying method template entities..."
70+
curl -s -X POST "http://localhost:${APP_PORT}/api/entities" \
71+
-H "Content-Type: application/json" \
72+
-d '{
73+
"url": "https://github.com/Mat-O-Lab/MSEO/raw/main/methods/DIN_EN_ISO_527-3.drawio.ttl",
74+
"entity_classes": [
75+
"https://spec.industrialontologies.org/ontology/core/Core/InformationContentEntity",
76+
"http://purl.obolibrary.org/obo/BFO_0000008"
77+
]
78+
}' | jq . > contententities.json
79+
80+
if [ -s contententities.json ]; then
81+
echo "✓ Generated contententities.json"
82+
else
83+
echo "✗ Failed to generate contententities.json"
84+
fi
85+
echo ""
86+
87+
- name: Test mapping generation with example request
88+
working-directory: ${{ env.WORKING_DIR }}
2889
run: |
29-
curl -X 'POST' \
30-
'http://localhost:${{env.APP_PORT}}/api/entities' \
31-
-H 'accept: application/json' \
32-
-H 'Content-Type: application/json' \
33-
-d '{
34-
"url": "https://raw.githubusercontent.com/Mat-O-Lab/CSVToCSVW/main/examples/example-metadata.json",
35-
"entity_classes": [
36-
"http://www.w3.org/ns/csvw#Column",
37-
"http://www.w3.org/ns/oa#Annotation"
38-
]}' | jq . > bearingentities.json
39-
curl -X 'POST' \
40-
'http://localhost:${{env.APP_PORT}}/api/entities' \
41-
-H 'accept: application/json' \
42-
-H 'Content-Type: application/json' \
43-
-d '{
44-
"url": "https://github.com/Mat-O-Lab/MSEO/raw/main/methods/DIN_EN_ISO_527-3.drawio.ttl",
45-
"entity_classes": [
46-
"https://spec.industrialontologies.org/ontology/core/Core/InformationContentEntity",
47-
"http://purl.obolibrary.org/obo/BFO_0000008"
48-
]}'| jq . > contententities.json
49-
- name: delete yaml files
50-
working-directory: ${{env.WORKING_DIR}}
51-
run: rm *.yaml
52-
continue-on-error: true
53-
- name: create YARRRML mapping
54-
working-directory: ${{env.WORKING_DIR}}
90+
echo "================================================"
91+
echo "Testing /api/mapping endpoint with request.json"
92+
echo "================================================"
93+
94+
if [ -f request.json ]; then
95+
echo "→ Creating YARRRML mapping from request.json..."
96+
97+
# Make API call and capture both headers and body
98+
RESPONSE=$(curl -s -X POST "http://localhost:${APP_PORT}/api/mapping" \
99+
-H "Content-Type: application/json" \
100+
-d @request.json \
101+
-D - -o mapping-output.yaml)
102+
103+
# Extract filename from Content-Disposition if present
104+
FILENAME=$(echo "$RESPONSE" | grep -i "Content-Disposition" | sed -n 's/.*filename=\(.*\)/\1/p' | tr -d '\r\n' || echo "example-map.yaml")
105+
106+
if [ -s mapping-output.yaml ]; then
107+
mv mapping-output.yaml "$FILENAME"
108+
echo "✓ Generated $FILENAME"
109+
echo "Preview (first 20 lines):"
110+
head -n 20 "$FILENAME"
111+
else
112+
echo "✗ Failed to generate mapping file"
113+
cat mapping-output.yaml
114+
fi
115+
else
116+
echo "⚠ request.json not found, skipping this test"
117+
fi
118+
echo ""
119+
120+
- name: Test all YAML mappings can be read
121+
working-directory: ${{ env.WORKING_DIR }}
55122
run: |
56-
curl -X POST "http://localhost:${{env.APP_PORT}}/api/mapping" -H "accept: application/json" -H "accept: application/json" -H "Content-Type: application/json" -d @request.json -v --connect-timeout 5 -O -J
57-
- name: Commit files # commit the output folder
123+
echo "================================================"
124+
echo "Validating existing YAML mapping files"
125+
echo "================================================"
126+
127+
for file in *.yaml
128+
do
129+
if [ -f "$file" ]; then
130+
echo "→ Checking $file..."
131+
132+
# Basic YAML syntax validation
133+
if python3 -c "import yaml; yaml.safe_load(open('$file'))" 2>/dev/null; then
134+
echo " ✓ Valid YAML syntax"
135+
else
136+
echo " ✗ Invalid YAML syntax"
137+
fi
138+
fi
139+
done
140+
echo ""
141+
142+
- name: Print service logs
143+
if: always()
144+
run: docker compose logs
145+
146+
- name: Commit generated files
58147
uses: EndBug/add-and-commit@v9
59148
with:
60-
message: 'updated example output'
61-
add: '*.* --force'
62-
cwd: './examples/'
149+
message: updated example outputs
150+
add: "*.json *.yaml --force"
151+
cwd: ./examples/

0 commit comments

Comments
 (0)