Skip to content

Minor fix to flaky test and README #3410

Minor fix to flaky test and README

Minor fix to flaky test and README #3410

Workflow file for this run

# This will run for all PRs
name: Build
on:
push:
branches: [ main, benchmarking-branch ]
pull_request:
types: [opened, synchronize, reopened]
branches: [ main, benchmarking-branch ]
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@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Checkout
uses: actions/checkout@v4
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- 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@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@v4
with:
fetch-depth: true
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Check Unit Tests
shell: bash
run: mvn test -Dtest='!**/integration/**,!**/DatabricksDriverExamples.java,!**/ProxyTest.java,!**/LoggingTest.java,!**/SSLTest.java'
- name: Install xmllint
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: JaCoCo report
run: mvn --batch-mode --errors jacoco:report --file pom.xml
- name: Extract codeCov percentage
shell: bash
run: |
COVERAGE_FILE="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