feat: run services tests on package agebd change

This commit is contained in:
Benjamin Labrecque
2026-07-30 15:11:15 +02:00
parent fb28f15ad8
commit a45a7a5c39
+34 -19
View File
@@ -52,7 +52,7 @@ jobs:
- name: Install Python 3.10
run: uv python install 3.10
- name: Run tests
- name: Run core tests
run: |
UV_CACHE_DIR="/sls/bd/hla/.cache/uv"
uv run --directory cli pytest
@@ -87,25 +87,32 @@ jobs:
rsync -av --delete --exclude='.nfs*' ./qt/ "${DEST_DIR}/"
# -----------------------------------------------------------------
# Services Deployment
# Services Detection, Testing, and Deployment
# -----------------------------------------------------------------
- name: Detect Changed Services
if: steps.filter.outputs.services == 'true'
- name: Detect Services to Test
# Run tests for a service if the service changed OR if core package agebd changed
if: steps.filter.outputs.services == 'true' || steps.filter.outputs.agebd == 'true'
id: detect-services
run: |
BEFORE="${{ github.event.before }}"
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
BEFORE="HEAD~1"
# If agebd changed, test ALL services to prevent breaking downstream dependencies
if [ "${{ steps.filter.outputs.agebd }}" = "true" ]; then
echo ":packages/agebd changed. Triggering tests for ALL services."
SERVICES_TO_TEST=$(ls -d services/*/ | xargs -n1 basename | tr '\n' ' ')
else
BEFORE="${{ github.event.before }}"
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
BEFORE="HEAD~1"
fi
# Get space-separated list of modified service folder names
SERVICES_TO_TEST=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u | tr '\n' ' ')
fi
# Get space-separated list of changed service directory names
CHANGED_SERVICES=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u | tr '\n' ' ')
echo "services=$CHANGED_SERVICES" >> $GITHUB_OUTPUT
echo "Detected changed services: $CHANGED_SERVICES"
echo "services=$SERVICES_TO_TEST" >> $GITHUB_OUTPUT
echo "Services queued for testing: $SERVICES_TO_TEST"
- name: Test Changed Services
if: steps.filter.outputs.services == 'true' && steps.detect-services.outputs.services != ''
- name: Test Services
if: steps.detect-services.outputs.services != ''
run: |
SERVICES="${{ steps.detect-services.outputs.services }}"
@@ -116,18 +123,26 @@ jobs:
echo "Running tests for: $SERVICE"
echo "=========================================="
# Run pytest inside the service directory using uv
uv run --directory "$SERVICE_DIR" pytest
else
echo "No tests directory found for $SERVICE, skipping..."
echo "Skipping $SERVICE (no tests directory found)..."
fi
done
- name: Deploy Changed Services
if: steps.filter.outputs.services == 'true' && steps.detect-services.outputs.services != ''
# ONLY deploy services that explicitly had file changes (prevents redeploying all services if only agebd changed)
if: steps.filter.outputs.services == 'true'
run: |
SERVICES="${{ steps.detect-services.outputs.services }}"
BEFORE="${{ github.event.before }}"
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
BEFORE="HEAD~1"
fi
CHANGED_SERVICES=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u)
for SERVICE in $SERVICES; do
for SERVICE in $CHANGED_SERVICES; do
echo "=========================================="
echo "Deploying service: $SERVICE (${AGEBD_ENV})"
echo "=========================================="
./.gitea/scripts/deploy-and-restart-service.sh "${SERVICE}" "${AGEBD_ENV}"
done