-
Notifications
You must be signed in to change notification settings - Fork 39
264 lines (227 loc) · 9.48 KB
/
prCheck.yml
File metadata and controls
264 lines (227 loc) · 9.48 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
261
262
263
264
# This will run for all PRs
name: Build
on:
push:
branches: [ main ]
pull_request: # Unit tests can be run for all external PRs
types: [opened, synchronize, reopened]
branches: [ main ]
permissions:
id-token: write
contents: read
jobs:
formatting-check:
strategy:
fail-fast: false
matrix:
java-version: [21] # For formatting, we don't need to run across multiple versions. Only sanity testing is required here, rest is taken care in the build.
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Check if fork
id: fork-check
shell: bash
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
echo "This is a forked PR — will use cached dependencies"
else
echo "is_fork=false" >> $GITHUB_OUTPUT
echo "This is a same-repo PR or push — will use JFrog OIDC"
fi
- name: Setup Maven
uses: ./.github/actions/setup-maven
with:
is-fork: ${{ steps.fork-check.outputs.is_fork }}
- name: Check formatting
run: mvn --errors spotless:check
unit-tests:
strategy:
fail-fast: false
matrix:
java-version: [11, 17, 21] # Adding LTS versions here. 21 is the latest LTS
github-runner: [ linux-ubuntu-latest, windows-server-latest ]
runs-on:
group: databricks-protected-runner-group
labels: ${{ matrix.github-runner }}
steps:
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Enable long paths
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Check if fork
id: fork-check
shell: bash
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
echo "This is a forked PR — will use cached dependencies"
else
echo "is_fork=false" >> $GITHUB_OUTPUT
echo "This is a same-repo PR or push — will use JFrog OIDC"
fi
- name: Setup Maven
uses: ./.github/actions/setup-maven
with:
is-fork: ${{ steps.fork-check.outputs.is_fork }}
- name: Set up Maven Toolchains
shell: bash
run: |
mkdir -p ~/.m2
cat > ~/.m2/toolchains.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>${{ matrix.java-version }}</version>
</provides>
<configuration>
<jdkHome>$JAVA_HOME</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF
- name: Check Arrow Patch Tests
shell: bash
if: matrix.java-version >= 17
run: mvn -Pjdk${{ matrix.java-version }}-NioNotOpen -pl jdbc-core test -Dgroups='Jvm17PlusAndArrowToNioReflectionDisabled'
- name: Check Arrow Allocator Manager Tests
shell: bash
if: matrix.java-version >= 17
run: mvn -Pjdk${{ matrix.java-version }}-NioNotOpen -pl jdbc-core test -Dgroups='Jvm17PlusAndArrowToNioReflectionDisabled' -Dtest="ArrowBufferAllocatorNettyManagerTest,ArrowBufferAllocatorUnsafeManagerTest,ArrowBufferAllocatorUnknownManagerTest" -DforkCount=1 -DreuseForks=false
- name: Check Arrow Memory Tests
shell: bash
run: mvn -Plow-memory -pl jdbc-core test -Dtest='DatabricksArrowPatchMemoryUsageTest'
- name: Check Unit Tests
shell: bash
run: mvn -pl jdbc-core clean test -Dgroups='!Jvm17PlusAndArrowToNioReflectionDisabled' jacoco:report
- name: Install xmllint
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: Extract codeCov percentage
shell: bash
run: |
COVERAGE_FILE="jdbc-core/target/site/jacoco/jacoco.xml"
COVERED=$(xmllint --xpath "string(//report/counter[@type='INSTRUCTION']/@covered)" "$COVERAGE_FILE")
MISSED=$(xmllint --xpath "string(//report/counter[@type='INSTRUCTION']/@missed)" "$COVERAGE_FILE")
TOTAL=$((COVERED + MISSED))
# Use Python for floating-point math
PERCENTAGE=$(python -c "covered=${COVERED}; total=${TOTAL}; print(round((covered/total)*100, 2))")
echo "$PERCENTAGE" > coverage.txt
echo "::set-output name=coverage::$PERCENTAGE"
- name: Check coverage percentage
shell: bash
run: |
BRANCH_COVERAGE=$(cat coverage.txt)
echo "Branch Coverage: $BRANCH_COVERAGE%"
# Use Python to compare the coverage with 85
python -c "import sys; sys.exit(0 if float('$BRANCH_COVERAGE') >= 85 else 1)"
if [ $? -eq 1 ]; then
echo "Coverage is less than 85%"
exit 1
else
echo "Coverage is equal to or greater than 85%"
fi
packaging-tests:
strategy:
fail-fast: false
matrix:
java-version: [ 17 ]
github-runner: [ linux-ubuntu-latest, windows-server-latest ]
runs-on:
group: databricks-protected-runner-group
labels: ${{ matrix.github-runner }}
steps:
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Enable long paths
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Check if fork
id: fork-check
shell: bash
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
echo "This is a forked PR — will use cached dependencies"
else
echo "is_fork=false" >> $GITHUB_OUTPUT
echo "This is a same-repo PR or push — will use JFrog OIDC"
fi
- name: Setup Maven
uses: ./.github/actions/setup-maven
with:
is-fork: ${{ steps.fork-check.outputs.is_fork }}
- name: Set up Maven Toolchains
shell: bash
run: |
mkdir -p ~/.m2
cat > ~/.m2/toolchains.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>${{ matrix.java-version }}</version>
</provides>
<configuration>
<jdkHome>$JAVA_HOME</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF
- name: Install JDBC artifacts into maven local
shell: bash
run: mvn -B -pl jdbc-core,assembly-uber,assembly-thin install -DskipTests -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Ddependency-check.skip=true
# Only run on push to main; secrets are not available for fork PRs
- name: Check Uber Jar Packaging
if: github.event_name == 'push'
shell: bash
run: mvn -pl test-assembly-uber test
env:
DATABRICKS_HOST: ${{ secrets.JDBC_PAT_TEST_HOST_NAME }}
DATABRICKS_HTTP_PATH: ${{ secrets.JDBC_PAT_TEST_HTTP_PATH }}
DATABRICKS_USER: ${{ secrets.DATABRICKS_USER }}
DATABRICKS_TOKEN: ${{ secrets.JDBC_PAT_TEST_TOKEN }}
# Only run on push to main; secrets are not available for fork PRs
- name: Check Thin Jar Packaging
if: github.event_name == 'push'
shell: bash
run: mvn -pl test-assembly-thin test
env:
DATABRICKS_HOST: ${{ secrets.JDBC_PAT_TEST_HOST_NAME }}
DATABRICKS_HTTP_PATH: ${{ secrets.JDBC_PAT_TEST_HTTP_PATH }}
DATABRICKS_USER: ${{ secrets.DATABRICKS_USER }}
DATABRICKS_TOKEN: ${{ secrets.JDBC_PAT_TEST_TOKEN }}