diff --git a/.asf.yaml b/.asf.yaml index 6bedf146..b00a8f1e 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -33,7 +33,6 @@ github: protected_branches: main: required_linear_history: true - notifications: commits: commits@arrow.apache.org issues_status: issues@arrow.apache.org diff --git a/.dockerallow b/.dockerallow new file mode 100644 index 00000000..0e6ebbfa --- /dev/null +++ b/.dockerallow @@ -0,0 +1,19 @@ +# 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. + +go.mod +go.sum diff --git a/.env b/.env index da5111b4..b7540e6c 100644 --- a/.env +++ b/.env @@ -17,3 +17,15 @@ # All of the following environment variables are required to set default values # for the parameters in docker-compose.yml. + +# different architecture notations +ARCH=amd64 + +# Default repository to pull and push images from +REPO=ghcr.io/apache/arrow-go + +# Default versions for platforms +DEBIAN=12 + +# Default versions for various dependencies +GO=1.22.6 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8b15cfb5..caf59d8d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,20 +16,16 @@ # under the License. name: Lint - on: push: branches-ignore: - 'dependabot/**' pull_request: - concurrency: group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} cancel-in-progress: true - permissions: contents: read - jobs: lint: name: Lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d22b377..33c04b68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,25 +16,83 @@ # under the License. name: Test - on: push: branches-ignore: - 'dependabot/**' pull_request: - concurrency: group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} cancel-in-progress: true - permissions: contents: read - jobs: + docker-targets: + name: Docker targets + runs-on: ubuntu-latest + outputs: + targets: ${{ steps.detect-targets.outputs.targets }} + steps: + - name: Detect targets + id: detect-targets + run: | + echo "targets<> "$GITHUB_OUTPUT" + echo "[" >> "$GITHUB_OUTPUT" + cat <> "$GITHUB_OUTPUT" + { + "arch-label": "AMD64", + "arch": "amd64", + "go": "1.22", + "runs-on": "ubuntu-latest" + }, + { + "arch-label": "AMD64", + "arch": "amd64", + "go": "1.23", + "runs-on": "ubuntu-latest" + } + JSON + echo "]" >> "$GITHUB_OUTPUT" + echo "JSON" >> "$GITHUB_OUTPUT" + docker: + name: ${{ matrix.arch-label }} Debian 12 Go ${{ matrix.go }} + needs: docker-targets + runs-on: ${{ matrix.runs-on }} + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.docker-targets.outputs.targets) }} + env: + ARCH: ${{ matrix.arch }} + 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-go || : + - name: Test + run: | + docker compose run debian-go + - 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-go macos: name: AMD64 macOS 12 Go ${{ matrix.go }} runs-on: macos-12 - timeout-minutes: 30 + timeout-minutes: 15 strategy: fail-fast: false matrix: @@ -61,11 +119,10 @@ jobs: - name: Test run: | $(brew --prefix)/bin/bash ci/scripts/test.sh $(pwd) - windows: name: AMD64 Windows 2019 Go ${{ matrix.go }} runs-on: windows-2019 - timeout-minutes: 25 + timeout-minutes: 15 strategy: fail-fast: false matrix: diff --git a/.golangci.yaml b/.golangci.yaml index ce947e37..f850dc7e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -25,6 +25,5 @@ linters: - gofmt - goimports - staticcheck - issues: fix: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa8aec1b..b0e6666d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,18 +16,6 @@ # 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" - repo: https://github.com/golangci/golangci-lint rev: v1.60.3 hooks: @@ -42,3 +30,19 @@ repos: - id: golangci-lint-full name: golangci-lint-full-internal entry: bash -c 'cd internal && golangci-lint run' + - 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" + - repo: https://github.com/google/yamlfmt + rev: v0.13.0 + hooks: + - id: yamlfmt diff --git a/ci/docker/debian-12.dockerfile b/ci/docker/debian-12.dockerfile new file mode 100644 index 00000000..bcf0984d --- /dev/null +++ b/ci/docker/debian-12.dockerfile @@ -0,0 +1,24 @@ +# 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 arch=amd64 +ARG go=1.22.6 +FROM ${arch}/golang:${go}-bookworm + +# Copy the go.mod and go.sum over and pre-download all the dependencies +COPY . /arrow-go +RUN cd /arrow-go && go mod download diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh index 21c01fd8..9edfab81 100755 --- a/ci/scripts/test.sh +++ b/ci/scripts/test.sh @@ -19,13 +19,6 @@ 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 @@ -34,14 +27,15 @@ MINGW*) test_args=() ;; *) - if [[ "$(go env GOHOSTARCH)" == "s390x" ]]; then + 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") + if [[ "$(go env GOOS)" = "darwin" ]]; then + # -asan not supported on darwin/amd64 + test_args=("-race") + else + test_args=("-asan") fi fi ;; diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..9286f535 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,50 @@ +# 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. + +# Usage +# ----- +# +# The docker compose file is parametrized using environment variables, the +# defaults are set in .env file. +# +# Example: +# $ ARCH=arm64v8 docker compose build debian-go +# $ ARCH=arm64v8 docker compose run debian-go + +services: + debian-go: + # Usage: + # docker compose build debian-go + # docker compose run debian-go + image: ${REPO}:${ARCH}-debian-${DEBIAN}-${GO} + build: + context: . + dockerfile: ci/docker/debian-${DEBIAN}.dockerfile + cache_from: + - ${REPO}:${ARCH}-debian-${DEBIAN}-${GO} + args: + arch: ${ARCH} + go: ${GO} + shm_size: &shm-size 2G + volumes: &debian-volumes + - .:/arrow-go:delegated + command: &go-command > + /bin/bash -c " + + git config --global --add safe.directory /arrow-go && + /arrow-go/ci/scripts/build.sh /arrow-go && + /arrow-go/ci/scripts/test.sh /arrow-go"