Skip to content

Commit 5de6aa6

Browse files
authored
GH-48013: [R] Add CI job for musl (Alpine Linux) to replicate CRAN checks (#48014)
### Rationale for this change CRAN have added Alpine Linux to their additional jobs - we should make sure we can test for this on CI ### What changes are included in this PR? Add CI job for Alpine Linux ### Are these changes tested? Yeah, the CI job should pass ### Are there any user-facing changes? No * GitHub Issue: #48013 Authored-by: Nic Crane <[email protected]> Signed-off-by: Nic Crane <[email protected]>
1 parent c988d17 commit 5de6aa6

File tree

6 files changed

+146
-4
lines changed

6 files changed

+146
-4
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# Minimal Alpine Linux container with R for testing Arrow R package
19+
# on musl libc (CRAN runs checks on Alpine Linux 3.22)
20+
# Replicates CRAN's Alpine environment as closely as possible
21+
22+
ARG arch=amd64
23+
FROM ${arch}/alpine:3.22
24+
25+
# Install R and essential build tools
26+
# Note: bash is needed for Arrow CI scripts, even though CRAN's Alpine uses BusyBox
27+
RUN apk add \
28+
R \
29+
R-dev \
30+
R-doc \
31+
bash \
32+
checkbashisms \
33+
cmake \
34+
curl-dev \
35+
g++ \
36+
gcc \
37+
git \
38+
linux-headers \
39+
make \
40+
musl-locales \
41+
openssl-dev \
42+
pkgconfig \
43+
zlib-dev && \
44+
rm -rf /var/cache/apk/* && \
45+
ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
46+
echo "Etc/UTC" > /etc/timezone
47+
48+
# Set locale and timezone
49+
ENV LANG=C.UTF-8 \
50+
LC_COLLATE=C \
51+
MUSL_LOCPATH=/usr/share/i18n/locales/musl
52+
53+
# Set CRAN repo
54+
RUN echo 'options(repos = c(CRAN = "https://cran.rstudio.com"))' >> /usr/lib/R/etc/Rprofile.site
55+
56+
# Install pak for package management (following rhub pattern)
57+
RUN R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "devel", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
58+
59+
# Enable automatic system requirements installation
60+
ENV PKG_SYSREQS=true \
61+
R_PKG_SYSREQS2=true
62+
63+
# Set up parallel compilation
64+
RUN echo "MAKEFLAGS=-j$(R -s -e 'cat(parallel::detectCores())')" >> /usr/lib/R/etc/Renviron.site
65+
66+
# Configure image and install Arrow-specific tooling
67+
COPY ci/scripts/r_docker_configure.sh /arrow/ci/scripts/
68+
COPY ci/etc/rprofile /arrow/ci/etc/
69+
COPY ci/scripts/r_install_system_dependencies.sh /arrow/ci/scripts/
70+
COPY ci/scripts/install_minio.sh /arrow/ci/scripts/
71+
COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts/
72+
RUN /arrow/ci/scripts/r_docker_configure.sh
73+
74+
# Install sccache
75+
COPY ci/scripts/install_sccache.sh /arrow/ci/scripts/
76+
RUN /arrow/ci/scripts/install_sccache.sh unknown-linux-musl /usr/local/bin
77+
78+
# Install R package dependencies
79+
COPY ci/scripts/r_deps.sh /arrow/ci/scripts/
80+
COPY r/DESCRIPTION /arrow/r/
81+
RUN /arrow/ci/scripts/r_deps.sh /arrow
82+
83+
# Verify R works and this is musl
84+
RUN R --version && ldd --version 2>&1 | grep -q musl

ci/scripts/r_docker_configure.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ elif [ "`which yum`" ]; then
3939
PACKAGE_MANAGER=yum
4040
elif [ "`which zypper`" ]; then
4141
PACKAGE_MANAGER=zypper
42+
elif [ "`which apk`" ]; then
43+
PACKAGE_MANAGER=apk
4244
else
4345
PACKAGE_MANAGER=apt-get
4446
apt-get update --allow-releaseinfo-change # flag needed for when debian version changes
@@ -49,8 +51,12 @@ fi
4951
R_CUSTOM_CCACHE=`echo $R_CUSTOM_CCACHE | tr '[:upper:]' '[:lower:]'`
5052
if [ ${R_CUSTOM_CCACHE} = "true" ]; then
5153
# install ccache
52-
$PACKAGE_MANAGER install -y epel-release || true
53-
$PACKAGE_MANAGER install -y ccache
54+
if [ "$PACKAGE_MANAGER" = "apk" ]; then
55+
$PACKAGE_MANAGER add ccache
56+
else
57+
$PACKAGE_MANAGER install -y epel-release || true
58+
$PACKAGE_MANAGER install -y ccache
59+
fi
5460

5561
mkdir -p ~/.R
5662
echo "VER=
@@ -73,7 +79,11 @@ fi
7379

7480
# Install rsync for bundling cpp source and curl to make sure it is installed on all images,
7581
# cmake is now a listed sys req.
76-
$PACKAGE_MANAGER install -y rsync cmake curl
82+
if [ "$PACKAGE_MANAGER" = "apk" ]; then
83+
$PACKAGE_MANAGER add rsync cmake curl
84+
else
85+
$PACKAGE_MANAGER install -y rsync cmake curl
86+
fi
7787

7888
# Update clang version to latest available.
7989
# This is only for rhub/clang20. If we change the base image from rhub/clang20,

ci/scripts/r_install_system_dependencies.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ elif [ "`which yum`" ]; then
2828
PACKAGE_MANAGER=yum
2929
elif [ "`which zypper`" ]; then
3030
PACKAGE_MANAGER=zypper
31+
elif [ "`which apk`" ]; then
32+
PACKAGE_MANAGER=apk
3133
else
3234
PACKAGE_MANAGER=apt-get
3335
apt-get update
@@ -39,6 +41,9 @@ case "$PACKAGE_MANAGER" in
3941
apt-get)
4042
apt-get install -y libcurl4-openssl-dev libssl-dev
4143
;;
44+
apk)
45+
$PACKAGE_MANAGER add curl-dev openssl-dev
46+
;;
4247
*)
4348
$PACKAGE_MANAGER install -y libcurl-devel openssl-devel
4449
;;
@@ -59,6 +64,11 @@ if [ "$ARROW_S3" == "ON" ] || [ "$ARROW_GCS" == "ON" ] || [ "$ARROW_R_DEV" == "T
5964
ln -s /usr/bin/python3.10 /usr/local/bin/python
6065
ln -s /usr/bin/pip3.10 /usr/local/bin/pip
6166
;;
67+
apk)
68+
$PACKAGE_MANAGER add py3-pip
69+
ln -s /usr/bin/python3 /usr/local/bin/python
70+
ln -s /usr/bin/pip3 /usr/local/bin/pip
71+
;;
6272
*)
6373
$PACKAGE_MANAGER install -y python3-pip
6474
ln -s /usr/bin/python3 /usr/local/bin/python

compose.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ x-hierarchy:
114114
# service entry, so any new image/service must be listed here.
115115
- almalinux-verify-rc
116116
- alpine-linux-cpp
117+
- alpine-linux-r
117118
- centos-cpp-static
118119
- conda:
119120
- conda-cpp:
@@ -1773,6 +1774,37 @@ services:
17731774
command: >
17741775
/bin/bash -c "/arrow/ci/scripts/r_revdepcheck.sh /arrow"
17751776
1777+
alpine-linux-r:
1778+
# Usage:
1779+
# docker compose build alpine-linux-r
1780+
# docker compose run alpine-linux-r
1781+
# Tests R package installation on musl (Alpine Linux) for CRAN checks.
1782+
# R package builds C++ from source (bundled RE2 2023-03-01 supports musl).
1783+
# Parameters:
1784+
# ALPINE_LINUX: 3.22
1785+
# R: 4.5 (Alpine's R version)
1786+
# ARCH: amd64, arm64v8, ...
1787+
image: ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-r
1788+
build:
1789+
context: .
1790+
dockerfile: ci/docker/alpine-linux-${ALPINE_LINUX}-r.dockerfile
1791+
cache_from:
1792+
- ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-r
1793+
args:
1794+
arch: ${ARCH}
1795+
shm_size: *shm-size
1796+
environment:
1797+
<<: [*common, *sccache]
1798+
LIBARROW_BINARY: "false"
1799+
ARROW_SOURCE_HOME: "/arrow"
1800+
ARROW_R_DEV: ${ARROW_R_DEV}
1801+
ARROW_USE_PKG_CONFIG: "false"
1802+
SKIP_VIGNETTES: "true"
1803+
NOT_CRAN: "false"
1804+
volumes:
1805+
- .:/arrow:delegated
1806+
command: /arrow/ci/scripts/r_test.sh /arrow
1807+
17761808
############################## Integration ##################################
17771809

17781810
conda-integration:

dev/tasks/tasks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,12 @@ tasks:
665665
ci: github
666666
template: r/github.linux.cran.yml
667667

668+
test-r-alpine-linux-cran:
669+
ci: github
670+
template: docker-tests/github.linux.yml
671+
params:
672+
image: alpine-linux-r
673+
668674
test-r-macos-as-cran:
669675
ci: github
670676
template: r/github.macos.cran.yml

r/src/Makevars.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ PKG_LIBS=@libs@
3131
all: $(SHLIB) purify
3232

3333
purify: $(SHLIB)
34-
@rm -rf ../{libarrow,windows} || true
34+
@rm -rf ../libarrow ../windows || true

0 commit comments

Comments
 (0)