Skip to content

Commit

Permalink
apacheGH-5: Add test CI: Docker based
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 9, 2024
1 parent b2063b4 commit b694b95
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 37 deletions.
1 change: 0 additions & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ github:
protected_branches:
main:
required_linear_history: true

notifications:
commits: commits@arrow.apache.org
issues_status: issues@arrow.apache.org
Expand Down
19 changes: 19 additions & 0 deletions .dockerallow
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 64 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ linters:
- gofmt
- goimports
- staticcheck

issues:
fix: true
28 changes: 16 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
24 changes: 24 additions & 0 deletions ci/docker/debian-12.dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 6 additions & 12 deletions ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
;;
Expand Down
50 changes: 50 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit b694b95

Please sign in to comment.