forked from apache/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (191 loc) · 7.3 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Check and Test
# This workflow should only be called from ci.yml which is triggered on
# the "pull_request" event type. We should never dispatch this workflow from
# a "pull_request_target" event.
on:
workflow_call:
inputs:
gradle-cache-read-only:
description: "Should the Gradle cache be read-only?"
default: true
type: boolean
gradle-cache-write-only:
description: "Should the Gradle cache be write-only?"
default: false
type: boolean
is-public-fork:
description: "Is this CI run from a public fork?"
default: true
type: boolean
jobs:
validate:
runs-on: ubuntu-latest
name: Compile and Check Java
outputs:
is-draft: ${{ steps.check-draft-pr.outputs.is-draft }}
steps:
- name: Env
run: printenv
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Check for Draft PR
id: check-draft-pr
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.draft
run: echo "is-draft=true" >> "$GITHUB_OUTPUT"
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Gradle
uses: ./.github/actions/setup-gradle
with:
java-version: 21
gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }}
gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- name: Compile and validate
env:
SCAN_ARG: ${{ inputs.is-public-fork && '--no-scan' || '--scan' }}
# Gradle flags
# --build-cache: Let Gradle restore the build cache
# --info: For now, we'll generate lots of logs while setting up the GH Actions
# --scan: Publish the build scan. This will only work on PRs from apache/kafka and trunk
# --no-scan: For public fork PRs, we won't attempt to publish the scan
run: |
./gradlew --build-cache --info $SCAN_ARG check -x test
- name: Archive check reports
if: always()
uses: actions/upload-artifact@v4
with:
name: check-reports
path: |
**/build/**/*.html
compression-level: 9
if-no-files-found: ignore
- name: Annotate checkstyle errors
# Avoid duplicate annotations, only run on java 21
if: failure()
run: python .github/scripts/checkstyle.py
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
- name: Annotate Rat errors
# Avoid duplicate annotations, only run on java 21
if: failure()
run: python .github/scripts/rat.py
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
test:
needs: validate
if: ${{ ! needs.validate.outputs.is-draft }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 21, 11 ] # If we change these, make sure to adjust ci-complete.yml
name: JUnit tests Java ${{ matrix.java }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install -r .github/scripts/requirements.txt
- name: Setup Gradle
uses: ./.github/actions/setup-gradle
with:
java-version: ${{ matrix.java }}
gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }}
gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- name: Test
# Gradle flags
# --build-cache: Let Gradle restore the build cache
# --no-scan: Don't attempt to publish the scan yet. We want to archive it first.
# --continue: Keep running even if a test fails
# -PcommitId Prevent the Git SHA being written into the jar files (which breaks caching)
id: junit-test
env:
TIMEOUT_MINUTES: 180 # 3 hours
run: |
set +e
./.github/scripts/thread-dump.sh &
timeout ${TIMEOUT_MINUTES}m ./gradlew --build-cache --continue --no-scan \
-PtestLoggingEvents=started,passed,skipped,failed \
-PmaxParallelForks=2 \
-PmaxTestRetries=1 -PmaxTestRetryFailures=3 \
-PmaxQuarantineTestRetries=3 -PmaxQuarantineTestRetryFailures=0 \
-PcommitId=xxxxxxxxxxxxxxxx \
quarantinedTest test
exitcode="$?"
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
- name: Archive JUnit HTML reports
uses: actions/upload-artifact@v4
id: junit-upload-artifact
with:
name: junit-reports-${{ matrix.java }}
path: |
**/build/reports/tests/*
compression-level: 9
if-no-files-found: ignore
- name: Archive JUnit XML
uses: actions/upload-artifact@v4
with:
name: junit-xml-${{ matrix.java }}
path: |
build/junit-xml/**/*.xml
compression-level: 9
if-no-files-found: ignore
- name: Archive Thread Dumps
id: thread-dump-upload-artifact
if: always() && steps.junit-test.outputs.exitcode == '124'
uses: actions/upload-artifact@v4
with:
name: junit-thread-dumps-${{ matrix.java }}
path: |
thread-dumps/*
compression-level: 9
if-no-files-found: ignore
- name: Parse JUnit tests
run: python .github/scripts/junit.py --export-test-catalog ./test-catalog >> $GITHUB_STEP_SUMMARY
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
JUNIT_REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
THREAD_DUMP_URL: ${{ steps.thread-dump-upload-artifact.outputs.artifact-url }}
GRADLE_EXIT_CODE: ${{ steps.junit-test.outputs.exitcode }}
- name: Archive Test Catalog
if: ${{ always() && matrix.java == '21' }}
uses: actions/upload-artifact@v4
with:
name: test-catalog
path: test-catalog
compression-level: 9
if-no-files-found: ignore
- name: Archive Build Scan
if: always()
uses: actions/upload-artifact@v4
with:
name: build-scan-test-${{ matrix.java }}
path: ~/.gradle/build-scan-data
compression-level: 9
if-no-files-found: ignore