| # 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: "Java Test" |
| description: "Run Java tests" |
| inputs: |
| artifact_name: |
| description: "Unique name for uploaded artifacts for this run" |
| required: true |
| suites: |
| description: 'Which Scalatest test suites to run' |
| required: false |
| default: '' |
| maven_opts: |
| description: 'Maven options passed to the mvn command' |
| required: false |
| default: '' |
| upload-test-reports: |
| description: 'Whether to upload test results including coverage to GitHub' |
| required: false |
| default: 'false' |
| skip-native-build: |
| description: 'Skip native build (when using pre-built artifact)' |
| required: false |
| default: 'false' |
| |
| runs: |
| using: "composite" |
| steps: |
| - name: Run Cargo release build |
| if: ${{ inputs.skip-native-build != 'true' }} |
| shell: bash |
| # it is important that we run the Scala tests against a release build rather than a debug build |
| # to make sure that no tests are relying on overflow checks that are present only in debug builds |
| run: | |
| cd native |
| cargo build --release |
| |
| # Evaluate hashFiles now, on the clean checkout, and reuse the result in the |
| # cache key below. The cache step's inputs are re-evaluated when its post |
| # (cache-save) phase runs, and by then the test run has left trees under the |
| # workspace (e.g. the Hive-catalog warehouse from CometIcebergEncryptionSuite) |
| # that make a fresh '**/pom.xml' walk throw "Fail to hash files under |
| # directory". A precomputed string keeps the save phase from re-walking them. |
| - name: Compute Maven cache key |
| id: maven-cache-key |
| if: ${{ runner.os != 'macOS' }} |
| shell: bash |
| run: echo "hash=${{ hashFiles('**/pom.xml') }}" >> "$GITHUB_OUTPUT" |
| |
| - name: Cache Maven dependencies |
| # TODO: remove next line after working again |
| # temporarily work around https://github.com/actions/runner-images/issues/13341 |
| # by disabling caching for macOS |
| if: ${{ runner.os != 'macOS' }} |
| uses: actions/cache@v5 |
| with: |
| path: | |
| ~/.m2/repository |
| /root/.m2/repository |
| key: ${{ runner.os }}-java-maven-${{ steps.maven-cache-key.outputs.hash }} |
| restore-keys: | |
| ${{ runner.os }}-java-maven- |
| |
| - name: Run all tests |
| shell: bash |
| if: ${{ inputs.suites == '' }} |
| env: |
| SPARK_LOCAL_HOSTNAME: "localhost" |
| SPARK_LOCAL_IP: "127.0.0.1" |
| run: | |
| MAVEN_OPTS="-Xmx4G -Xms2G -XX:+UnlockDiagnosticVMOptions -XX:+ShowMessageBoxOnError -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=./hs_err_pid%p.log" SPARK_HOME=`pwd` ./mvnw -B -Prelease install ${{ inputs.maven_opts }} |
| - name: Run specified tests |
| shell: bash |
| if: ${{ inputs.suites != '' }} |
| env: |
| SPARK_LOCAL_HOSTNAME: "localhost" |
| SPARK_LOCAL_IP: "127.0.0.1" |
| run: | |
| MAVEN_SUITES="$(echo "${{ inputs.suites }}" | paste -sd, -)" |
| echo "Running with MAVEN_SUITES=$MAVEN_SUITES" |
| MAVEN_OPTS="-Xmx4G -Xms2G -DwildcardSuites=$MAVEN_SUITES -XX:+UnlockDiagnosticVMOptions -XX:+ShowMessageBoxOnError -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=./hs_err_pid%p.log" SPARK_HOME=`pwd` ./mvnw -B -Prelease install ${{ inputs.maven_opts }} |
| - name: Upload crash logs |
| if: failure() |
| uses: actions/upload-artifact@v6 |
| with: |
| name: crash-logs-${{ inputs.artifact_name }} |
| path: "**/hs_err_pid*.log" |
| - name: Debug listing |
| if: failure() |
| shell: bash |
| run: | |
| echo "CWD: $(pwd)" |
| ls -lah . |
| ls -lah target |
| find . -name 'unit-tests.log' |
| - name: Upload unit-tests.log |
| if: failure() |
| uses: actions/upload-artifact@v6 |
| with: |
| name: unit-tests-${{ inputs.artifact_name }} |
| path: "**/target/unit-tests.log" |
| - name: Upload test results |
| if: ${{ inputs.upload-test-reports == 'true' }} |
| uses: actions/upload-artifact@v6 |
| with: |
| name: java-test-reports-${{ inputs.artifact_name }} |
| path: "**/target/surefire-reports/*.txt" |
| retention-days: 7 # 1 week for test reports |
| overwrite: true |