| name: Fineract E2E Tests |
| |
| on: |
| workflow_call: |
| |
| permissions: |
| contents: read |
| |
| jobs: |
| test: |
| name: E2E Tests (Shard ${{ matrix.shard_index }} of ${{ matrix.total_shards }}) |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 60 |
| |
| strategy: |
| fail-fast: false |
| matrix: |
| # Define the number of shards (1-based indexing) |
| shard_index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] |
| total_shards: [15] |
| |
| env: |
| DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} |
| IMAGE_NAME: fineract |
| BASE_URL: https://localhost:8443 |
| TEST_USERNAME: mifos |
| TEST_PASSWORD: password |
| TEST_STRONG_PASSWORD: A1b2c3d4e5f$ |
| TEST_TENANT_ID: default |
| INITIALIZATION_ENABLED: true |
| EVENT_VERIFICATION_ENABLED: true |
| ACTIVEMQ_BROKER_URL: tcp://localhost:61616 |
| ACTIVEMQ_TOPIC_NAME: events |
| |
| steps: |
| - name: Set up JDK 21 |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 |
| with: |
| java-version: '21' |
| distribution: 'zulu' |
| |
| - name: Download workspace |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 |
| with: |
| name: fineract-workspace-${{ github.run_id }} |
| path: . |
| |
| - name: Extract workspace |
| run: tar -xf fineract-workspace.tar |
| |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 |
| |
| - name: Make scripts executable |
| run: chmod +x scripts/split-features.sh |
| |
| - name: Split feature files into shards |
| id: split-features |
| run: | |
| ./scripts/split-features.sh ${{ matrix.total_shards }} ${{ matrix.shard_index }} |
| echo "Shard ${{ matrix.shard_index }} feature files:" |
| cat feature_shard_${{ matrix.shard_index }}.txt |
| |
| - name: Build the image |
| run: ./gradlew --no-daemon --console=plain :fineract-provider:jibDockerBuild -Djib.to.image=$IMAGE_NAME -x test -x cucumber -x buildJavaSdk |
| |
| - name: Start the Fineract stack |
| run: docker compose -f docker-compose-postgresql-test-activemq.yml up -d |
| |
| - name: Check the stack |
| run: docker ps |
| |
| - name: Wait for Manager to be ready |
| run: | |
| # Wait for the container to be running |
| echo "Waiting for Manager container to be ready..." |
| timeout 300 bash -c 'until docker ps --filter "health=healthy" --filter "name=fineract" --format "{{.Status}}" | grep -q "healthy"; do |
| if docker ps --filter "name=fineract" --format "{{.Status}}" | grep -q "unhealthy"; then |
| echo "Container is unhealthy. Stopping..." |
| docker ps -a |
| docker logs $(docker ps -q --filter name=fineract) || true |
| exit 1 |
| fi |
| echo "Waiting for Manager to be ready..." |
| sleep 5 |
| done' |
| |
| # Check the health endpoint |
| echo "Checking Manager health endpoint..." |
| curl -f -k --retry 30 --retry-all-errors --connect-timeout 10 --retry-delay 10 \ |
| https://localhost:8443/fineract-provider/actuator/health |
| |
| - name: Execute tests for shard ${{ matrix.shard_index }} |
| id: tests |
| run: | |
| # Initialize failure flag |
| FAILED=0 |
| |
| # Create necessary directories |
| mkdir -p "allure-results-shard-${{ matrix.shard_index }}" |
| mkdir -p "allure-results-merged" |
| |
| # Read feature files from the shard file |
| if [ ! -s "feature_shard_${{ matrix.shard_index }}.txt" ]; then |
| echo "No features to test in this shard. Skipping..." |
| exit 0 |
| fi |
| |
| # Read each feature file path and run tests one by one |
| while IFS= read -r feature_file || [ -n "$feature_file" ]; do |
| # Skip empty lines |
| [ -z "$feature_file" ] && continue |
| |
| # Create a safe filename for the results |
| safe_name=$(echo "$feature_file" | tr '/' '-' | tr ' ' '_') |
| |
| echo "::group::Testing feature: $feature_file" |
| |
| # Run tests with individual allure results directory |
| if ! ./gradlew --no-daemon --console=plain \ |
| :fineract-e2e-tests-runner:cucumber \ |
| -Pcucumber.features="$feature_file" \ |
| -Dallure.results.directory="allure-results-shard-${{ matrix.shard_index }}/$safe_name" \ |
| allureReport \ |
| -x buildJavaSdk \ |
| -x :fineract-client:buildJavaSdk \ |
| -x :fineract-client-feign:buildJavaSdk \ |
| -x :fineract-avro-schemas:buildJavaSdk; then |
| |
| echo "::error::Test failed for $feature_file" |
| FAILED=1 |
| fi |
| |
| echo "::endgroup::" |
| |
| # Copy the results to a merged directory |
| if [ -d "allure-results-shard-${{ matrix.shard_index }}/$safe_name" ]; then |
| cp -r "allure-results-shard-${{ matrix.shard_index }}/$safe_name/." "allure-results-merged/" || true |
| fi |
| done < "feature_shard_${{ matrix.shard_index }}.txt" |
| |
| # Generate individual report for this shard |
| if [ -d "allure-results-merged" ] && [ "$(ls -A allure-results-merged)" ]; then |
| echo "Generating Allure report..." |
| mkdir -p "allure-report-shard-${{ matrix.shard_index }}" |
| ./fineract-e2e-tests-runner/build/allure/commandline/bin/allure generate "allure-results-merged" --clean -o "allure-report-shard-${{ matrix.shard_index }}" || \ |
| echo "::warning::Failed to generate Allure report for shard ${{ matrix.shard_index }}" |
| fi |
| |
| # Exit with failure status if any test failed |
| if [ "$FAILED" -eq 1 ]; then |
| echo "::error::Some tests failed in this shard" |
| exit 1 |
| fi |
| |
| - name: Upload test results |
| if: always() |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| with: |
| name: allure-results-shard-${{ matrix.shard_index }} |
| path: | |
| allure-results-shard-${{ matrix.shard_index }} |
| allure-results-merged |
| **/build/allure-results |
| **/build/reports/tests/test |
| **/build/test-results/test |
| retention-days: 5 |
| |
| - name: Upload Allure Report |
| if: always() |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| with: |
| name: allure-report-shard-${{ matrix.shard_index }} |
| path: allure-report-shard-${{ matrix.shard_index }} |
| retention-days: 5 |
| |
| - name: Upload logs |
| if: always() |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| with: |
| name: logs-shard-${{ matrix.shard_index }} |
| path: | |
| **/build/reports/tests/ |
| **/logs/ |
| **/out/ |
| retention-days: 5 |
| |
| - name: Clean up |
| if: always() |
| run: | |
| docker compose -f docker-compose-postgresql-test-activemq.yml down -v |
| docker system prune -f |