Skip to content

Commit 88fdc40

Browse files
joewizclaude
andcommitted
[ci] Add GitHub Actions CI with Docker-based eXist-db smoke tests
Modeled on joewiz/exist-lsp CI workflow. Extracts exist.uber.jar from Docker image for compilation (published 7.0.0-SNAPSHOT is stale). Deploys XAR to container and runs smoke tests via REST API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4892beb commit 88fdc40

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

.github/workflows/exist.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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 | grep -q "Server has started"; \
55+
do sleep 6s; \
56+
done
57+
sleep 5
58+
59+
# Smoke tests: verify module loads and key functionality works
60+
# Note: The XAR module cannot override the built-in http-client in
61+
# the Docker image, so these tests verify the built-in module works.
62+
# The key JSON-as-string fix is validated by the Maven integration tests.
63+
- name: Test http:send-request basic GET
64+
run: |
65+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
66+
<query xmlns="http://exist.sourceforge.net/NS/exist">
67+
<text><![CDATA[
68+
import module namespace http = "http://expath.org/ns/http-client";
69+
let $r := http:send-request(
70+
<http:request method="GET" href="https://httpbin.org/get"/>
71+
)
72+
return string($r[1]/@status)
73+
]]></text>
74+
</query>' "http://localhost:8080/exist/rest/db")
75+
echo "$result"
76+
echo "$result" | grep -q "200" || (echo "FAIL: expected status 200" && exit 1)
77+
78+
- name: Test http:send-request POST with body
79+
run: |
80+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
81+
<query xmlns="http://exist.sourceforge.net/NS/exist">
82+
<text><![CDATA[
83+
import module namespace http = "http://expath.org/ns/http-client";
84+
let $r := http:send-request(
85+
<http:request method="POST" href="https://httpbin.org/post">
86+
<http:body media-type="text/plain">hello</http:body>
87+
</http:request>
88+
)
89+
return string($r[1]/@status)
90+
]]></text>
91+
</query>' "http://localhost:8080/exist/rest/db")
92+
echo "$result"
93+
echo "$result" | grep -q "200" || (echo "FAIL: expected status 200" && exit 1)
94+
95+
- name: Test http:send-request returns response headers
96+
run: |
97+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
98+
<query xmlns="http://exist.sourceforge.net/NS/exist">
99+
<text><![CDATA[
100+
import module namespace http = "http://expath.org/ns/http-client";
101+
let $r := http:send-request(
102+
<http:request method="GET" href="https://httpbin.org/get"/>
103+
)
104+
return count($r[1]/http:header) > 0
105+
]]></text>
106+
</query>' "http://localhost:8080/exist/rest/db")
107+
echo "$result"
108+
echo "$result" | grep -q "true" || (echo "FAIL: expected headers" && exit 1)
109+
110+
- name: Test http:send-request XML response is parsed
111+
run: |
112+
result=$(curl -sf -u admin: -H "Content-Type: application/xml" --data '
113+
<query xmlns="http://exist.sourceforge.net/NS/exist">
114+
<text><![CDATA[
115+
import module namespace http = "http://expath.org/ns/http-client";
116+
let $r := http:send-request(
117+
<http:request method="GET" href="https://httpbin.org/xml"/>
118+
)
119+
return count($r[2]//slide) > 0
120+
]]></text>
121+
</query>' "http://localhost:8080/exist/rest/db")
122+
echo "$result"
123+
echo "$result" | grep -q "true" || (echo "FAIL: expected parsed XML" && exit 1)
124+
125+
- name: Upload XAR artifact
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: exist-http-client-xar
129+
path: target/exist-http-client-*.xar

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.env
2+
.mvn/
23
target/
34
*.class
45
*.jar

0 commit comments

Comments
 (0)