Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,33 @@ jobs:
shell: bash
run: ci/scripts/test.sh $(pwd)

go-interop:
name: arrow-go interop ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
runs-on:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 8.0.x
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: test/arrow-go-interop/go.mod
cache-dependency-path: test/arrow-go-interop/go.sum
- name: Test
shell: bash
run: ci/scripts/test_go_interop.sh $(pwd)

integration:
name: Integration
runs-on: ubuntu-latest
Expand Down
53 changes: 53 additions & 0 deletions ci/scripts/build_go_interop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.

# Builds the arrow-go interop shim (test/arrow-go-interop) as a C shared
# library and prints its path. Requires Go and a C compiler for cgo (on
# Windows, MinGW-w64 gcc).
#
# Usage: build_go_interop.sh <source_dir> [output_dir]
#
# Point the tests at the result with:
# export ARROW_GO_INTEROP_LIB=$(ci/scripts/build_go_interop.sh .)

set -euo pipefail

source_dir=$(cd "${1}" && pwd)
output_dir=${2:-${source_dir}/artifacts/arrow-go-interop}

case "$(uname -s)" in
Linux*) library_name=libarrow_go_interop.so ;;
Darwin*) library_name=libarrow_go_interop.dylib ;;
MINGW* | MSYS* | CYGWIN*) library_name=arrow_go_interop.dll ;;
*)
echo "Unsupported platform: $(uname -s)" >&2
exit 1
;;
esac

mkdir -p "${output_dir}"
output_dir=$(cd "${output_dir}" && pwd)

CGO_ENABLED=1 go build \
-C "${source_dir}/test/arrow-go-interop" \
-buildmode=c-shared \
-o "${output_dir}/${library_name}" \
. >&2

echo "${output_dir}/${library_name}"
72 changes: 72 additions & 0 deletions ci/scripts/test_go_interop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/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.

# Builds the arrow-go interop shim and runs the C Async Device Stream interop
# tests against it. Requires Go and a C compiler for cgo.
#
# Usage: test_go_interop.sh <source_dir>

set -euo pipefail

source_dir=$(cd "${1}" && pwd)

# Paths handed to .NET and Go must be native paths on Windows.
native_path() {
if type cygpath >/dev/null 2>&1; then
cygpath -m "${1}"
else
echo "${1}"
fi
}

echo "::group::Toolchain"
go version
go env CC CGO_ENABLED
cc_name=$(go env CC)
if type "${cc_name}" >/dev/null 2>&1; then
"${cc_name}" --version
else
echo "C compiler '${cc_name}' (needed by cgo) was not found on PATH" >&2
fi
echo "::endgroup::"

echo "::group::Build arrow-go interop shim"
library=$(bash "${source_dir}/ci/scripts/build_go_interop.sh" "${source_dir}")
echo "::endgroup::"

ARROW_GO_INTEROP_LIB=$(native_path "${library}")
ARROW_GO_INTEROP_REQUIRED=1
# The test host swallows stderr, so have Go write fatal errors here instead.
crash_log="$(dirname "${library}")/go-crash.log"
rm -f "${crash_log}"
ARROW_GO_INTEROP_CRASH_LOG=$(native_path "${crash_log}")
export ARROW_GO_INTEROP_LIB ARROW_GO_INTEROP_REQUIRED ARROW_GO_INTEROP_CRASH_LOG

status=0
dotnet test "${source_dir}/test/Apache.Arrow.Tests" \
--framework net8.0 \
--filter "FullyQualifiedName~CAsyncDeviceStreamGoInteropTests" ||
status=$?

if [ -s "${crash_log}" ]; then
echo "Go runtime crash output:" >&2
cat "${crash_log}" >&2
fi

exit "${status}"
1 change: 1 addition & 0 deletions dev/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*.resx
*.sln
*.slnf
test/arrow-go-interop/go.sum
.github/pull_request_template.md
src/Apache.Arrow/Flatbuf/*
docs/images/*.png
Expand Down
Loading
Loading