MINOR Fix some test-catalog issues (#18272)

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
David Arthur 2024-12-20 08:42:57 -05:00 committed by GitHub
parent e8863c9ee2
commit af5d6c2578
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 20 deletions

View File

@ -402,10 +402,19 @@ if __name__ == "__main__":
print("<hr/>") print("<hr/>")
# Print special message if there was a timeout # Print special message if there was a timeout
exit_code = get_env("GRADLE_EXIT_CODE", int) test_exit_code = get_env("GRADLE_TEST_EXIT_CODE", int)
if exit_code == 124: quarantined_test_exit_code = get_env("GRADLE_QUARANTINED_TEST_EXIT_CODE", int)
if test_exit_code == 124 or quarantined_test_exit_code == 124:
# Special handling for timeouts. The exit code 124 is emitted by 'timeout' command used in build.yml.
# A watchdog script "thread-dump.sh" will use jstack to force a thread dump for any Gradle process
# still running after the timeout. We capture the exit codes of the two test tasks and pass them to
# this script. If either "test" or "quarantinedTest" fails due to timeout, we want to fail the overall build.
thread_dump_url = get_env("THREAD_DUMP_URL") thread_dump_url = get_env("THREAD_DUMP_URL")
logger.debug(f"Gradle command timed out. These are partial results!") if test_exit_code == 124:
logger.debug(f"Gradle task for 'test' timed out. These are partial results!")
else:
logger.debug(f"Gradle task for 'quarantinedTest' timed out. These are partial results!")
logger.debug(summary) logger.debug(summary)
if thread_dump_url: if thread_dump_url:
print(f"\nThe JUnit tests were cancelled due to a timeout. Thread dumps were generated before the job was cancelled. " print(f"\nThe JUnit tests were cancelled due to a timeout. Thread dumps were generated before the job was cancelled. "
@ -414,7 +423,7 @@ if __name__ == "__main__":
else: else:
logger.debug(f"Failing this step because the tests timed out. Thread dumps were not archived, check logs in JUnit step.") logger.debug(f"Failing this step because the tests timed out. Thread dumps were not archived, check logs in JUnit step.")
exit(1) exit(1)
elif exit_code in (0, 1): elif test_exit_code in (0, 1):
logger.debug(summary) logger.debug(summary)
if total_failures > 0: if total_failures > 0:
logger.debug(f"Failing this step due to {total_failures} test failures") logger.debug(f"Failing this step due to {total_failures} test failures")
@ -425,5 +434,5 @@ if __name__ == "__main__":
else: else:
exit(0) exit(0)
else: else:
logger.debug(f"Gradle had unexpected exit code {exit_code}. Failing this step") logger.debug(f"Gradle had unexpected exit code {test_exit_code}. Failing this step")
exit(1) exit(1)

View File

@ -21,14 +21,10 @@ name: Check and Test
on: on:
workflow_call: workflow_call:
inputs: inputs:
gradle-cache-read-only: is-trunk:
description: "Should the Gradle cache be read-only?" description: "Is this a trunk build?"
default: true default: true
type: boolean type: boolean
gradle-cache-write-only:
description: "Should the Gradle cache be write-only?"
default: false
type: boolean
is-public-fork: is-public-fork:
description: "Is this CI run from a public fork?" description: "Is this CI run from a public fork?"
default: true default: true
@ -105,8 +101,8 @@ jobs:
uses: ./.github/actions/setup-gradle uses: ./.github/actions/setup-gradle
with: with:
java-version: 23 java-version: 23
gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }} gradle-cache-read-only: ${{ !inputs.is-trunk }}
gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }} gradle-cache-write-only: ${{ inputs.is-trunk }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }} develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- name: Compile and validate - name: Compile and validate
env: env:
@ -156,6 +152,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
java: [ 23, 17 ] # If we change these, make sure to adjust ci-complete.yml java: [ 23, 17 ] # If we change these, make sure to adjust ci-complete.yml
outputs:
timed-out: ${{ (steps.junit-test.outputs.gradle-exitcode == '124' || steps.junit-quarantined-test.outputs.gradle-exitcode == '124') }}
name: JUnit tests Java ${{ matrix.java }} name: JUnit tests Java ${{ matrix.java }}
steps: steps:
- name: Checkout code - name: Checkout code
@ -168,8 +166,8 @@ jobs:
uses: ./.github/actions/setup-gradle uses: ./.github/actions/setup-gradle
with: with:
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }} gradle-cache-read-only: ${{ !inputs.is-trunk }}
gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }} gradle-cache-write-only: ${{ inputs.is-trunk }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }} develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
# If the load-catalog job failed, we won't be able to download the artifact. Since we don't want this to fail # If the load-catalog job failed, we won't be able to download the artifact. Since we don't want this to fail
@ -186,7 +184,7 @@ jobs:
uses: ./.github/actions/run-gradle uses: ./.github/actions/run-gradle
with: with:
test-task: quarantinedTest test-task: quarantinedTest
timeout-minutes: 30 timeout-minutes: 180
test-catalog-path: ${{ steps.load-test-catalog.outputs.download-path }}/combined-test-catalog.txt test-catalog-path: ${{ steps.load-test-catalog.outputs.download-path }}/combined-test-catalog.txt
build-scan-artifact-name: build-scan-quarantined-test-${{ matrix.java }} build-scan-artifact-name: build-scan-quarantined-test-${{ matrix.java }}
@ -235,7 +233,8 @@ jobs:
GITHUB_WORKSPACE: ${{ github.workspace }} GITHUB_WORKSPACE: ${{ github.workspace }}
JUNIT_REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }} JUNIT_REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
THREAD_DUMP_URL: ${{ steps.thread-dump-upload-artifact.outputs.artifact-url }} THREAD_DUMP_URL: ${{ steps.thread-dump-upload-artifact.outputs.artifact-url }}
GRADLE_EXIT_CODE: ${{ steps.junit-test.outputs.gradle-exitcode }} GRADLE_TEST_EXIT_CODE: ${{ steps.junit-test.outputs.gradle-exitcode }}
GRADLE_QUARANTINED_TEST_EXIT_CODE: ${{ steps.junit-quarantined-test.outputs.gradle-exitcode }}
- name: Archive Test Catalog - name: Archive Test Catalog
if: ${{ always() && matrix.java == '23' }} if: ${{ always() && matrix.java == '23' }}
@ -249,7 +248,7 @@ jobs:
update-test-catalog: update-test-catalog:
name: Update Test Catalog name: Update Test Catalog
needs: test needs: test
if: ${{ always() && !inputs.is-public-fork }} if: ${{ always() && inputs.is-trunk && !needs.test.outputs.timed-out }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write

View File

@ -38,8 +38,7 @@ jobs:
build: build:
uses: ./.github/workflows/build.yml uses: ./.github/workflows/build.yml
with: with:
gradle-cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} is-trunk: ${{ github.ref == 'refs/heads/trunk' }}
gradle-cache-write-only: ${{ github.ref == 'refs/heads/trunk' }}
is-public-fork: ${{ github.event.pull_request.head.repo.fork || false }} is-public-fork: ${{ github.event.pull_request.head.repo.fork || false }}
secrets: secrets:
inherit inherit