Skip to content

Commit 052c181

Browse files
joewizclaude
andcommitted
[ci] Add GitHub Actions CI workflow with Docker smoke tests
Builds the XAR by extracting exist.uber.jar from the existdb/existdb Docker image, then deploys the XAR via autodeploy and runs smoke tests against a live eXist-db container. Tests verify module loading, method detection, parameter defaults, header access, attribute round-trips, and parameter-map type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9d083ab commit 052c181

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

.github/workflows/exist.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# This workflow builds a xar archive, deploys it into exist and runs a smoke test.
2+
3+
name: exist-db CI
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
exist-version: [latest]
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
# Build with Maven
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v5
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
cache: maven
25+
26+
# Extract exist-core JAR from Docker image for compilation,
27+
# since the published 7.0.0-SNAPSHOT in the Maven repo is stale.
28+
- name: Pull eXist-db image
29+
run: docker pull existdb/existdb:${{ matrix.exist-version }}
30+
31+
- name: Install exist-core from Docker image into local Maven repo
32+
run: |
33+
id=$(docker create existdb/existdb:${{ matrix.exist-version }})
34+
docker cp "$id:/exist/lib/exist.uber.jar" /tmp/exist.uber.jar
35+
docker rm "$id"
36+
mvn install:install-file -Dfile=/tmp/exist.uber.jar \
37+
-DgroupId=org.exist-db -DartifactId=exist-core \
38+
-Dversion=7.0.0-SNAPSHOT -Dpackaging=jar -q
39+
40+
- name: Build with Maven
41+
run: mvn clean package -DskipTests -q
42+
43+
# Deploy XAR in Container
44+
- name: Start eXist-db container
45+
run: |
46+
docker run -dit -p 8080:8080 \
47+
-v ${{ github.workspace }}/target:/exist/autodeploy \
48+
--name exist --rm --health-interval=1s --health-start-period=1s \
49+
existdb/existdb:${{ matrix.exist-version }}
50+
51+
- name: Wait for eXist-db to start and deploy packages
52+
timeout-minutes: 5
53+
run: |
54+
while ! docker logs exist 2>&1 | grep -q "Server has started"; \
55+
do sleep 6s; \
56+
done
57+
echo "Server started, waiting for autodeploy..."
58+
sleep 15
59+
echo "=== eXist-db logs (tail) ==="
60+
docker logs exist 2>&1 | tail -15
61+
62+
- name: Check XAR is installed
63+
run: |
64+
result=$(curl -s -u admin: -H "Content-Type: application/xml" --data '
65+
<query xmlns="http://exist.sourceforge.net/NS/exist">
66+
<text><![CDATA[
67+
import module namespace exrequest = "http://exquery.org/ns/request";
68+
"request module loaded"
69+
]]></text>
70+
</query>' "http://localhost:8080/exist/rest/db")
71+
echo "$result"
72+
echo "$result" | grep -q "request module loaded" || (echo "FAIL: request module not loaded" && exit 1)
73+
74+
# Smoke tests: verify functions work
75+
- name: Test exrequest:method returns GET
76+
run: |
77+
result=$(curl -sf -u admin: \
78+
'http://localhost:8080/exist/rest/db?_query=import%20module%20namespace%20exrequest%20%3D%20%22http%3A%2F%2Fexquery.org%2Fns%2Frequest%22%3B%20exrequest%3Amethod()&_wrap=no')
79+
echo "$result"
80+
echo "$result" | grep -q "GET" || (echo "FAIL: expected GET" && exit 1)
81+
82+
- name: Test exrequest:scheme returns http
83+
run: |
84+
result=$(curl -sf -u admin: \
85+
'http://localhost:8080/exist/rest/db?_query=import%20module%20namespace%20exrequest%20%3D%20%22http%3A%2F%2Fexquery.org%2Fns%2Frequest%22%3B%20exrequest%3Ascheme()&_wrap=no')
86+
echo "$result"
87+
echo "$result" | grep -q "http" || (echo "FAIL: expected http" && exit 1)
88+
89+
- name: Test exrequest:parameter with default value
90+
run: |
91+
result=$(curl -sf -u admin: \
92+
'http://localhost:8080/exist/rest/db?_query=import%20module%20namespace%20exrequest%20%3D%20%22http%3A%2F%2Fexquery.org%2Fns%2Frequest%22%3B%20exrequest%3Aparameter(%22missing%22%2C%20%22fallback%22)&_wrap=no')
93+
echo "$result"
94+
echo "$result" | grep -q "fallback" || (echo "FAIL: expected fallback" && exit 1)
95+
96+
- name: Test exrequest:header-names returns non-empty sequence
97+
run: |
98+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
99+
<query xmlns="http://exist.sourceforge.net/NS/exist">
100+
<text><![CDATA[
101+
import module namespace exrequest = "http://exquery.org/ns/request";
102+
count(exrequest:header-names()) > 0
103+
]]></text>
104+
</query>' "http://localhost:8080/exist/rest/db")
105+
echo "$result"
106+
echo "$result" | grep -q "true" || (echo "FAIL: expected non-empty header names" && exit 1)
107+
108+
- name: Test exrequest:set-attribute and exrequest:attribute round-trip
109+
run: |
110+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
111+
<query xmlns="http://exist.sourceforge.net/NS/exist">
112+
<text><![CDATA[
113+
import module namespace exrequest = "http://exquery.org/ns/request";
114+
let $_ := exrequest:set-attribute("test-key", "test-value")
115+
return exrequest:attribute("test-key")
116+
]]></text>
117+
</query>' "http://localhost:8080/exist/rest/db")
118+
echo "$result"
119+
echo "$result" | grep -q "test-value" || (echo "FAIL: expected test-value" && exit 1)
120+
121+
- name: Test exrequest:parameter-map returns a map
122+
run: |
123+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
124+
<query xmlns="http://exist.sourceforge.net/NS/exist">
125+
<text><![CDATA[
126+
import module namespace exrequest = "http://exquery.org/ns/request";
127+
exrequest:parameter-map() instance of map(*)
128+
]]></text>
129+
</query>' "http://localhost:8080/exist/rest/db")
130+
echo "$result"
131+
echo "$result" | grep -q "true" || (echo "FAIL: expected map instance" && exit 1)

0 commit comments

Comments
 (0)