Skip to content

Commit

Permalink
ARROW-17358: [CI][C++] Add a job for Alpine Linux (apache#13825)
Browse files Browse the repository at this point in the history
Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou authored and ksuarez1423 committed Aug 15, 2022
1 parent 5c99d84 commit c240da4
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 34 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ULIMIT_CORE=-1

# Default versions for platforms
ALMALINUX=8
ALPINE_LINUX=3.16
DEBIAN=11
FEDORA=35
UBUNTU=20.04
Expand Down
102 changes: 102 additions & 0 deletions ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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
FROM ${arch}/alpine:3.16

RUN apk add \
bash \
benchmark-dev \
boost-dev \
brotli-dev \
bzip2-dev \
c-ares-dev \
ccache \
clang \
cmake \
curl-dev \
g++ \
gcc \
gdb \
gflags-dev \
git \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
lz4-dev \
make \
musl-locales \
nlohmann-json \
openssl-dev \
perl \
pkgconfig \
protobuf-dev \
py3-pip \
py3-numpy-dev \
python3-dev \
rapidjson-dev \
re2-dev \
rsync \
samurai \
snappy-dev \
sqlite-dev \
thrift-dev \
tzdata \
utf8proc-dev \
zlib-dev \
zstd-dev && \
rm -rf /var/cache/apk/* && \
ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
echo "Etc/UTC" > /etc/timezone

COPY ci/scripts/install_minio.sh /arrow/ci/scripts/
RUN /arrow/ci/scripts/install_minio.sh latest /usr/local

COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts/
RUN /arrow/ci/scripts/install_gcs_testbench.sh default

ENV ARROW_BUILD_TESTS=ON \
ARROW_DATASET=ON \
ARROW_DEPENDENCY_SOURCE=SYSTEM \
ARROW_FLIGHT=ON \
ARROW_FLIGHT_SQL=ON \
ARROW_GANDIVA=ON \
ARROW_GCS=ON \
ARROW_HOME=/usr/local \
ARROW_ORC=ON \
ARROW_PARQUET=ON \
ARROW_PLASMA=ON \
ARROW_S3=ON \
ARROW_USE_CCACHE=ON \
ARROW_WITH_BROTLI=ON \
ARROW_WITH_BZ2=ON \
ARROW_WITH_LZ4=ON \
ARROW_WITH_OPENTELEMETRY=OFF \
ARROW_WITH_MUSL=ON \
ARROW_WITH_SNAPPY=ON \
ARROW_WITH_ZLIB=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
CMAKE_CXX_STANDARD=17 \
google_cloud_cpp_storage_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
3 changes: 2 additions & 1 deletion ci/scripts/cpp_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ cmake \
-DARROW_WITH_BZ2=${ARROW_WITH_BZ2:-OFF} \
-DARROW_WITH_LZ4=${ARROW_WITH_LZ4:-OFF} \
-DARROW_WITH_OPENTELEMETRY=${ARROW_WITH_OPENTELEMETRY:-OFF} \
-DARROW_WITH_MUSL=${ARROW_WITH_MUSL:-OFF} \
-DARROW_WITH_SNAPPY=${ARROW_WITH_SNAPPY:-OFF} \
-DARROW_WITH_UTF8PROC=${ARROW_WITH_UTF8PROC:-ON} \
-DARROW_WITH_ZLIB=${ARROW_WITH_ZLIB:-OFF} \
Expand Down Expand Up @@ -172,7 +173,7 @@ time cmake --build . --target install
popd

if [ -x "$(command -v ldconfig)" ]; then
ldconfig
ldconfig ${ARROW_HOME}/${CMAKE_INSTALL_LIBDIR:-lib}
fi

if [ "${ARROW_USE_CCACHE}" == "ON" ]; then
Expand Down
5 changes: 2 additions & 3 deletions cpp/build-support/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ function run_test() {
# XML output from gtest. We assume that gtest knows better than us and our
# regexes in most cases, but for certain errors we delete the resulting xml
# file and let our own post-processing step regenerate it.
export GREP=$(which egrep)
if zgrep --silent "ThreadSanitizer|Leak check.*detected leaks" $LOGFILE ; then
if grep -E -q "ThreadSanitizer|Leak check.*detected leaks" $LOGFILE ; then
echo ThreadSanitizer or leak check failures in $LOGFILE
STATUS=1
rm -f $XMLFILE
Expand Down Expand Up @@ -157,7 +156,7 @@ function post_process_tests() {
# If we have a LeakSanitizer report, and XML reporting is configured, add a new test
# case result to the XML file for the leak report. Otherwise Jenkins won't show
# us which tests had LSAN errors.
if zgrep --silent "ERROR: LeakSanitizer: detected memory leaks" $LOGFILE ; then
if grep -E -q "ERROR: LeakSanitizer: detected memory leaks" $LOGFILE ; then
echo Test had memory leaks. Editing XML
perl -p -i -e '
if (m#</testsuite>#) {
Expand Down
2 changes: 2 additions & 0 deletions cpp/cmake_modules/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ if(ARROW_DEFINE_OPTIONS)

define_option(ARROW_GGDB_DEBUG "Pass -ggdb flag to debug builds" ON)

define_option(ARROW_WITH_MUSL "Whether the system libc is musl or not" OFF)

#----------------------------------------------------------------------
set_option_category("Test and benchmark")

Expand Down
39 changes: 14 additions & 25 deletions cpp/src/arrow/csv/converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,47 +624,36 @@ TEST(TimestampConversion, UserDefinedParsers) {
{{86400000}, {172800000}}, options);
}

#ifndef _WIN32
TEST(TimestampConversion, UserDefinedParsersWithZone) {
auto options = ConvertOptions::Defaults();
auto type = timestamp(TimeUnit::SECOND, "America/Phoenix");

// Test a single parser
options.timestamp_parsers = {TimestampParser::MakeStrptime("%m/%d/%Y %z")};
AssertConversion<TimestampType, int64_t>(type, {"01/02/1970 +0000,01/03/1970 +0000\n"},
{{86400}, {172800}}, options);
if (internal::kStrptimeSupportsZone) {
AssertConversion<TimestampType, int64_t>(
type, {"01/02/1970 +0000,01/03/1970 +0000\n"}, {{86400}, {172800}}, options);
} else {
AssertConversionError(type, {"01/02/1970 +0000,01/03/1970 +0000\n"}, {0, 1}, options);
}

// Test multiple parsers
options.timestamp_parsers.push_back(TimestampParser::MakeISO8601());
AssertConversion<TimestampType, int64_t>(
type, {"01/02/1970 +0000,1970-01-03T00:00:00+0000\n"}, {{86400}, {172800}},
options);
if (internal::kStrptimeSupportsZone) {
AssertConversion<TimestampType, int64_t>(
type, {"01/02/1970 +0000,1970-01-03T00:00:00+0000\n"}, {{86400}, {172800}},
options);
} else {
AssertConversionError(type, {"01/02/1970 +0000,1970-01-03T00:00:00+0000\n"}, {0},
options);
}

// Test errors
options.timestamp_parsers = {TimestampParser::MakeStrptime("%m/%d/%Y")};
AssertConversionError(type, {"01/02/1970,01/03/1970\n"}, {0, 1}, options);
options.timestamp_parsers.push_back(TimestampParser::MakeISO8601());
AssertConversionError(type, {"01/02/1970,1970-01-03T00:00:00+0000\n"}, {0}, options);
}
#else
// Windows uses the vendored musl strptime which doesn't support %z.
TEST(TimestampConversion, UserDefinedParsersWithZone) {
auto options = ConvertOptions::Defaults();
auto type = timestamp(TimeUnit::SECOND, "America/Phoenix");

options.timestamp_parsers = {TimestampParser::MakeStrptime("%m/%d/%Y %z")};
AssertConversionError(type, {"01/02/1970 +0000,01/03/1970 +0000\n"}, {0, 1}, options);

options.timestamp_parsers.push_back(TimestampParser::MakeISO8601());
AssertConversionError(type, {"01/02/1970 +0000,1970-01-03T00:00:00+0000\n"}, {0},
options);

options.timestamp_parsers = {TimestampParser::MakeStrptime("%m/%d/%Y")};
AssertConversionError(type, {"01/02/1970,01/03/1970\n"}, {0, 1}, options);
options.timestamp_parsers.push_back(TimestampParser::MakeISO8601());
AssertConversionError(type, {"01/02/1970,1970-01-03T00:00:00+0000\n"}, {0}, options);
}
#endif

Decimal128 Dec128(util::string_view value) {
Decimal128 dec;
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/util/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#cmakedefine ARROW_GCS
#cmakedefine ARROW_S3
#cmakedefine ARROW_USE_NATIVE_INT128
#cmakedefine ARROW_WITH_MUSL
#cmakedefine ARROW_WITH_OPENTELEMETRY
#cmakedefine ARROW_WITH_UCX

Expand Down
3 changes: 2 additions & 1 deletion cpp/src/arrow/util/value_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "arrow/type.h"
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/config.h"
#include "arrow/util/macros.h"
#include "arrow/util/time.h"
#include "arrow/util/visibility.h"
Expand Down Expand Up @@ -770,7 +771,7 @@ static inline bool ParseTimestampISO8601(const char* s, size_t length,
return true;
}

#ifdef _WIN32
#if defined(_WIN32) || defined(ARROW_WITH_MUSL)
static constexpr bool kStrptimeSupportsZone = false;
#else
static constexpr bool kStrptimeSupportsZone = true;
Expand Down
3 changes: 2 additions & 1 deletion dev/tasks/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ tasks:

############################## Docker tests ##################################

{% for image in ["conda-cpp",
{% for image in ["alpine-linux-cpp",
"conda-cpp",
"debian-c-glib",
"ubuntu-c-glib",
"debian-ruby",
Expand Down
38 changes: 35 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ x-hierarchy:
# descendant images if any. Archery checks that all node has a corresponding
# service entry, so any new image/service must be listed here.
- almalinux-verify-rc
- alpine-linux-cpp
- centos-cpp-static
- conda:
- conda-cpp:
Expand Down Expand Up @@ -162,6 +163,8 @@ x-hierarchy:
volumes:
almalinux-ccache:
name: ${ARCH}-almalinux-ccache
alpine-linux-ccache:
name: ${ARCH}-alpine-linux-ccache
conda-ccache:
name: ${ARCH}-conda-ccache
debian-ccache:
Expand Down Expand Up @@ -192,6 +195,36 @@ services:
# -e ARROW_TEST_LINKAGE=static \
# conda-cpp|debian-cpp|...

alpine-linux-cpp:
# Usage:
# docker-compose build alpine-linux-cpp
# docker-compose run --rm alpine-linux-cpp
# Parameters:
# ALPINE_LINUX: 3.16
# ARCH: amd64, arm64v8, ...
image: ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-cpp
build:
context: .
dockerfile: ci/docker/alpine-linux-${ALPINE_LINUX}-cpp.dockerfile
cache_from:
- ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-cpp
args:
arch: ${ARCH}
shm_size: &shm-size 2G
ulimits: &ulimits
core: ${ULIMIT_CORE}
environment:
<<: *ccache
ARROW_ENABLE_TIMING_TESTS: # inherit
ARROW_MIMALLOC: "ON"
volumes: &alpine-linux-volumes
- .:/arrow:delegated
- ${DOCKER_VOLUME_PREFIX}alpine-linux-ccache:/ccache:delegated
command: >-
/bin/bash -c "
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/cpp_test.sh /arrow /build"
conda:
# Base image for conda builds.
#
Expand Down Expand Up @@ -229,9 +262,8 @@ services:
args:
repo: ${REPO}
arch: ${ARCH}
shm_size: &shm-size 2G
ulimits: &ulimits
core: ${ULIMIT_CORE}
shm_size: *shm-size
ulimits: *ulimits
environment:
<<: *ccache
ARROW_BUILD_BENCHMARKS: "ON"
Expand Down

0 comments on commit c240da4

Please sign in to comment.