Skip to content

Commit

Permalink
Add test CI: macOS (#86)
Browse files Browse the repository at this point in the history
Fix GH-11

This part:
https://github.com/apache/arrow/blob/58415d1fac50cb829b3dcf08526033d6db8c30db/.github/workflows/go.yml#L305-L360

This also imports `ci/scripts/go_{build,test}.sh` from apache/arrow.

This also introduce ShellCheck and shfmt with pre-commit.

This also adds apache/arrow-testing and apache/parquet-testing
submodules.
  • Loading branch information
kou authored Sep 7, 2024
1 parent 70ac142 commit d486377
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

[*.sh]
indent_style = space
indent_size = 2
21 changes: 21 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

# All of the following environment variables are required to set default values
# for the parameters in docker-compose.yml.

STATICCHECK=v0.5.1
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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: Lint

on:
push:
pull_request:

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.12
- name: Install pre-commit
run: |
python -m pip install pre-commit
- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: |
pre-commit run --all-files --color=always --show-diff-on-failure
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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: Test

on:
push:
pull_request:

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

jobs:
macos:
name: AMD64 macOS 12 Go ${{ matrix.go }}
runs-on: macos-12
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
go:
- '1.21'
- '1.22'
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
submodules: recursive
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go }}
cache: true
cache-dependency-path: go.sum
- name: Install bash via Homebrew
run: |
brew install bash
- name: Install staticcheck
run: |
. .env
go install honnef.co/go/tools/cmd/staticcheck@${STATICCHECK}
- name: Build
run: |
$(brew --prefix)/bin/bash ci/scripts/build.sh $(pwd)
- name: Test
run: |
$(brew --prefix)/bin/bash ci/scripts/test.sh $(pwd)
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "arrow-testing"]
path = arrow-testing
url = https://github.com/apache/arrow-testing.git
[submodule "parquet-testing"]
path = parquet-testing
url = https://github.com/apache/parquet-testing.git
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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.

repos:
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
hooks:
- id: shfmt
args:
# The default args is "--write --simplify" but we don't use
# "--simplify". Because it's conflicted will ShellCheck.
- "--write"
1 change: 1 addition & 0 deletions arrow-testing
Submodule arrow-testing added at 4d2094
75 changes: 75 additions & 0 deletions ci/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/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 -eux

source_dir=${1}

# Need "all=" as per https://github.com/golang/go/issues/42131#issuecomment-713917379
export GOFLAGS="${GOFLAGS:-} -gcflags=all=-d=checkptr"

pushd "${source_dir}/arrow"

: "${ARROW_GO_TESTCGO:=}"

go_install_arrow_options=()
if [[ -n "${ARROW_GO_TESTCGO}" ]]; then
if [[ "${MSYSTEM:-}" = "MINGW64" ]]; then
export PATH=${MINGW_PREFIX}/bin:${PATH}
go clean -cache
go clean -testcache
fi
go_install_arrow_options+=("-tags" "assert,test,ccalloc")
fi

go install "${go_install_arrow_options[@]}" -v ./...

popd

pushd "${source_dir}/parquet"

go install -v ./...

popd

: "${ARROW_INTEGRATION_GO:=ON}"

if [[ "${ARROW_INTEGRATION_GO}" = "ON" ]]; then
pushd "${source_dir}/arrow/internal/cdata_integration"

case "$(uname)" in
Linux)
go_lib="arrow_go_integration.so"
;;
Darwin)
go_lib="arrow_go_integration.dylib"
;;
MINGW*)
go_lib="arrow_go_integration.dll"
;;
esac
go build \
-buildvcs=false \
-tags cdata_integration,assert \
-buildmode=c-shared \
-o "${go_lib}" \
.

popd
fi
89 changes: 89 additions & 0 deletions ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/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 -eux

# simplistic semver comparison
verlte() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}

ver=$(go env GOVERSION)

source_dir=${1}

case "$(uname)" in
MINGW*)
# -race and -asan don't work on Windows currently
test_args=()
;;
*)
if [[ "$(go env GOHOSTARCH)" == "s390x" ]]; then
# -race and -asan not supported on s390x
test_args=()
else
test_args=("-race")
if verlte "1.18" "${ver#go}" && [ "$(go env GOOS)" != "darwin" ]; then
# asan not supported on darwin/amd64
test_args+=("-asan")
fi
fi
;;
esac

# Go static check (skipped in MinGW)
if [[ -z "${MINGW_LINT:-}" ]]; then
pushd "${source_dir}"
"$(go env GOPATH)"/bin/staticcheck ./...
popd
fi

pushd "${source_dir}/arrow"

: "${ARROW_GO_TESTCGO:=}"

tags="assert,test"
if [[ -n "${ARROW_GO_TESTCGO}" ]]; then
if [[ "${MSYSTEM:-}" = "MINGW64" ]]; then
export PATH=${MINGW_PREFIX}\\bin:${MINGW_PREFIX}\\lib:$PATH
fi
tags+=",ccalloc"
fi

# the cgo implementation of the c data interface requires the "test"
# tag in order to run its tests so that the testing functions implemented
# in .c files don't get included in non-test builds.

go test "${test_args[@]}" -tags ${tags} ./...

# run it again but with the noasm tag
go test "${test_args[@]}" -tags ${tags},noasm ./...

popd

export PARQUET_TEST_DATA=${1}/parquet-testing/data
export ARROW_TEST_DATA=${1}/arrow-testing/data
pushd "${source_dir}/parquet"

go test "${test_args[@]}" -tags assert ./...

# run the tests again but with the noasm tag
go test "${test_args[@]}" -tags assert,noasm ./...

popd
1 change: 1 addition & 0 deletions parquet-testing
Submodule parquet-testing added at 50af3d

0 comments on commit d486377

Please sign in to comment.