|
57 | 57 | required: false |
58 | 58 | type: boolean |
59 | 59 | 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" |
60 | 65 | enable-coverage-guard: |
61 | 66 | description: "Run coverage baseline guard and auto-update" |
62 | 67 | required: false |
@@ -346,6 +351,19 @@ jobs: |
346 | 351 | cd server/apps/${{ inputs.app-name }} |
347 | 352 | composer install --no-progress --prefer-dist --optimize-autoloader |
348 | 353 |
|
| 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 | +
|
349 | 367 | - name: Run PHPUnit tests |
350 | 368 | run: | |
351 | 369 | cd server/apps/${{ inputs.app-name }} |
@@ -450,25 +468,38 @@ jobs: |
450 | 468 | - name: Install Newman |
451 | 469 | run: npm install -g newman |
452 | 470 |
|
453 | | - - name: Smoke test API |
| 471 | + - name: Validate Newman collections |
454 | 472 | 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." |
463 | 485 |
|
464 | 486 | - name: Run Newman tests |
465 | 487 | 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 |
472 | 503 |
|
473 | 504 | - name: Show Nextcloud log on failure |
474 | 505 | if: failure() |
|
0 commit comments