From 14a33c5f1d52900a3d9617e3fec0f18416ed0073 Mon Sep 17 00:00:00 2001 From: DHANYA KUMAR VG Date: Thu, 6 Feb 2025 21:08:01 +0530 Subject: [PATCH 1/6] Added proper test-summary --- .github/workflows/integration-tests.yml | 115 ++++++++++++------------ 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 4ee7c6efaf..a2460157f0 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -111,20 +111,28 @@ jobs: java-version: 17 distribution: temurin - - name: Integration tests - uses: burrunan/gradle-cache-action@v1 + - name: Run integration test for ${{ matrix.tests }} + run: | + # Run ONLY the test class for this matrix entry + ./gradlew -PintegrationTests integration-tests:test \ + --tests "com.atlan.java.sdk.${{ matrix.tests }}" \ + --rerun-tasks + env: - ATLAN_BASE_URL: "https://gcpotel.atlan.com/" - ATLAN_API_KEY: ${{ secrets.TENANT_API_KEY }} - with: - arguments: -PintegrationTests integration-tests:test --tests "com.atlan.java.sdk.${{ matrix.tests }}" --rerun-tasks + ATLAN_BASE_URL: "https://gcpotel.atlan.com/" + ATLAN_API_KEY: ${{ secrets.TENANT_API_KEY }} + - name: Move JUnit XML results + # Move them into a test-specific folder so that multiple matrix jobs don't overwrite each other's results. + run: | + mkdir -p integration-tests/build/test-results/${{ matrix.tests }} + mv integration-tests/build/test-results/test/* integration-tests/build/test-results/${{ matrix.tests }} || true - - if: success() || failure() + - name: Upload JUnit test results uses: actions/upload-artifact@v4 with: - name: ${{ matrix.tests }} - path: integration-tests/${{ matrix.tests }}.log + name: ${{ matrix.tests }}-junit-results + path: integration-tests/build/test-results/${{ matrix.tests }} report-test-results: @@ -135,67 +143,58 @@ jobs: - name: Download Test Results uses: actions/download-artifact@v4 with: + # This will download all artifacts, including each test's folder path: test-results - - name: Collect Failed Tests - id: collect-failures + - name: Summarize JUnit XML + id: summary run: | - echo "### Integration Test Results" >> test-summary.md + echo "### Integration Test Results" > test-summary.md echo "" >> test-summary.md - - failed_tests="" - for dir in test-results/*; do - # Only proceed if this is a directory - if [ -d "$dir" ]; then - - # Find the first .log file within that directory - log_file=$(find "$dir" -maxdepth 1 -name "*.log" | head -n 1) - if [ -f "$log_file" ]; then - echo "--------------------------------------------------" - echo "Inspecting log for test: $(basename "$dir")" - echo "Log file path: $log_file" - echo "--------------------------------------------------" - - # Show some portion of the log (maybe first 40 lines) so you can debug - # You could do full `cat "$log_file"` if you want everything - head -n 40 "$log_file" - - echo "--------------------------------------------------" - echo "End of log snippet for $(basename "$dir")" - echo "--------------------------------------------------" - - # Count lines that contain 'FAILED' - # (Adjust pattern if your logs show "FAIL" or "BUILD FAILED" etc.) - failed_count=$(grep -c " FAILED" "$log_file") - - if (( failed_count > 0 )); then - echo "❌ Detected $failed_count failure(s) in $(basename "$dir")" - failed_tests+="$(basename "$dir")\n" - else - echo "✅ No failures detected in $(basename "$dir")" - fi - echo "" - else - echo "No .log file found in $dir" - fi + + all_passed=true + total_failures=0 + + # Each matrix test has its own subfolder named "...-junit-results", + # but the download-artifact step will default to putting each artifact in a directory. + # For example: test-results/PersonaTest-junit-results/ (with *.xml inside). + + # Find all JUnit XML files under test-results/ + while IFS= read -r -d '' xmlfile; do + # We'll parse "failures" and "tests" attributes from each in the XML. + # If you have multiple elements, we sum them up. + # This quick grep-based approach is enough, but for more robust parsing, consider using xmllint or a test-report action. + + # Extract numeric sums for failures in this file + file_failures=$(grep -Po 'failures="\K\d+' "$xmlfile" | paste -sd+ - | bc) + [[ -z "$file_failures" ]] && file_failures=0 + + # If any failures > 0, we note them + if [ "$file_failures" -gt 0 ]; then + echo "❌ Failures found in: $xmlfile ($file_failures failures)" >> test-summary.md + all_passed=false + total_failures=$((total_failures + file_failures)) + else + echo "✅ No failures in: $xmlfile" >> test-summary.md fi - done - - # Summarize: - if [[ -n "$failed_tests" ]]; then - echo "❌ **Some tests failed.** Please check these directories:" - echo -e "$failed_tests" - echo "ALL_TESTS_PASSED=false" >> "$GITHUB_ENV" + done < <(find test-results -name '*.xml' -print0) + + if [ "$all_passed" = true ]; then + echo "" >> test-summary.md + echo "✅ **All integration tests passed!** Ready to merge. 🚀" >> test-summary.md + echo "ALL_TESTS_PASSED=true" >> $GITHUB_ENV else - echo "✅ **All tests passed!**" - echo "ALL_TESTS_PASSED=true" >> "$GITHUB_ENV" + echo "" >> test-summary.md + echo "❌ **Some tests failed.** Total failures: $total_failures" >> test-summary.md + echo "ALL_TESTS_PASSED=false" >> $GITHUB_ENV fi + - name: Output Test Summary to Logs run: | echo "--------------------------------------------------" echo "✅ Printing the test summary before posting to PR" echo "--------------------------------------------------" - cat test-summary.md # This prints the content of test-summary.md into the GitHub Actions logs + cat test-summary.md - name: Post Comment on PR uses: mshick/add-pr-comment@v2 From 650a2015b8be21467cb23617dccf5154e0f88f32 Mon Sep 17 00:00:00 2001 From: DHANYA KUMAR VG Date: Thu, 6 Feb 2025 21:09:30 +0530 Subject: [PATCH 2/6] removed wait dependency --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index a2460157f0..8fab8b2774 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -87,7 +87,7 @@ jobs: echo "tests=$json_tests" >> $GITHUB_OUTPUT integration-test: needs: - - wait-for-deployment +# - wait-for-deployment - setup-java-sdk - list-integration-tests runs-on: ubuntu-latest From 9f0d10126ac11efff4acef838c8382ef431d6fbf Mon Sep 17 00:00:00 2001 From: DHANYA KUMAR VG Date: Fri, 7 Feb 2025 00:02:59 +0530 Subject: [PATCH 3/6] modified failures result --- .github/workflows/integration-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 8fab8b2774..722b6fa66d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -123,12 +123,13 @@ jobs: ATLAN_API_KEY: ${{ secrets.TENANT_API_KEY }} - name: Move JUnit XML results - # Move them into a test-specific folder so that multiple matrix jobs don't overwrite each other's results. + if: success() || failure() run: | mkdir -p integration-tests/build/test-results/${{ matrix.tests }} mv integration-tests/build/test-results/test/* integration-tests/build/test-results/${{ matrix.tests }} || true - name: Upload JUnit test results + if: success() || failure() uses: actions/upload-artifact@v4 with: name: ${{ matrix.tests }}-junit-results From f23908b7c481b82cf2b711b5ea05a066d94d9c76 Mon Sep 17 00:00:00 2001 From: dhanyavg-atlan Date: Fri, 7 Feb 2025 15:14:53 +0530 Subject: [PATCH 4/6] Update integration-tests.yml --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 722b6fa66d..56ae67c8e4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -10,7 +10,7 @@ on: - lineageondemand - makerlogic - mlh41-integration-tests - + jobs: wait-for-deployment: runs-on: ubuntu-latest From d64a9464bd7be64832b4f7aef67ae0027fdf87f2 Mon Sep 17 00:00:00 2001 From: DHANYA KUMAR VG Date: Fri, 7 Feb 2025 19:04:47 +0530 Subject: [PATCH 5/6] modified push to pull_request --- .github/workflows/maven.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 88dad2ef2d..45f10e0927 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ name: Java CI with Maven on: - push: + pull_request: branches: - alpha - beta @@ -28,7 +28,6 @@ on: - master - lineageondemand - makerlogic - - mlh41-integration-tests jobs: build: From ca001b95acba20c6deb75060067c8f5123d35683 Mon Sep 17 00:00:00 2001 From: DHANYA KUMAR VG Date: Sun, 9 Feb 2025 14:20:56 +0530 Subject: [PATCH 6/6] copied workflows from mlh41tests --- .github/workflows/integration-tests.yml | 23 +++++------------------ .github/workflows/maven.yml | 4 ++-- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 56ae67c8e4..a28abdd21d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,7 +1,7 @@ name: Integration Tests for Metastore on: - push: + pull_request: branches: - alpha - beta @@ -9,8 +9,7 @@ on: - master - lineageondemand - makerlogic - - mlh41-integration-tests - + - mlh41tests jobs: wait-for-deployment: runs-on: ubuntu-latest @@ -21,7 +20,7 @@ jobs: - name: Wait for Matching Revision run: | MAX_RETRIES=30 # Set maximum number of retries - SLEEP_TIME=30 # Time in seconds between retries + SLEEP_TIME=60 # Time in seconds between retries for i in $(seq 1 $MAX_RETRIES); do echo "Attempt $i: Checking API for matching commit ID..." @@ -35,19 +34,15 @@ jobs: echo "Fetched Revision: $REVISION" echo "Expected Commit ID: $COMMIT_ID" - if [[ "$REVISION" == "$COMMIT_ID" ]]; then echo "✅ Revision matches commit ID! Proceeding to the next step..." exit 0 fi - echo "🔄 No match yet. Retrying in $SLEEP_TIME seconds..." sleep $SLEEP_TIME done - echo "❌ ERROR: Max retries reached. Commit ID did not match the revision." exit 1 - setup-java-sdk: runs-on: ubuntu-latest steps: @@ -87,7 +82,7 @@ jobs: echo "tests=$json_tests" >> $GITHUB_OUTPUT integration-test: needs: -# - wait-for-deployment + - wait-for-deployment - setup-java-sdk - list-integration-tests runs-on: ubuntu-latest @@ -117,7 +112,6 @@ jobs: ./gradlew -PintegrationTests integration-tests:test \ --tests "com.atlan.java.sdk.${{ matrix.tests }}" \ --rerun-tasks - env: ATLAN_BASE_URL: "https://gcpotel.atlan.com/" ATLAN_API_KEY: ${{ secrets.TENANT_API_KEY }} @@ -127,7 +121,6 @@ jobs: run: | mkdir -p integration-tests/build/test-results/${{ matrix.tests }} mv integration-tests/build/test-results/test/* integration-tests/build/test-results/${{ matrix.tests }} || true - - name: Upload JUnit test results if: success() || failure() uses: actions/upload-artifact@v4 @@ -152,24 +145,19 @@ jobs: run: | echo "### Integration Test Results" > test-summary.md echo "" >> test-summary.md - all_passed=true total_failures=0 - # Each matrix test has its own subfolder named "...-junit-results", # but the download-artifact step will default to putting each artifact in a directory. # For example: test-results/PersonaTest-junit-results/ (with *.xml inside). - # Find all JUnit XML files under test-results/ while IFS= read -r -d '' xmlfile; do # We'll parse "failures" and "tests" attributes from each in the XML. # If you have multiple elements, we sum them up. # This quick grep-based approach is enough, but for more robust parsing, consider using xmllint or a test-report action. - # Extract numeric sums for failures in this file file_failures=$(grep -Po 'failures="\K\d+' "$xmlfile" | paste -sd+ - | bc) [[ -z "$file_failures" ]] && file_failures=0 - # If any failures > 0, we note them if [ "$file_failures" -gt 0 ]; then echo "❌ Failures found in: $xmlfile ($file_failures failures)" >> test-summary.md @@ -179,7 +167,6 @@ jobs: echo "✅ No failures in: $xmlfile" >> test-summary.md fi done < <(find test-results -name '*.xml' -print0) - if [ "$all_passed" = true ]; then echo "" >> test-summary.md echo "✅ **All integration tests passed!** Ready to merge. 🚀" >> test-summary.md @@ -202,4 +189,4 @@ jobs: if: github.event_name == 'pull_request' with: message-path: test-summary.md - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 45f10e0927..763af571d7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ on: - master - lineageondemand - makerlogic - + - mlh41tests jobs: build: @@ -126,4 +126,4 @@ jobs: - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@v2.1.33 with: - sarif_file: 'trivy-image-results.sarif' + sarif_file: 'trivy-image-results.sarif' \ No newline at end of file