ci: dynamically discover and manage systemd services in workflow tests
Some checks are pending
API Endpoint Tests / test-api-endpoints (push) Successful in 46s
Integration Tests / test-service-integration (push) Has started running

This commit is contained in:
aitbc
2026-04-27 09:40:21 +02:00
parent 8926bb011e
commit aa395fbbf7
2 changed files with 62 additions and 21 deletions

View File

@@ -54,19 +54,26 @@ jobs:
- name: Start required services
run: |
cd /var/lib/aitbc-workspaces/api-tests/repo
echo "Starting AITBC services for endpoint testing..."
# Start coordinator-api
systemctl start aitbc-coordinator-api.service || echo "⚠️ coordinator-api already running or failed to start"
# Start exchange-api
systemctl start aitbc-exchange-api.service || echo "⚠️ exchange-api already running or failed to start"
# Start wallet daemon
systemctl start aitbc-wallet.service || echo "⚠️ wallet already running or failed to start"
# Start blockchain RPC
systemctl start aitbc-blockchain-rpc.service || echo "⚠️ blockchain-rpc already running or failed to start"
mapfile -t services < <(
find systemd -maxdepth 1 -type f -name "aitbc-*.service" -printf "%f\n" |
sed 's/\.service$//' |
sort
)
if [[ ${#services[@]} -eq 0 ]]; then
echo "⚠️ No aitbc service files found to start"
fi
for svc in "${services[@]}"; do
if systemctl list-unit-files | grep -q "^$svc.service"; then
systemctl start "$svc" 2>/dev/null && echo "✅ $svc started" || echo "⚠️ $svc already running or failed to start"
else
echo "⚠️ $svc service file not found"
fi
done
# Give services time to initialize
sleep 5
@@ -155,11 +162,17 @@ jobs:
- name: Cleanup
if: always()
run: |
cd /var/lib/aitbc-workspaces/api-tests/repo
# Stop the services we started
systemctl stop aitbc-coordinator-api.service || true
systemctl stop aitbc-exchange-api.service || true
systemctl stop aitbc-wallet.service || true
systemctl stop aitbc-blockchain-rpc.service || true
mapfile -t services < <(
find systemd -maxdepth 1 -type f -name "aitbc-*.service" -printf "%f\n" |
sed 's/\.service$//' |
sort
)
for svc in "${services[@]}"; do
systemctl stop "$svc" || true
done
# Clean up workspace
rm -rf /var/lib/aitbc-workspaces/api-tests

View File

@@ -56,12 +56,27 @@ jobs:
- name: Start services
if: github.event_name != 'pull_request'
run: |
cd /var/lib/aitbc-workspaces/integration-tests/repo
echo "Starting AITBC services..."
for svc in aitbc-coordinator-api aitbc-exchange-api aitbc-wallet aitbc-blockchain-rpc aitbc-blockchain-node aitbc-agent-coordinator; do
if systemctl is-active --quiet "$svc" 2>/dev/null; then
echo "✅ $svc already running"
mapfile -t services < <(
find systemd -maxdepth 1 -type f -name "aitbc-*.service" -printf "%f\n" |
sed 's/\.service$//' |
sort
)
if [[ ${#services[@]} -eq 0 ]]; then
echo "⚠️ No aitbc service files found to start"
fi
for svc in "${services[@]}"; do
if systemctl list-unit-files | grep -q "^$svc.service"; then
if systemctl is-active --quiet "$svc" 2>/dev/null; then
echo "✅ $svc already running"
else
systemctl start "$svc" 2>/dev/null && echo "✅ $svc started" || echo "⚠️ $svc failed to start"
fi
else
systemctl start "$svc" 2>/dev/null && echo " $svc started" || echo "⚠️ $svc not available"
echo "⚠️ $svc service file not found"
fi
sleep 1
done
@@ -147,8 +162,21 @@ jobs:
- name: Service status report
if: always()
run: |
cd /var/lib/aitbc-workspaces/integration-tests/repo
echo "=== Service Status ==="
for svc in aitbc-coordinator-api aitbc-exchange-api aitbc-wallet aitbc-blockchain-rpc aitbc-blockchain-node aitbc-agent-coordinator; do
mapfile -t services < <(
find systemd -maxdepth 1 -type f -name "aitbc-*.service" -printf "%f\n" |
sed 's/\.service$//' |
sort
)
if [[ ${#services[@]} -eq 0 ]]; then
echo "⚠️ No aitbc service files found"
exit 0
fi
for svc in "${services[@]}"; do
status=$(systemctl is-active "$svc" 2>/dev/null) || status="inactive"
echo " $svc: $status"
done