|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +name: Spark Search Docker |
| 14 | + |
| 15 | +on: |
| 16 | + pull_request: |
| 17 | + types: |
| 18 | + - opened |
| 19 | + - synchronize |
| 20 | + - ready_for_review |
| 21 | + - reopened |
| 22 | + paths: |
| 23 | + - ".github/workflows/spark-search.yml" |
| 24 | + - "Makefile" |
| 25 | + - "docker/**" |
| 26 | + - "integration-tests/**" |
| 27 | + - "lance-spark-base_2.12/src/main/java/org/lance/spark/search/**" |
| 28 | + - "lance-spark-base_2.12/src/main/scala/org/lance/spark/search/**" |
| 29 | + - "lance-spark-base_2.12/src/test/java/org/lance/spark/search/**" |
| 30 | + - "lance-spark-*/src/main/scala/org/lance/spark/extensions/**" |
| 31 | + - "pom.xml" |
| 32 | + - "*/pom.xml" |
| 33 | + workflow_dispatch: |
| 34 | + inputs: |
| 35 | + spark-version: |
| 36 | + description: "Spark version to test" |
| 37 | + required: true |
| 38 | + default: "3.5" |
| 39 | + scala-version: |
| 40 | + description: "Scala version to test" |
| 41 | + required: true |
| 42 | + default: "2.13" |
| 43 | + backends: |
| 44 | + description: "Comma-separated test backends: local or local,rest-dir" |
| 45 | + required: true |
| 46 | + default: "local,rest-dir" |
| 47 | + rest-uri: |
| 48 | + description: "Optional REST namespace URI. If omitted, tests start a local REST directory namespace." |
| 49 | + required: false |
| 50 | + default: "" |
| 51 | + rest-database: |
| 52 | + description: "Optional database header value for an external REST namespace" |
| 53 | + required: false |
| 54 | + default: "" |
| 55 | + docker-run-args: |
| 56 | + description: "Extra docker run args for docker-test" |
| 57 | + required: false |
| 58 | + default: "" |
| 59 | + |
| 60 | +permissions: |
| 61 | + contents: read |
| 62 | + |
| 63 | +concurrency: |
| 64 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 65 | + cancel-in-progress: true |
| 66 | + |
| 67 | +env: |
| 68 | + SPARK_VERSION: ${{ github.event.inputs['spark-version'] || '3.5' }} |
| 69 | + SCALA_VERSION: ${{ github.event.inputs['scala-version'] || '2.13' }} |
| 70 | + SEARCH_TEST_BACKENDS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.backends || 'local,rest-dir' }} |
| 71 | + SEARCH_PYTEST_CMD: >- |
| 72 | + pytest /home/lance/tests/test_lance_spark.py::TestDQLSearchTableFunctions |
| 73 | + -v --timeout=180 |
| 74 | +
|
| 75 | +jobs: |
| 76 | + search-docker-test: |
| 77 | + name: Search Docker Test |
| 78 | + runs-on: ubuntu-24.04 |
| 79 | + timeout-minutes: 90 |
| 80 | + steps: |
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 85 | + - name: Set up Java |
| 86 | + uses: actions/setup-java@v4 |
| 87 | + with: |
| 88 | + distribution: temurin |
| 89 | + java-version: 17 |
| 90 | + cache: "maven" |
| 91 | + - name: Resolve Docker build args |
| 92 | + id: docker-args |
| 93 | + run: | |
| 94 | + make print-docker-build-args SPARK_VERSION=${SPARK_VERSION} SCALA_VERSION=${SCALA_VERSION} >> $GITHUB_OUTPUT |
| 95 | + - name: Set up Docker Buildx |
| 96 | + uses: docker/setup-buildx-action@v3 |
| 97 | + - name: Build test-base image (cached) |
| 98 | + uses: docker/build-push-action@v6 |
| 99 | + with: |
| 100 | + context: docker |
| 101 | + file: docker/Dockerfile.test-base |
| 102 | + load: true |
| 103 | + tags: lance-spark-test-base:${{ env.SPARK_VERSION }}_${{ env.SCALA_VERSION }} |
| 104 | + build-args: | |
| 105 | + SPARK_DOWNLOAD_VERSION=${{ steps.docker-args.outputs.spark-download-version }} |
| 106 | + SPARK_MAJOR_VERSION=${{ env.SPARK_VERSION }} |
| 107 | + SCALA_VERSION=${{ env.SCALA_VERSION }} |
| 108 | + PY4J_VERSION=${{ steps.docker-args.outputs.py4j-version }} |
| 109 | + SPARK_SCALA_SUFFIX=${{ steps.docker-args.outputs.spark-scala-suffix }} |
| 110 | + cache-from: type=gha,scope=search-test-base-${{ env.SPARK_VERSION }}_${{ env.SCALA_VERSION }} |
| 111 | + cache-to: type=gha,mode=max,scope=search-test-base-${{ env.SPARK_VERSION }}_${{ env.SCALA_VERSION }} |
| 112 | + - name: Build bundle |
| 113 | + run: make bundle SPARK_VERSION=${SPARK_VERSION} SCALA_VERSION=${SCALA_VERSION} |
| 114 | + - name: Build test image |
| 115 | + run: | |
| 116 | + make docker-build-test \ |
| 117 | + SPARK_VERSION=${SPARK_VERSION} \ |
| 118 | + SCALA_VERSION=${SCALA_VERSION} \ |
| 119 | + LANCE_NAMESPACE_IMPL_VERSION=${{ steps.docker-args.outputs.lance-namespace-impl-version }} |
| 120 | + - name: Run directory namespace search tests |
| 121 | + if: ${{ contains(env.SEARCH_TEST_BACKENDS, 'local') }} |
| 122 | + run: | |
| 123 | + make docker-test \ |
| 124 | + SPARK_VERSION=${SPARK_VERSION} \ |
| 125 | + SCALA_VERSION=${SCALA_VERSION} \ |
| 126 | + TEST_BACKENDS=local \ |
| 127 | + PYTEST_CMD="${SEARCH_PYTEST_CMD}" |
| 128 | + - name: Resolve REST namespace URI |
| 129 | + id: rest |
| 130 | + if: ${{ contains(env.SEARCH_TEST_BACKENDS, 'rest-dir') }} |
| 131 | + env: |
| 132 | + INPUT_REST_URI: ${{ github.event.inputs['rest-uri'] }} |
| 133 | + INPUT_DOCKER_RUN_ARGS: ${{ github.event.inputs['docker-run-args'] }} |
| 134 | + run: | |
| 135 | + rest_uri="${INPUT_REST_URI}" |
| 136 | + docker_run_args="${INPUT_DOCKER_RUN_ARGS}" |
| 137 | + start_rest_dir="false" |
| 138 | + rest_dir_root="" |
| 139 | + rest_dir_port="" |
| 140 | +
|
| 141 | + if [ -z "${rest_uri}" ]; then |
| 142 | + rest_dir_port="10024" |
| 143 | + rest_dir_root="/home/lance/rest-data" |
| 144 | + rest_uri="http://127.0.0.1:${rest_dir_port}" |
| 145 | + start_rest_dir="true" |
| 146 | + fi |
| 147 | +
|
| 148 | + echo "uri=${rest_uri}" >> "$GITHUB_OUTPUT" |
| 149 | + echo "start_rest_dir=${start_rest_dir}" >> "$GITHUB_OUTPUT" |
| 150 | + echo "rest_dir_root=${rest_dir_root}" >> "$GITHUB_OUTPUT" |
| 151 | + echo "rest_dir_port=${rest_dir_port}" >> "$GITHUB_OUTPUT" |
| 152 | + { |
| 153 | + echo "docker_run_args<<EOF" |
| 154 | + echo "${docker_run_args}" |
| 155 | + echo "EOF" |
| 156 | + } >> "$GITHUB_OUTPUT" |
| 157 | + - name: Run REST directory namespace search tests |
| 158 | + if: ${{ contains(env.SEARCH_TEST_BACKENDS, 'rest-dir') }} |
| 159 | + env: |
| 160 | + LANCE_SPARK_REST_URI: ${{ steps.rest.outputs.uri }} |
| 161 | + LANCE_SPARK_REST_API_KEY: ${{ secrets.LANCE_SPARK_REST_API_KEY }} |
| 162 | + LANCE_SPARK_REST_DATABASE: ${{ github.event.inputs['rest-database'] }} |
| 163 | + LANCE_SPARK_START_REST_DIR: ${{ steps.rest.outputs.start_rest_dir }} |
| 164 | + LANCE_SPARK_REST_DIR_ROOT: ${{ steps.rest.outputs.rest_dir_root }} |
| 165 | + LANCE_SPARK_REST_DIR_PORT: ${{ steps.rest.outputs.rest_dir_port }} |
| 166 | + DOCKER_RUN_ARGS: ${{ steps.rest.outputs.docker_run_args }} |
| 167 | + run: | |
| 168 | + make docker-test \ |
| 169 | + SPARK_VERSION=${SPARK_VERSION} \ |
| 170 | + SCALA_VERSION=${SCALA_VERSION} \ |
| 171 | + TEST_BACKENDS=rest-dir \ |
| 172 | + LANCE_SPARK_REST_URI="${LANCE_SPARK_REST_URI}" \ |
| 173 | + LANCE_SPARK_REST_API_KEY="${LANCE_SPARK_REST_API_KEY}" \ |
| 174 | + LANCE_SPARK_REST_DATABASE="${LANCE_SPARK_REST_DATABASE}" \ |
| 175 | + LANCE_SPARK_START_REST_DIR="${LANCE_SPARK_START_REST_DIR}" \ |
| 176 | + LANCE_SPARK_REST_DIR_ROOT="${LANCE_SPARK_REST_DIR_ROOT}" \ |
| 177 | + LANCE_SPARK_REST_DIR_PORT="${LANCE_SPARK_REST_DIR_PORT}" \ |
| 178 | + DOCKER_RUN_ARGS="${DOCKER_RUN_ARGS}" \ |
| 179 | + PYTEST_CMD="${SEARCH_PYTEST_CMD}" |
0 commit comments