Skip to content

Commit c275a3b

Browse files
committed
feat(.github/workflows): initialize container integration tests prototype
1 parent 6b188a4 commit c275a3b

1 file changed

Lines changed: 179 additions & 0 deletions

File tree

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Container Integration Tests Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths-ignore:
8+
- "doc/**"
9+
- "**/*.md"
10+
- "**/*.txt"
11+
- ".github/ISSUE_TEMPLATE/**"
12+
- ".github/*.md"
13+
pull_request:
14+
branches:
15+
- develop
16+
paths-ignore:
17+
- "doc/**"
18+
- "**/*.md"
19+
- "**/*.txt"
20+
- ".github/ISSUE_TEMPLATE/**"
21+
- ".github/*.md"
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
main-integration-tests-workflow:
29+
runs-on: ubuntu-latest
30+
if: vars.ENABLE_DOCKER_TESTS == 'true'
31+
timeout-minutes: 60
32+
33+
defaults:
34+
run:
35+
shell: bash
36+
37+
steps:
38+
# ---------------------------
39+
# CHECKOUT
40+
# ---------------------------
41+
- name: Checkout repository
42+
uses: actions/checkout@v6
43+
44+
# ---------------------------
45+
# VERIFY DOCKER
46+
# ---------------------------
47+
- name: Verify Docker
48+
run: |
49+
set -euo pipefail
50+
docker version
51+
52+
# ---------------------------
53+
# SETUP JAVA + MAVEN
54+
# ---------------------------
55+
- name: Setup Java
56+
uses: actions/setup-java@v5
57+
with:
58+
distribution: "temurin"
59+
java-version: "21"
60+
cache: "maven"
61+
62+
- name: Verify Maven
63+
run: |
64+
set -euo pipefail
65+
mvn -version
66+
67+
# ---------------------------
68+
# CLEAN PREVIOUS VOLUMES
69+
# ---------------------------
70+
- name: Clean docker-dev-volumes
71+
run: |
72+
set -euo pipefail
73+
rm -rf docker-dev-volumes || true
74+
75+
# ---------------------------
76+
# BUILD IMAGES (Dataverse-native)
77+
# ---------------------------
78+
- name: Build Dataverse containers via Maven
79+
run: |
80+
set -euo pipefail
81+
mvn -Pct clean package
82+
83+
# ---------------------------
84+
# START CONTAINERS (BACKGROUND)
85+
# ---------------------------
86+
- name: Start Dataverse stack
87+
run: |
88+
set -euo pipefail
89+
mvn -Pct docker:start
90+
91+
# ---------------------------
92+
# WAIT FOR API READINESS
93+
# ---------------------------
94+
- name: Wait for Dataverse API readiness
95+
run: |
96+
set -euo pipefail
97+
URL="http://localhost:8080/api/info/version"
98+
MAX_ATTEMPTS=10
99+
SLEEP_TIME=15
100+
echo "Waiting for Dataverse readiness..."
101+
for attempt in $(seq 1 $MAX_ATTEMPTS); do
102+
echo "Attempt $attempt..."
103+
RESPONSE=$(curl -s --max-time 15 "$URL" || true)
104+
STATUS=$(echo "$RESPONSE" | jq -r '.status' 2>/dev/null || echo "NOT_READY")
105+
if [ "$STATUS" = "OK" ]; then
106+
echo "Dataverse endpoint is READY."
107+
echo "Dataverse waiting for full readiness. Waiting 30 more seconds."
108+
sleep 30
109+
echo "Response: $RESPONSE"
110+
exit 0
111+
fi
112+
echo "Not ready. Sleeping ${SLEEP_TIME}s..."
113+
sleep $SLEEP_TIME
114+
if [ $SLEEP_TIME -lt 60 ]; then
115+
SLEEP_TIME=$((SLEEP_TIME * 2))
116+
if [ $SLEEP_TIME -gt 60 ]; then
117+
SLEEP_TIME=60
118+
fi
119+
fi
120+
done
121+
echo "Dataverse failed to become ready."
122+
docker ps
123+
CONTAINERS="$(docker ps -q)"
124+
if [ -n "$CONTAINERS" ]; then
125+
for cid in $CONTAINERS; do
126+
echo "===== Logs for container $cid ====="
127+
docker logs "$cid" || true
128+
done
129+
else
130+
echo "No running containers to show logs for."
131+
fi
132+
exit 1
133+
134+
# ---------------------------
135+
# MAP LOCALSTACK TO LOCALHOST
136+
# ---------------------------
137+
- name: Map localstack to localhost for Maven tests
138+
run: echo "127.0.0.1 localstack" | sudo tee -a /etc/hosts
139+
140+
# ---------------------------
141+
# RUN MAVEN TESTS
142+
# ---------------------------
143+
- name: Run Maven Integration Tests
144+
env:
145+
# Setting the three requested environment variables
146+
DVAPIKEY: "burrito"
147+
DV_APIKEY: "burrito"
148+
DV_API_KEY: "burrito"
149+
run: |
150+
set -euo pipefail
151+
# Read the file content into a variable
152+
TEST_SUITE=$(cat tests/integration-tests.txt)
153+
154+
echo "Running suite: $TEST_SUITE"
155+
156+
mvn test surefire-report:report jacoco:report \
157+
-Dtest="$TEST_SUITE" \
158+
-Ddataverse.test.baseurl=http://localhost:8080 \
159+
-Dmaven.test.failure.ignore=true
160+
161+
# ---------------------------
162+
# DUMP LOGS ON FAILURE
163+
# ---------------------------
164+
- name: Dump Dataverse Logs on Failure
165+
if: failure()
166+
run: docker logs dev_dataverse
167+
168+
# ---------------------------
169+
# SHUTDOWN STACK
170+
# ---------------------------
171+
- name: Stop Dataverse stack
172+
if: always()
173+
run: |
174+
set -euo pipefail
175+
mvn -Pct docker:stop || true
176+
- name: Final Docker cleanup
177+
if: always()
178+
run: |
179+
docker system prune -af || true

0 commit comments

Comments
 (0)