diff --git a/.github/workflows/test-stack-reusable-workflow.yml b/.github/workflows/test-stack-reusable-workflow.yml index c1f7b2c9e..3f71cdcd3 100644 --- a/.github/workflows/test-stack-reusable-workflow.yml +++ b/.github/workflows/test-stack-reusable-workflow.yml @@ -546,21 +546,78 @@ jobs: pip install 'pyOpenSSL>=23.2.0' echo "=== Running version 0.49.1 to create datastore ===" - TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD=1 python3 ./changedetection.py -C -d /tmp/data - echo "✓ Version 0.49.1 datastore created successfully" + python3 ./changedetection.py -C -d /tmp/data & + APP_PID=$! + + # Wait for app to be ready + echo "Waiting for 0.49.1 to be ready..." + sleep 6 + + # Extract API key from datastore (0.49.1 uses url-watches.json) + API_KEY=$(jq -r '.settings.application.api_access_token // empty' /tmp/data/url-watches.json) + echo "API Key: ${API_KEY:0:8}..." + + # Create a watch with tag "github-group-test" via API + echo "Creating test watch with tag via API..." + curl -X POST "http://127.0.0.1:5000/api/v1/watch" \ + -H "x-api-key: ${API_KEY}" \ + -H "Content-Type: application/json" \ + --show-error --fail \ + --retry 6 --retry-delay 1 --retry-connrefused \ + -d '{ + "url": "https://example.com/upgrade-test", + "tag": "github-group-test" + }' + + echo "✓ Created watch with tag 'github-group-test' in version 0.49.1" + + # Stop the old version gracefully + kill $APP_PID + wait $APP_PID || true + echo "✓ Version 0.49.1 stopped" # Upgrade to current version git checkout ${{ github.ref_name }} pip install -r requirements.txt - echo "=== Running current version ${{ github.ref_name }} with old datastore ===" + echo "=== Running current version ${{ github.ref_name }} with old datastore (testing mode) ===" TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD=1 python3 ./changedetection.py -d /tmp/data > /tmp/upgrade-test.log 2>&1 echo "=== Upgrade test output ===" cat /tmp/upgrade-test.log + echo "✓ Datastore upgraded successfully" + + # Now start the current version normally to verify the tag survived + echo "=== Starting current version to verify tag exists after upgrade ===" + timeout 20 python3 ./changedetection.py -d /tmp/data > /tmp/ui-test.log 2>&1 & + APP_PID=$! + + # Wait for app to be ready and fetch UI + echo "Waiting for current version to be ready..." + sleep 5 + curl --retry 6 --retry-delay 1 --retry-connrefused --silent http://127.0.0.1:5000 > /tmp/ui-output.html + + # Verify tag exists in UI + if grep -q "github-group-test" /tmp/ui-output.html; then + echo "✓ Tag 'github-group-test' found in UI after upgrade" + else + echo "ERROR: Tag 'github-group-test' not found in UI after upgrade" + echo "=== UI Output ===" + cat /tmp/ui-output.html + echo "=== App Log ===" + cat /tmp/ui-test.log + kill $APP_PID || true + exit 1 + fi + + # Cleanup + kill $APP_PID || true + wait $APP_PID || true echo "" - echo "✓ Upgrade test passed: 0.49.1 → ${{ github.ref_name }}" + echo "✓✓✓ Upgrade test passed: 0.49.1 → ${{ github.ref_name }} ✓✓✓" + echo " - Datastore migrated successfully" + echo " - Tag 'github-group-test' survived upgrade" echo "✓ Upgrade test passed: 0.49.1 → ${{ github.ref_name }}"