Skip to content

Replace BLAS/LAPACK with OpenBLAS, add APK install docs #171

Replace BLAS/LAPACK with OpenBLAS, add APK install docs

Replace BLAS/LAPACK with OpenBLAS, add APK install docs #171

Workflow file for this run

name: R builds
on:
push:
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.
Use "all-patch" to use all patch versions since R 3.1.
Defaults to "last-5,3.6.3,devel".
required: false
default: 'last-5,3.6.3,devel'
type: string
arch:
description: |
Comma-separated list of architectures. Specify "amd64", "arm64", or both.
Defaults to "amd64,arm64".
required: false
default: 'amd64,arm64'
type: choice
options:
- 'amd64,arm64'
- 'amd64'
- 'arm64'
publish:
description: |
Publish the builds to S3 staging or production? Defaults to not publishing.
required: false
default: ''
type: choice
options:
- ''
- staging
- production
workflow_call:
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,3.6.3,devel".
required: false
default: 'last-5,3.6.3,devel'
type: string
arch:
description: |
Comma-separated list of architectures. Specify "amd64", "arm64", or both.
Defaults to "amd64,arm64".
required: false
default: 'amd64,arm64'
type: string
publish:
description: |
Publish the builds to S3 staging or production? Allowed values are "staging", "production", or empty (default).
required: false
default: ''
type: string
secrets:
AWS_PUBLISH_ROLE:
required: true
AWS_REGION:
required: true
S3_BUCKET_STAGING:
required: true
S3_BUCKET_PRODUCTION:
required: true
permissions:
id-token: write
contents: read
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
platforms: ${{ steps.setup-matrix.outputs.platforms }}
r_versions: ${{ steps.setup-matrix.outputs.r_versions }}
arch: ${{ steps.setup-matrix.outputs.arch }}
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Set up matrix of platforms and R versions
id: setup-matrix
run: |
# Validate the R versions
r_versions=$(python manage_r_versions.py get "${{ inputs.r_versions }}")
# Filter out unsupported build combinations
build_matrix=$(python get_matrix.py --platforms="${{ inputs.platforms }}" --versions="$r_versions" --arch="${{ inputs.arch }}")
matrix=$(echo "$build_matrix" | jq -c '.matrix')
platforms=$(echo "$build_matrix" | jq -c '.platforms')
r_versions=$(echo "$build_matrix" | jq -c '.r_versions')
arch=$(echo "$build_matrix" | jq -c '.arch')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
echo "Using matrix: $matrix"
echo "platforms=$platforms" >> $GITHUB_OUTPUT
echo "Using platforms: $platforms"
echo "r_versions=$r_versions" >> $GITHUB_OUTPUT
echo "Using R versions: $r_versions"
echo "arch=$arch" >> $GITHUB_OUTPUT
echo "Using architectures: $arch"
unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install pytest
run: pip install pytest
- name: Run unit tests
run: python -m pytest builder/portable-r/test_delocate_r.py -v
docker-images:
needs: setup-matrix
strategy:
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
arch: ${{ fromJson(needs.setup-matrix.outputs.arch) }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
name: Docker image (${{ matrix.platform }}-${{ matrix.arch }})
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
# 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 }}-${{ matrix.arch }}-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-${{ matrix.arch }}-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 }} \
--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: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
name: ${{ matrix.platform }}-${{ matrix.arch }} (R ${{ matrix.r_version }})
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Restore cached Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ matrix.platform }}-${{ matrix.arch }}-buildx-${{ github.sha }}
restore-keys: ${{ matrix.platform }}-${{ matrix.arch }}-buildx-
- name: Load cached Docker image
run: |
docker buildx build -t r-builds:${{ matrix.platform }} \
--file builder/Dockerfile.${{ matrix.platform }} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--load \
builder
- name: Build R
run: |
R_VERSION=${{ matrix.r_version }} make build-r-${{ matrix.platform }}
- name: Test R
run: |
R_VERSION=${{ matrix.r_version }} make test-r-${{ matrix.platform }}
- name: Configure AWS Credentials
if: ${{ inputs.publish != '' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_PUBLISH_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Publish R
if: ${{ inputs.publish != '' }}
run: |
echo "Publishing R for ${{ inputs.publish }}"
s3_bucket=${{ inputs.publish == 'staging' && secrets.S3_BUCKET_STAGING || secrets.S3_BUCKET_PRODUCTION }}
S3_BUCKET=$s3_bucket make publish-r-${{ matrix.platform }}
update-versions-json:
if: ${{ inputs.publish != '' }}
needs: [build, setup-matrix]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_PUBLISH_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Update versions.json
run: |
echo "Publishing versions.json for ${{ inputs.publish }}"
s3_bucket=${{ inputs.publish == 'staging' && secrets.S3_BUCKET_STAGING || secrets.S3_BUCKET_PRODUCTION }}
versions=$(echo '${{ needs.setup-matrix.outputs.r_versions }}' | jq -r 'join(",")')
python manage_r_versions.py publish --s3-bucket="$s3_bucket" --versions="$versions"