forked from chainguard-dev/melange
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request chainguard-dev#1111 from chainguard-dev/R
feat: Add build pipeline for R packages
- Loading branch information
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Built-in R pipeline | ||
|
||
Melange includes a built-in pipeline to compile R packages. | ||
|
||
To get started quickly, checkout the `R/build` pipeline: | ||
[cran-build.yaml](https://github.com/chainguard-dev/melange/blob/main/examples/R-build.yaml) | ||
|
||
## Building R packages with `R/build` | ||
|
||
The `R/build` pipeline is a declarative interface that leverages the R package | ||
manager. This pipeline builds an R package from source and installs it to the | ||
standard R library directory. | ||
|
||
Here's a sample melange configuration file cloning and running the same | ||
sample project as above: | ||
|
||
```yaml | ||
package: | ||
name: cran-proxy | ||
version: 0.4_27 | ||
epoch: 0 | ||
description: Distance and similarity measures | ||
copyright: | ||
- license: GPL-2.0-or-later | ||
|
||
environment: | ||
contents: | ||
packages: | ||
- R | ||
- R-dev | ||
- busybox | ||
|
||
var-transforms: | ||
- from: ${{package.version}} | ||
match: '_' | ||
replace: '-' | ||
to: mangled-package-version | ||
|
||
pipeline: | ||
- uses: git-checkout | ||
with: | ||
repository: https://github.com/cran/proxy | ||
tag: ${{vars.mangled-package-version}} | ||
expected-commit: 311a8569a534460ef04473ffa442dc7b72ba9a41 | ||
|
||
- uses: R/build | ||
with: | ||
package: proxy | ||
version: ${{vars.mangled-package-version}} | ||
|
||
- uses: strip | ||
|
||
update: | ||
enabled: true | ||
version-transform: | ||
- match: '_' | ||
replace: '-' | ||
github: | ||
identifier: cran/proxy | ||
use-tag: true | ||
``` | ||
|
||
(:bulb: Experiment with this code, | ||
[download it from the examples directory](https://github.com/chainguard-dev/melange/blob/main/examples/R-build.yaml)) | ||
|
||
## Build Parameters | ||
|
||
The `R/build` pipeline supports passing a few parameters the R package manager by | ||
setting them in the melange configuration file. As of this writing, you can define | ||
the following values: | ||
|
||
```yaml | ||
package: | ||
description: | | ||
The R package to install | ||
required: true | ||
|
||
path: | ||
description: | | ||
Path to R package source or source tarball | ||
default: "." | ||
|
||
version: | ||
description: | | ||
The R package version | ||
required: true | ||
``` | ||
|
||
For the most up to date supported features check the | ||
[build](https://github.com/chainguard-dev/melange/blob/main/pkg/build/pipelines/R/build.yaml) | ||
pipeline. | ||
|
||
Feel free to request more features in the built-in pipelines by | ||
[filing a new issue](https://github.com/chainguard-dev/melange/issues/new) in | ||
the melange repository! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-FileCopyrightText: 2024 Chainguard, Inc | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This is a sample configuration file to demonstrate how to build a software | ||
# project using melange's built-in R/build pipeline. | ||
# | ||
# For more information about melange's built-in rust support check out: | ||
# https://github.com/chainguard-dev/melange/blob/main/docs/PIPELINES-R.md | ||
package: | ||
name: cran-proxy | ||
version: 0.4_27 | ||
epoch: 0 | ||
description: Distance and similarity measures | ||
copyright: | ||
- license: GPL-2.0-or-later | ||
|
||
environment: | ||
contents: | ||
packages: | ||
- R | ||
- R-dev | ||
- busybox | ||
|
||
var-transforms: | ||
- from: ${{package.version}} | ||
match: '_' | ||
replace: '-' | ||
to: mangled-package-version | ||
|
||
pipeline: | ||
- uses: git-checkout | ||
with: | ||
repository: https://github.com/cran/proxy | ||
tag: ${{vars.mangled-package-version}} | ||
expected-commit: 311a8569a534460ef04473ffa442dc7b72ba9a41 | ||
|
||
- uses: R/build | ||
with: | ||
package: proxy | ||
version: ${{vars.mangled-package-version}} | ||
|
||
- uses: strip | ||
|
||
update: | ||
enabled: true | ||
version-transform: | ||
- match: '_' | ||
replace: '-' | ||
github: | ||
identifier: cran/proxy | ||
use-tag: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Run a build using the R package manager | ||
|
||
needs: | ||
packages: | ||
- R | ||
- R-dev | ||
- busybox | ||
|
||
inputs: | ||
package: | ||
description: | | ||
The R package to install | ||
required: true | ||
|
||
path: | ||
description: | | ||
Path to R package source or source tarball | ||
default: "." | ||
|
||
version: | ||
description: | | ||
The R package version | ||
required: true | ||
|
||
pipeline: | ||
- runs: | | ||
# Use default R library path | ||
mkdir -p /usr/lib/R/library | ||
mkdir -p ${{targets.contextdir}}/usr/lib/R/library | ||
# Build R package from source | ||
Rscript -e 'install.packages("${{inputs.path}}", repos = NULL, type = "source")' | ||
# Install package | ||
mv /usr/lib/R/library/${{inputs.package}} ${{targets.contextdir}}/usr/lib/R/library/ |