Skip to content

Commit

Permalink
feat: add r-hub workflow (#232)
Browse files Browse the repository at this point in the history
insightsengineering/idr-tasks#781

---------

Signed-off-by: walkowif <[email protected]>
Co-authored-by: cicdguy <[email protected]>
Co-authored-by: Pawel Rucki <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent abf5405 commit 3d8f753
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# This workflow is based on R-hub's generic GitHub Actions workflow file.
# Its canonical location is at
# https://github.com/r-hub/actions/blob/main/workflows/rhub.yaml

name: R-hub 🌐

on:
workflow_call:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
# These platforms correspond roughly to CRAN package checks.
# More information: https://github.com/insightsengineering/idr-tasks/issues/781
# All supported R-hub platforms can be viewed by running: rhub::rhub_platforms()
# Container-based platforms (as opposed to VM-based Windows and macOS platforms)
# can be also viewed here: https://r-hub.github.io/containers/containers.html
# gcc14 = r-devel-linux-x86_64-fedora-gcc
default: >-
r-devel-linux-x86_64-debian-clang,
r-devel-linux-x86_64-debian-gcc,
gcc14,
r-devel-windows-x86_64,
r-patched-linux-x86_64,
r-release-linux-x86_64,
r-release-macos-arm64,
r-release-macos-x86_64,
r-release-windows-x86_64,
r-oldrel-macos-arm64,
r-oldrel-macos-x86_64,
r-oldrel-windows-x86_64,
linux,
gcc13,
noSuggests,
donttest
lookup-refs:
description: |
List of package references to be used for the feature branch.
Multiple entries in new lines or separated by commas.
required: false
default: ""
type: string

concurrency:
group: r-hub-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
- uses: r-hub/actions/setup@v1
with:
config: ${{ inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1

- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

- name: Prepare DESCRIPTION file
uses: insightsengineering/setup-r-dependencies@main
with:
lookup-refs: ${{ inputs.lookup-refs }}
skip-install: true

- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
needs: DepsDev,DepsBranch

- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1

- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}

- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

- name: Setup R dependencies
uses: insightsengineering/setup-r-dependencies@main
with:
lookup-refs: ${{ inputs.lookup-refs }}
skip-install: true

- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
needs: DepsDev,DepsBranch

- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
Binary file added images/rhub-workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,9 @@ jobs:
needs: release
uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main
```

## [`rhub.yaml`](./.github/workflows/rhub.yaml)

This is a workflow based on the [official R-hub workflow](https://github.com/r-hub/actions/blob/main/workflows/rhub.yaml) with the main goal being to `R CMD check` the package on different environments corresponding to the CRAN checks.

<img src="images/rhub-workflow.png" width="60%">

0 comments on commit 3d8f753

Please sign in to comment.