ci: build last four minor R versions instead of only the latest #6

Merged
pat-s merged 1 commit from t3code/2a207854 into main 2026-06-12 17:16:44 +00:00
Showing only changes of commit d2fc0c9600 - Show all commits

ci: build last four minor R versions instead of only the latest

Derive the latest patch release of each of the last four minor R versions
from posit's versions.json and build any that are missing from S3,
so older supported minors stay available rather than only the newest stable.

Replace the awk regex existence check with a literal index() match;
the unescaped version dots made e.g. 4.4.3 spuriously match 4.3.3.
Patrick Schratz 2026-06-12 16:08:46 +02:00
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -114,15 +114,26 @@ steps:
kubernetes.io/arch: "${ARCH}" kubernetes.io/arch: "${ARCH}"
- name: Get latest R version - name: Get R versions to build
image: reg.devxy.io/docker.io/library/alpine:3.23 image: reg.devxy.io/docker.io/library/alpine:3.23
privileged: true privileged: true
commands: commands:
- ip link set dev eth0 mtu 1280 2>/dev/null || true - ip link set dev eth0 mtu 1280 2>/dev/null || true
- for i in 1 2 3 4 5; do apk add -q --no-cache curl jq && break; sleep 5; done - for i in 1 2 3 4 5; do apk add -q --no-cache curl jq && break; sleep 5; done
- curl -sf https://formulae.brew.sh/api/formula/r.json | jq -er '.versions.stable' > r-version-to-build.txt # Latest patch release of each of the last 4 minor R versions (e.g. 4.6.0, 4.5.3, 4.4.3, 4.3.3).
# - echo "4.1.3" > r-version-to-build.txt - |
- cat r-version-to-build.txt curl -sf https://cdn.posit.co/r/versions.json | jq -r '
.r_versions
| map(select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$")))
| group_by(split(".")[0:2] | join("."))
| map(max_by(split(".") | map(tonumber)))
| sort_by(split(".") | map(tonumber))
| reverse
| .[0:4]
| .[]' > r-versions-to-build.txt
# To pin specific versions for testing, overwrite the file, e.g.:
# - printf '4.1.3\n' > r-versions-to-build.txt
- cat r-versions-to-build.txt
backend_options: backend_options:
kubernetes: kubernetes:
resources: resources:
@ -136,19 +147,23 @@ steps:
kubernetes.io/arch: "${ARCH}" kubernetes.io/arch: "${ARCH}"
- name: Check if files for R version already exist in s3 - name: Check which R versions already exist in s3
image: reg.devxy.io/docker.io/library/alpine:3.23 image: reg.devxy.io/docker.io/library/alpine:3.23
privileged: true privileged: true
commands: commands:
- ip link set dev eth0 mtu 1280 2>/dev/null || true - ip link set dev eth0 mtu 1280 2>/dev/null || true
- for i in 1 2 3 4 5; do apk add -q --no-cache curl && break; sleep 5; done - for i in 1 2 3 4 5; do apk add -q --no-cache curl && break; sleep 5; done
- | - |
VERSION=$(cat r-version-to-build.txt) LISTING=$(curl -s "https://s3.eu-central-003.backblazeb2.com/devxy-r-builds?prefix=${PLATFORM_ID}/" | \
curl -s "https://s3.eu-central-003.backblazeb2.com/devxy-r-builds?prefix=${PLATFORM_ID}/" | \ grep -oE '<Key>[^<]+</Key>' | sed 's/<[^>]*>//g')
grep -oE '<Key>[^<]+</Key>' | sed 's/<[^>]*>//g' | \ : > r-versions-existing.txt
awk -v arch="${ARCH_ID}" -v ver="${VERSION}" \ for VERSION in $(cat r-versions-to-build.txt); do
'$0 ~ arch && $0 ~ ver {print substr($NF, 3, 5)}' > r-version-s3.txt if printf '%s\n' "$LISTING" | \
- cat r-version-s3.txt awk -v arch="${ARCH_ID}" -v ver="$VERSION" 'index($0, arch) && index($0, ver) { found=1 } END { exit !found }'; then
echo "$VERSION" >> r-versions-existing.txt
fi
done
- echo "Already present in s3:"; cat r-versions-existing.txt
backend_options: backend_options:
kubernetes: kubernetes:
nodeSelector: nodeSelector:
@ -164,9 +179,20 @@ steps:
commands: | commands: |
ip link set dev eth0 mtu 1280 2>/dev/null || true ip link set dev eth0 mtu 1280 2>/dev/null || true
# docker info # docker info
if ! grep -qF "$(cat r-version-to-build.txt)" r-version-s3.txt; then TO_BUILD=""
for VERSION in $(cat r-versions-to-build.txt); do
if grep -qxF "$VERSION" r-versions-existing.txt; then
echo "R $VERSION already exists for ${PLATFORM} (${ARCH_ID}), skipping"
else
TO_BUILD="$TO_BUILD $VERSION"
fi
done
if [ -n "$TO_BUILD" ]; then
for i in 1 2 3 4 5; do apk add -q --no-cache make just docker-compose && break; sleep 5; done for i in 1 2 3 4 5; do apk add -q --no-cache make just docker-compose && break; sleep 5; done
just build-r-${PLATFORM} $(cat r-version-to-build.txt) for VERSION in $TO_BUILD; do
echo "Building R $VERSION for ${PLATFORM}"
just build-r-${PLATFORM} "$VERSION"
done
fi fi
backend_options: backend_options:
kubernetes: kubernetes: