This is an automated email from the ASF dual-hosted git repository.
raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new fbf0d2d GH-5: Add test CI: Docker based (#105)
fbf0d2d is described below
commit fbf0d2d13bd6bb84ea7cf6d57e44204913542bbf
Author: Sutou Kouhei <[email protected]>
AuthorDate: Mon Sep 9 17:36:09 2024 +0900
GH-5: Add test CI: Docker based (#105)
Fix GH-5
This part:
https://github.com/apache/arrow/blob/58415d1fac50cb829b3dcf08526033d6db8c30db/.github/workflows/go.yml#L49-L135
---
.asf.yaml | 1 -
.env => .dockerallow | 4 +-
.env | 12 ++++++
.github/workflows/lint.yml | 4 --
.github/workflows/test.yml | 71 ++++++++++++++++++++++++++++++----
.golangci.yaml | 1 -
.pre-commit-config.yaml | 28 ++++++++------
.env => ci/docker/debian-12.dockerfile | 9 ++++-
ci/scripts/test.sh | 18 +++------
compose.yaml | 49 +++++++++++++++++++++++
10 files changed, 156 insertions(+), 41 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
index 6bedf14..b00a8f1 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -33,7 +33,6 @@ github:
protected_branches:
main:
required_linear_history: true
-
notifications:
commits: [email protected]
issues_status: [email protected]
diff --git a/.env b/.dockerallow
similarity index 86%
copy from .env
copy to .dockerallow
index da5111b..0e6ebbf 100644
--- a/.env
+++ b/.dockerallow
@@ -15,5 +15,5 @@
# 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.
+go.mod
+go.sum
diff --git a/.env b/.env
index da5111b..b7540e6 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 8b15cfb..caf59d8 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 0d22b37..33c04b6 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<<JSON" >> "$GITHUB_OUTPUT"
+ echo "[" >> "$GITHUB_OUTPUT"
+ cat <<JSON >> "$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 ce947e3..f850dc7 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 aa8aec1..b0e6666 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/.env b/ci/docker/debian-12.dockerfile
similarity index 80%
copy from .env
copy to ci/docker/debian-12.dockerfile
index da5111b..bcf0984 100644
--- a/.env
+++ b/ci/docker/debian-12.dockerfile
@@ -15,5 +15,10 @@
# 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.
+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 21c01fd..9edfab8 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 0000000..a17de30
--- /dev/null
+++ b/compose.yaml
@@ -0,0 +1,49 @@
+# 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"