Skip to content

arm64 R builds

arm64 R builds #175

Workflow file for this run

name: arm64 R builds
on:
workflow_dispatch:
inputs:
platforms:
description: |
Comma-separated list of platforms. Specify "all" to use all platforms (the default).
required: false
default: 'all'
type: string
r_versions:
description: |
Comma-separated list of R versions. Specify "last-N" to use the
last N minor R versions, or "all" to use all minor R versions since R 3.1.
Defaults to "last-5".
required: false
default: 'next,devel'
type: string
schedule:
- cron: '55 2 * * *'
permissions:
contents: read
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
platforms: ${{ steps.setup-matrix.outputs.platforms }}
r_versions: ${{ steps.setup-matrix.outputs.r_versions }}
steps:
- uses: actions/checkout@v3
- name: Set up matrix of platforms and R versions
id: setup-matrix
run: |
platforms=$(python test/get_platforms.py ${{ github.event.inputs.platforms }})
echo "platforms=$platforms" >> $GITHUB_OUTPUT
r_versions=$(python test/get_r_versions.py ${{ github.event.inputs.r_versions || 'next,devel' }})
echo "r_versions=$r_versions" >> $GITHUB_OUTPUT
docker-images:
needs: setup-matrix
strategy:
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
runs-on: ubuntu-latest
name: Docker image (${{ matrix.platform }})
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
platforms: linux/arm64
# Enable Docker layer caching without having to push to a registry.
# https://docs.docker.com/build/ci/github-actions/examples/#local-cache
# This may eventually be migrated to the GitHub Actions cache backend,
# which is still considered experimental.
# https://github.com/moby/buildkit#github-actions-cache-experimental
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ matrix.platform }}-arm64-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-arm64-buildx-
# Use docker buildx instead of docker-compose here because cache exporting
# does not seem to work as of docker-compose v2.6.0 and buildx v0.8.2, even
# though it works with buildx individually.
- name: Build image
run: |
docker buildx build -t r-builds:${{ matrix.platform }} \
--platform linux/arm64 \
--file builder/Dockerfile.${{ matrix.platform }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new,mode=max" \
builder
# Temporary workaround for unbounded GHA cache growth with the local cache mode.
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build:
needs: [setup-matrix, docker-images]
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
r_version: ${{ fromJson(needs.setup-matrix.outputs.r_versions) }}
runs-on: ubuntu-latest
name: ${{ matrix.platform }} (R ${{ matrix.r_version }})
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
platforms: linux/arm64
- name: Restore cached Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ matrix.platform }}-arm64-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-arm64-buildx-
- name: Load cached Docker image
run: |
docker buildx build -t r-builds:${{ matrix.platform }} \
--platform linux/arm64 \
--file builder/Dockerfile.${{ matrix.platform }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--load \
builder
- name: Build R
run: |
cd builder && docker-compose up ${{ matrix.platform }}
env:
R_VERSION: ${{ matrix.r_version }}
DOCKER_DEFAULT_PLATFORM: linux/arm64
- name: Copy and rename package
run: |
pkg=$(find builder/integration -name "*.deb" -or -name "*.rpm")
pkg2=$(echo $pkg | sed "s|/[rR]-|/r-rstudio-${{ matrix.platform }}-|")
pkg2=$(basename "$pkg2")
cp "$pkg" "$pkg2"
ls -l .
- name: Release
uses: softprops/action-gh-release@v1
with:
repository: r-hub/R
token: ${{ secrets.DEPLOY_TOKEN }}
files: |
*-rstudio-*.deb
*-rstudio-*.rpm
name: "Latest builds"
tag_name: v${{ matrix.r_version }}