forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 7
260 lines (235 loc) · 10.1 KB
/
precommit.yml
File metadata and controls
260 lines (235 loc) · 10.1 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# 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: PR Precommit Checks
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SRC_REL: src
PATCH_REL: output
YETUS_REL: yetus
YETUS_VERSION: '0.15.0'
GENERAL_CHECK_PLUGINS: 'all,-javadoc,-jira,-shadedjars,-unit'
JDK_SPECIFIC_PLUGINS: 'compile,github,htmlout,javac,javadoc,maven,mvninstall,shadedjars,unit'
AUTHOR_IGNORE_LIST: 'src/main/asciidoc/_chapters/developer.adoc'
BLANKS_EOL_IGNORE_FILE: 'dev-support/blanks-eol-ignore.txt'
BLANKS_TABS_IGNORE_FILE: 'dev-support/blanks-tabs-ignore.txt'
ARCHIVE_PATTERN_LIST: 'TEST-*.xml,org.apache.h*.txt,*.dumpstream,*.dump'
TESTS_FILTER: 'checkstyle,javac,javadoc,pylint,shellcheck,shelldocs,blanks,perlcritic,ruby-lint,rubocop'
BUILD_THREAD: 4
SUREFIRE_FIRST_PART_FORK_COUNT: '0.5C'
SUREFIRE_SECOND_PART_FORK_COUNT: '0.5C'
ASF_NIGHTLIES: 'https://nightlies.apache.org'
jobs:
precommit-checks:
runs-on: ubuntu-latest
timeout-minutes: 600
strategy:
fail-fast: false
matrix:
include:
- name: 'general-check'
plugins: 'all,-javadoc,-jira,-shadedjars,-unit'
java-version: '17'
hadoop-profile: '3.0'
workdir: 'yetus-general-check'
skip-errorprone: false
report-name: 'PR General Check Report'
- name: 'jdk17-hadoop3-check'
plugins: 'compile,github,htmlout,javac,javadoc,maven,mvninstall,shadedjars,unit'
java-version: '17'
hadoop-profile: '3.0'
workdir: 'yetus-jdk17-hadoop3-check'
skip-errorprone: true
report-name: 'PR JDK17 Hadoop3 Check Report'
steps:
- name: Setup environment paths
id: setup-env
run: |
WORKDIR="${GITHUB_WORKSPACE}/${{ matrix.workdir }}"
echo "WORKDIR=${WORKDIR}" >> $GITHUB_ENV
echo "YETUSDIR=${WORKDIR}/${YETUS_REL}" >> $GITHUB_ENV
echo "SOURCEDIR=${WORKDIR}/${SRC_REL}" >> $GITHUB_ENV
echo "PATCHDIR=${WORKDIR}/${PATCH_REL}" >> $GITHUB_ENV
echo "DOCKERFILE=${WORKDIR}/${SRC_REL}/dev-support/docker/Dockerfile" >> $GITHUB_ENV
echo "CACHE_APACHE_ARTIFACT=${WORKDIR}/${SRC_REL}/dev-support/jenkins-scripts/cache-apache-project-artifact.sh" >> $GITHUB_ENV
echo "YETUS_DRIVER=${WORKDIR}/${SRC_REL}/dev-support/jenkins_precommit_github_yetus.sh" >> $GITHUB_ENV
echo "HIDE_OLD_COMMENTS=${WORKDIR}/${SRC_REL}/dev-support/gh_hide_old_comments.sh" >> $GITHUB_ENV
# Set matrix-specific environment variables
echo "PLUGINS=${{ matrix.plugins }}" >> $GITHUB_ENV
echo "SET_JAVA_HOME=/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/${{ matrix.java-version }}*/x64" >> $GITHUB_ENV
echo "HADOOP_PROFILE=${{ matrix.hadoop-profile }}" >> $GITHUB_ENV
echo "WORKDIR_REL=${{ matrix.workdir }}" >> $GITHUB_ENV
echo "SKIP_ERRORPRONE=${{ matrix.skip-errorprone }}" >> $GITHUB_ENV
# Create working directories
mkdir -p "${WORKDIR}"
mkdir -p "${WORKDIR}/${SRC_REL}"
mkdir -p "${WORKDIR}/${YETUS_REL}"
mkdir -p "${WORKDIR}/${PATCH_REL}"
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- name: Checkout source code
uses: actions/checkout@v4
with:
path: ${{ matrix.workdir }}/src
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip
pip3 install --upgrade pip
- name: Download and extract Apache Yetus
working-directory: ${{ env.YETUSDIR }}
run: |
"${CACHE_APACHE_ARTIFACT}" \
--keys 'https://downloads.apache.org/yetus/KEYS' \
--verify-tar-gz \
./apache-yetus-${YETUS_VERSION}-bin.tar.gz \
yetus/${YETUS_VERSION}/apache-yetus-${YETUS_VERSION}-bin.tar.gz
tar --strip-components=1 -xzf apache-yetus-${YETUS_VERSION}-bin.tar.gz
rm apache-yetus-${YETUS_VERSION}-bin.tar.gz
- name: Run Yetus test-patch
id: test-patch
continue-on-error: true
working-directory: ${{ env.WORKDIR }}
env:
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
BUILD_URL_ARTIFACTS: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EXCLUDE_TESTS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/workflows/find-flaky-tests.yml/runs/latest/artifacts
run: |
hostname -a
pwd
ls -la
printenv 2>&1 | sort
echo "[INFO] Launching Yetus via ${YETUS_DRIVER}"
set +e
"${YETUS_DRIVER}"
EXIT_CODE=$?
set -e
echo "exit_code=${EXIT_CODE}" >> $GITHUB_OUTPUT
if [ ${EXIT_CODE} -ne 0 ]; then
echo "Test-patch failed with exit code ${EXIT_CODE}"
fi
exit 0
- name: Process site artifacts (general check only)
if: matrix.name == 'general-check' && always()
working-directory: ${{ env.WORKDIR }}
run: |
if [ -d "${PATCHDIR}/branch-site" ]; then
echo "Remove ${PATCHDIR}/branch-site for saving space"
rm -rf "${PATCHDIR}/branch-site"
python3 ${SOURCEDIR}/dev-support/gen_redirect_html.py \
"${ASF_NIGHTLIES}/hbase/${{ github.repository }}/${{ github.run_id }}/${{ matrix.workdir }}/${PATCH_REL}/branch-site" \
> "${PATCHDIR}/branch-site.html"
else
echo "No branch-site, skipping"
fi
if [ -d "${PATCHDIR}/patch-site" ]; then
echo "Remove ${PATCHDIR}/patch-site for saving space"
rm -rf "${PATCHDIR}/patch-site"
python3 ${SOURCEDIR}/dev-support/gen_redirect_html.py \
"${ASF_NIGHTLIES}/hbase/${{ github.repository }}/${{ github.run_id }}/${{ matrix.workdir }}/${PATCH_REL}/patch-site" \
> "${PATCHDIR}/patch-site.html"
else
echo "No patch-site, skipping"
fi
- name: Process test logs (JDK check only)
if: matrix.name == 'jdk17-hadoop3-check' && always()
working-directory: ${{ env.WORKDIR }}
run: |
if [ -d "${PATCHDIR}/archiver" ]; then
count=$(find "${PATCHDIR}/archiver" -type f | wc -l)
if [[ 0 -ne ${count} ]]; then
echo "zipping ${count} archived files"
zip -q -m -r "${PATCHDIR}/test_logs.zip" "${PATCHDIR}/archiver"
else
echo "No archived files, skipping compressing."
fi
else
echo "No archiver directory, skipping compressing."
fi
if [ -f "${PATCHDIR}/test_logs.zip" ]; then
echo "Creating redirect for test_logs.zip"
python3 ${SOURCEDIR}/dev-support/gen_redirect_html.py \
"${ASF_NIGHTLIES}/hbase/${{ github.repository }}/${{ github.run_id }}/${{ matrix.workdir }}/${PATCH_REL}" \
> "${PATCHDIR}/test_logs.html"
else
echo "No test_logs.zip, skipping"
fi
- name: Publish test results
if: matrix.name == 'jdk17-hadoop3-check' && always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: JDK17 Hadoop3 Test Results
junit_files: ${{ matrix.workdir }}/src/**/target/**/TEST-*.xml
fail_on: nothing
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}-results
path: |
${{ matrix.workdir }}/output/*
${{ matrix.workdir }}/output/**/*
!${{ matrix.workdir }}/output/precommit
!${{ matrix.workdir }}/output/precommit/**/*
retention-days: 15
- name: Upload HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}-html-report
path: ${{ matrix.workdir }}/output/report.html
retention-days: 15
- name: Hide old PR comments (general check only)
if: matrix.name == 'general-check' && always()
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
"${HIDE_OLD_COMMENTS}" "${{ github.event.pull_request.number }}" || :
- name: Set job status
if: always()
run: |
if [ "${{ steps.test-patch.outputs.exit_code }}" != "0" ]; then
echo "Test-patch failed, marking job as failed"
exit 1
fi
- name: Cleanup
if: always()
run: |
# See YETUS-764
if [ -f "${PATCHDIR}/pidfile.txt" ]; then
echo "test-patch process appears to still be running: killing"
kill $(cat "${PATCHDIR}/pidfile.txt") || true
sleep 10
fi
if [ -f "${PATCHDIR}/cidfile.txt" ]; then
echo "test-patch container appears to still be running: killing"
docker kill $(cat "${PATCHDIR}/cidfile.txt") || true
fi
# See HADOOP-13951
if [ -d "${WORKDIR}" ]; then
chmod -R u+rxw "${WORKDIR}" || true
fi