Skip to content

Add GHA workflow to publish, poll daily, and build devel/next #3

Add GHA workflow to publish, poll daily, and build devel/next

Add GHA workflow to publish, poll daily, and build devel/next #3

Workflow file for this run

name: R builds
on:
push:
paths:
- 'builder/**'
- 'test/**'
- 'Makefile'
- '.github/workflows/build.yml'
pull_request:
paths:
- 'builder/**'
- 'test/**'
- 'Makefile'
- '.github/workflows/build.yml'
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,3.6.3,devel".
required: false
default: 'last-5,3.6.3,devel'
type: string
publish:
description: |
Publish the builds to S3 staging or production? Defaults to not publishing.
required: false
default: ''
type: string
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
publish:
description: |
Publish the builds to S3 staging or production? Defaults to not publishing.
required: false
default: ''
type: string
options:

Check failure on line 64 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / R builds

Invalid workflow file

The workflow is not valid. .github/workflows/build.yml (Line: 64, Col: 9): Unexpected value 'options'
- ''
- staging
- production
secrets:
AWS_PUBLISH_ROLE:
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:
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 }})
echo "r_versions=$r_versions" >> $GITHUB_OUTPUT
docker-images:
needs: setup-matrix
strategy:
matrix:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
name: Docker image (${{ matrix.platform }})
steps:
- uses: actions/checkout@v3
- 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:
platform: ${{ fromJson(needs.setup-matrix.outputs.platforms) }}
r_version: ${{ fromJson(needs.setup-matrix.outputs.r_versions) }}
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
name: ${{ matrix.platform }}-${{ matrix.arch }} (R ${{ matrix.r_version }})
steps:
- uses: actions/checkout@v3
- 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: |
s3_bucket=${{ inputs.publish == 'staging' && secrets.S3_BUCKET_STAGING || secrets.S3_BUCKET_PRODUCTION }}
R_VERSION=${{ matrix.r_version }} S3_BUCKET=$s3_bucket make publish-r-${{ matrix.platform }}-${{ matrix.arch }}
- name: Update versions.json
if: ${{ inputs.publish == 'production' }}
run: |
# TODO: Update versions.json? make sure no race conditions, maybe only at end for productoin only
# TODO publish versions.json
# TODO publish to staging on main merges?