Skip to content

Commit 951113f

Browse files
committed
ci: Add validation steps and configurable Newman collection path
- Add newman-collection-path input (default: tests/integration) - Add "Validate test infrastructure" step in PHPUnit job - Add "Validate Newman collections" step in Newman job - Run each Newman collection individually for better error isolation - Remove app-specific smoke test from Newman job
1 parent 4f39928 commit 951113f

1 file changed

Lines changed: 46 additions & 15 deletions

File tree

.github/workflows/quality.yml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ on:
5757
required: false
5858
type: boolean
5959
default: false
60+
newman-collection-path:
61+
description: "Path to Newman/Postman collection files (relative to app root)"
62+
required: false
63+
type: string
64+
default: "tests/integration"
6065
enable-coverage-guard:
6166
description: "Run coverage baseline guard and auto-update"
6267
required: false
@@ -346,6 +351,19 @@ jobs:
346351
cd server/apps/${{ inputs.app-name }}
347352
composer install --no-progress --prefer-dist --optimize-autoloader
348353
354+
- name: Validate test infrastructure
355+
run: |
356+
cd server/apps/${{ inputs.app-name }}
357+
if [ ! -f phpunit.xml ] && [ ! -f phpunit-unit.xml ]; then
358+
echo "::error::PHPUnit is enabled but no phpunit.xml or phpunit-unit.xml found. Add a PHPUnit config or disable enable-phpunit."
359+
exit 1
360+
fi
361+
if [ ! -d tests/Unit ] && [ ! -d tests/unit ] && [ ! -d tests/Service ] && [ ! -d tests/Integration ] && [ ! -d tests/integration ]; then
362+
echo "::error::PHPUnit is enabled but no test directories found (tests/Unit, tests/Service, tests/Integration). Add tests or disable enable-phpunit."
363+
exit 1
364+
fi
365+
echo "PHPUnit infrastructure validated."
366+
349367
- name: Run PHPUnit tests
350368
run: |
351369
cd server/apps/${{ inputs.app-name }}
@@ -450,25 +468,38 @@ jobs:
450468
- name: Install Newman
451469
run: npm install -g newman
452470

453-
- name: Smoke test API
471+
- name: Validate Newman collections
454472
run: |
455-
echo "=== Check app is enabled ==="
456-
cd server && php occ app:list --enabled | grep -i register || echo "App not listed"
457-
echo "=== Test register creation ==="
458-
curl -s -u admin:admin -X POST \
459-
-H "Content-Type: application/json" \
460-
-d '{"title":"smoke-test","description":"CI smoke test"}' \
461-
http://localhost:8080/index.php/apps/${{ inputs.app-name }}/api/registers | head -500
462-
echo ""
473+
cd server/apps/${{ inputs.app-name }}
474+
COLLECTION_PATH="${{ inputs.newman-collection-path }}"
475+
if [ ! -d "$COLLECTION_PATH" ]; then
476+
echo "::error::Newman is enabled but collection directory '$COLLECTION_PATH' does not exist. Add Postman collections or disable enable-newman."
477+
exit 1
478+
fi
479+
COLLECTIONS=$(find "$COLLECTION_PATH" -name "*.postman_collection.json" 2>/dev/null | wc -l)
480+
if [ "$COLLECTIONS" -eq 0 ]; then
481+
echo "::error::Newman is enabled but no .postman_collection.json files found in '$COLLECTION_PATH'. Add Postman collections or disable enable-newman."
482+
exit 1
483+
fi
484+
echo "Found $COLLECTIONS Postman collection(s) in $COLLECTION_PATH."
463485
464486
- name: Run Newman tests
465487
run: |
466-
cd server/apps/${{ inputs.app-name }}/tests/integration
467-
newman run *.postman_collection.json \
468-
--env-var "base_url=http://localhost:8080" \
469-
--env-var "admin_user=admin" \
470-
--env-var "admin_password=admin" \
471-
--reporters cli
488+
cd server/apps/${{ inputs.app-name }}/${{ inputs.newman-collection-path }}
489+
FAIL=0
490+
for collection in *.postman_collection.json; do
491+
echo ""
492+
echo "=== Running: $collection ==="
493+
newman run "$collection" \
494+
--env-var "base_url=http://localhost:8080" \
495+
--env-var "admin_user=admin" \
496+
--env-var "admin_password=admin" \
497+
--reporters cli || FAIL=1
498+
done
499+
if [ "$FAIL" -ne 0 ]; then
500+
echo "::error::One or more Newman collections failed."
501+
exit 1
502+
fi
472503
473504
- name: Show Nextcloud log on failure
474505
if: failure()

0 commit comments

Comments
 (0)