diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d0efeb6..fb5acc34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -129,6 +129,46 @@ jobs: continue-on-error: true run: | docker compose push debian-cgo + docker_cgo_python: + name: AMD64 Debian 12 Go ${{ matrix.go }} - CGO Python + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + go: + - '1.22' + - '1.23' + env: + GO: ${{ matrix.go }} + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + submodules: recursive + - name: Login to GitHub Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pull + run: | + docker compose pull debian || : + docker compose pull debian-cgo-python || : + - name: Build + run: | + docker compose build debian + docker compose build debian-cgo-python + - name: Test + run: | + docker compose run debian-cgo-python + - name: Push + if: >- + success() && github.event_name == 'push' && github.repository == 'apache/arrow-go' && github.ref_name == 'main' + continue-on-error: true + run: | + docker compose push debian-cgo-python macos: name: AMD64 macOS 12 Go ${{ matrix.go }} runs-on: macos-12 diff --git a/ci/docker/debian-12-cgo-python.dockerfile b/ci/docker/debian-12-cgo-python.dockerfile new file mode 100644 index 00000000..a24955f7 --- /dev/null +++ b/ci/docker/debian-12-cgo-python.dockerfile @@ -0,0 +1,34 @@ +# 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. + +ARG base +FROM ${base} + +ENV DEBIAN_FRONTEND noninteractive + +# Install python3 and pip so we can install pyarrow to test the C data interface. +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + python3 \ + python3-pip \ + python3-venv && \ + apt-get clean + +ENV ARROW_PYTHON_VENV /arrow-dev +RUN python3 -m venv ${ARROW_PYTHON_VENV} && \ + . ${ARROW_PYTHON_VENV}/bin/activate && \ + pip install pyarrow cffi --only-binary pyarrow diff --git a/ci/scripts/go_cgo_python_test.sh b/ci/scripts/go_cgo_python_test.sh new file mode 100755 index 00000000..253ff726 --- /dev/null +++ b/ci/scripts/go_cgo_python_test.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# 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. + +set -ex + +source_dir=${1} + +if [ -n "${ARROW_PYTHON_VENV:-}" ]; then + . "${ARROW_PYTHON_VENV}/bin/activate" +fi + +export GOFLAGS="${GOFLAGS} -gcflags=all=-d=checkptr" + +pushd ${source_dir}/arrow/cdata/test + +case "$(uname)" in + Linux) + testlib="cgotest.so" + ;; + Darwin) + testlib="cgotest.so" + ;; + MINGW*) + testlib="cgotest.dll" + ;; +esac + +go build -tags cdata_test,assert -buildmode=c-shared -buildvcs=false -o $testlib . + +python test_export_to_cgo.py + +rm $testlib +rm "${testlib%.*}.h" + +popd diff --git a/compose.yaml b/compose.yaml index 42d306bc..0b1f48b8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -64,3 +64,21 @@ services: environment: ARROW_GO_TESTCGO: "1" command: *go-command + debian-cgo-python: + # Usage: + # docker compose build debian-cgo-python + # docker compose run debian-cgo-python + image: ${REPO}:${ARCH}-debian-${DEBIAN}-${GO}-cgo-python + build: + context: . + dockerfile: ci/docker/debian-${DEBIAN}-cgo-python.dockerfile + cache_from: + - ${REPO}:${ARCH}-debian-${DEBIAN}-${GO}-cgo-python + args: + base: ${REPO}:${ARCH}-debian-${DEBIAN}-${GO} + shm_size: *shm-size + volumes: *debian-volumes + command: &cgo-python-command > + /bin/bash -c " + git config --global --add safe.directory /arrow && + /arrow-go/ci/scripts/go_cgo_python_test.sh /arrow-go"