2323 branches :
2424 - master
2525 schedule :
26+ # scheduled job with JDK 17
2627 - cron : ' 0 12 * * *'
28+ # scheduled job with JDK 21
29+ # if cron expression is changed, make sure to update the expression in jdk_major_version step in preconditions job
30+ - cron : ' 0 6 * * *'
2731 workflow_dispatch :
2832 inputs :
2933 collect_coverage :
3034 description : ' Collect test coverage and upload to Codecov'
3135 required : true
32- default : ' true'
36+ type : boolean
37+ default : true
38+ jdk_major_version :
39+ description : ' JDK major version to use for the build'
40+ required : true
41+ type : choice
42+ options :
43+ - ' 17'
44+ - ' 21'
45+ default : ' 17'
46+ trace_test_resource_cleanup :
47+ description : ' Collect thread & heap information before exiting a test JVM. When set to "on", thread dump and heap histogram will be collected. When set to "full", a heap dump will also be collected.'
48+ required : true
49+ type : choice
50+ options :
51+ - ' off'
52+ - ' on'
53+ - ' full'
54+ default : ' off'
55+ thread_leak_detector_wait_millis :
56+ description : ' Duration in ms to wait for threads to exit in thread leak detection between test classes. It is necessary to wait for threads to complete before they are determined to be leaked threads.'
57+ required : true
58+ type : number
59+ default : 10000
3360
3461concurrency :
35- group : ${{ github.workflow }}-${{ github.ref }}
62+ group : ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}${{ github.event_name == 'workflow_dispatch' && github.event.inputs.jdk_major_version || '' }}
3663 cancel-in-progress : true
3764
3865env :
39- MAVEN_OPTS : -Xss1500k -Xmx1024m -Daether.connector.http.reuseConnections=false -Daether.connector.requestTimeout=60000 -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.serviceUnavailableRetryStrategy.class=standard -Dmaven.wagon.rto=60000
66+ MAVEN_OPTS : -Xss1500k -Xmx1500m -Daether.connector.http.reuseConnections=false -Daether.connector.requestTimeout=60000 -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.serviceUnavailableRetryStrategy.class=standard -Dmaven.wagon.rto=60000
4067 # defines the retention period for the intermediate build artifacts needed for rerunning a failed build job
4168 # it's possible to rerun individual failed jobs when the build artifacts are available
4269 # if the artifacts have already been expired, the complete workflow can be rerun by closing and reopening the PR or by rebasing the PR
@@ -46,23 +73,47 @@ jobs:
4673 preconditions :
4774 name : Preconditions
4875 runs-on : ubuntu-22.04
49- if : (github.event_name != 'schedule') || (github.repository == 'apache/pulsar')
5076 outputs :
5177 docs_only : ${{ steps.check_changes.outputs.docs_only }}
5278 changed_tests : ${{ steps.changes.outputs.tests_files }}
79+ need_owasp : ${{ steps.changes.outputs.need_owasp }}
5380 collect_coverage : ${{ steps.check_coverage.outputs.collect_coverage }}
81+ jdk_major_version : ${{ steps.jdk_major_version.outputs.jdk_major_version }}
82+
5483 steps :
84+ - name : Cancel scheduled jobs in forks by default
85+ if : ${{ github.repository != 'apache/pulsar' && github.event_name == 'schedule' }}
86+ uses : actions/github-script@v6
87+ with :
88+ script : |
89+ await github.rest.actions.cancelWorkflowRun({owner: context.repo.owner, repo: context.repo.repo, run_id: context.runId});
90+ process.exit(1);
91+
92+ - name : Select JDK major version
93+ id : jdk_major_version
94+ run : |
95+ # use JDK 21 for the scheduled build with cron expression '0 6 * * *'
96+ if [[ "${{ github.event_name == 'schedule' && github.event.schedule == '0 6 * * *' && 'true' || 'false' }}" == "true" ]]; then
97+ echo "jdk_major_version=21" >> $GITHUB_OUTPUT
98+ exit 0
99+ fi
100+ # use JDK 17 for build unless overridden with workflow_dispatch input
101+ echo "jdk_major_version=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.jdk_major_version || '17'}}" >> $GITHUB_OUTPUT
102+
55103 - name : checkout
104+ if : ${{ github.event_name == 'pull_request' }}
56105 uses : actions/checkout@v3
57106
58107 - name : Detect changed files
108+ if : ${{ github.event_name == 'pull_request' }}
59109 id : changes
60110 uses : apache/pulsar-test-infra/paths-filter@master
61111 with :
62112 filters : .github/changes-filter.yaml
63113 list-files : csv
64114
65115 - name : Check changed files
116+ if : ${{ github.event_name == 'pull_request' }}
66117 id : check_changes
67118 run : |
68119 if [[ "${GITHUB_EVENT_NAME}" != "schedule" && "${GITHUB_EVENT_NAME}" != "workflow_dispatch" ]]; then
@@ -95,6 +146,11 @@ jobs:
95146 JOB_NAME : Flaky tests suite
96147 COLLECT_COVERAGE : " ${{ needs.preconditions.outputs.collect_coverage }}"
97148 GRADLE_ENTERPRISE_ACCESS_KEY : ${{ secrets.GE_ACCESS_TOKEN }}
149+ CI_JDK_MAJOR_VERSION : ${{ needs.preconditions.outputs.jdk_major_version }}
150+ TRACE_TEST_RESOURCE_CLEANUP : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.trace_test_resource_cleanup || 'off' }}
151+ TRACE_TEST_RESOURCE_CLEANUP_DIR : ${{ github.workspace }}/target/trace-test-resource-cleanup
152+ THREAD_LEAK_DETECTOR_WAIT_MILLIS : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.thread_leak_detector_wait_millis || 10000 }}
153+ THREAD_LEAK_DETECTOR_DIR : ${{ github.workspace }}/target/thread-leak-dumps
98154 runs-on : ubuntu-22.04
99155 timeout-minutes : 100
100156 if : ${{ needs.preconditions.outputs.docs_only != 'true' }}
@@ -105,6 +161,10 @@ jobs:
105161 - name : Tune Runner VM
106162 uses : ./.github/actions/tune-runner-vm
107163
164+ - name : Clean Disk when tracing test resource cleanup
165+ if : ${{ env.TRACE_TEST_RESOURCE_CLEANUP != 'off' }}
166+ uses : ./.github/actions/clean-disk
167+
108168 - name : Setup ssh access to build runner VM
109169 # ssh access is enabled for builds in own forks
110170 if : ${{ github.repository != 'apache/pulsar' && github.event_name == 'pull_request' }}
@@ -124,11 +184,11 @@ jobs:
124184 restore-keys : |
125185 ${{ runner.os }}-m2-dependencies-core-modules-
126186
127- - name : Set up JDK 17
187+ - name : Set up JDK ${{ env.CI_JDK_MAJOR_VERSION }}
128188 uses : actions/setup-java@v3
129189 with :
130190 distribution : ' temurin'
131- java-version : 17
191+ java-version : ${{ env.CI_JDK_MAJOR_VERSION }}
132192
133193 - name : Build core-modules
134194 run : |
@@ -146,8 +206,24 @@ jobs:
146206 if : ${{ always() }}
147207 uses : ./.github/actions/copy-test-reports
148208
209+ - name : Publish Test Report
210+ uses : apache/pulsar-test-infra/action-junit-report@master
211+ if : ${{ always() }}
212+ with :
213+ report_paths : ' test-reports/TEST-*.xml'
214+ annotate_only : ' true'
215+
216+ - name : Report detected thread leaks
217+ if : ${{ always() }}
218+ run : |
219+ if [ -d "$THREAD_LEAK_DETECTOR_DIR" ]; then
220+ cd "$THREAD_LEAK_DETECTOR_DIR"
221+ cat threadleak*.txt | awk '/^Summary:/ {print "::warning::" $0 "\n"; next} {print}'
222+ fi
223+
149224 - name : Create Jacoco reports
150225 if : ${{ needs.preconditions.outputs.collect_coverage == 'true' }}
226+ continue-on-error : true
151227 run : |
152228 $GITHUB_WORKSPACE/build/pulsar_ci_tool.sh create_test_coverage_report
153229 cd $GITHUB_WORKSPACE/target
@@ -160,33 +236,34 @@ jobs:
160236 name : Jacoco-coverage-report-flaky
161237 path : target/jacoco_test_coverage_report_flaky.zip
162238 retention-days : 3
239+ if-no-files-found : ignore
163240
164241 - name : Upload to Codecov
165242 if : ${{ needs.preconditions.outputs.collect_coverage == 'true' }}
166243 uses : ./.github/actions/upload-coverage
244+ continue-on-error : true
167245 with :
168246 flags : unittests
169247
170- - name : Publish Test Report
171- uses : apache/pulsar-test-infra/action-junit-report@master
172- if : ${{ always() }}
173- with :
174- report_paths : ' test-reports/TEST-*.xml'
175- annotate_only : ' true'
176-
177248 - name : Upload Surefire reports
178249 uses : actions/upload-artifact@v3
179- if : ${{ !success() }}
250+ if : ${{ !success() || env.TRACE_TEST_RESOURCE_CLEANUP != 'off' }}
180251 with :
181252 name : Unit-BROKER_FLAKY-surefire-reports
182253 path : surefire-reports
183254 retention-days : 7
255+ if-no-files-found : ignore
184256
185- - name : Upload possible heap dump
257+ - name : Upload possible heap dump, core dump or crash files
186258 uses : actions/upload-artifact@v3
187259 if : ${{ always() }}
188260 with :
189- name : Unit-BROKER_FLAKY-heapdump
190- path : /tmp/*.hprof
261+ name : Unit-BROKER_FLAKY-dumps
262+ path : |
263+ /tmp/*.hprof
264+ **/hs_err_*.log
265+ **/core.*
266+ ${{ env.TRACE_TEST_RESOURCE_CLEANUP_DIR }}/*
267+ ${{ env.THREAD_LEAK_DETECTOR_DIR }}/*
191268 retention-days : 7
192- if-no-files-found : ignore
269+ if-no-files-found : ignore
0 commit comments