Skip to content

Commit

Permalink
[ci] automate building CRAN package (#3497)
Browse files Browse the repository at this point in the history
* [ci] automate building CRAN package

* add workflow for building CRAN package

* remove newlines

* add to R README

* Apply suggestions from code review

Co-authored-by: Nikita Titov <[email protected]>

* add timeout

Co-authored-by: Nikita Titov <[email protected]>
  • Loading branch information
jameslamb and StrikerRUS authored Oct 30, 2020
1 parent 0ab9f97 commit 88a7344
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/r_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: R artifact builds

on:
pull_request_review_comment:
types: [created]

jobs:
cran-package:
name: cran-package
if: github.event.comment.body == '/gha build r-artifacts' && contains('OWNER,MEMBER,COLLABORATOR', github.event.comment.author_association)
timeout-minutes: 60
runs-on: ubuntu-latest
container: rocker/r-base
steps:
- name: Checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 5
submodules: true
- name: Build package
shell: bash
id: build_package
run: |
sh build-cran-package.sh || exit -1
LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g")
ARTIFACT_NAME=lightgbm-${LGB_VERSION}-r-cran.tar.gz
mv lightgbm_${LGB_VERSION}.tar.gz ${ARTIFACT_NAME}
echo "::set-output name=artifact_name::${ARTIFACT_NAME}"
echo "::set-output name=artifact_path::$(pwd)/${ARTIFACT_NAME}"
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_package.outputs.artifact_name }}
path: ${{ steps.build_package.outputs.artifact_path }}
8 changes: 7 additions & 1 deletion R-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ sh build-cran-package.sh

This will create a file `lightgbm_${VERSION}.tar.gz`, where `VERSION` is the version of `LightGBM`.

Alternatively, GitHub Actions can generate this file for you. On a pull request, go to the "Files changed" tab and create a comment with this phrase:

> /gha build r-artifacts
Go to https://github.com/microsoft/LightGBM/actions, and find the most recent run of the "R artifact builds" workflow. If it ran successfully, you'll find a download link for the package (in `.zip` format) in that run's "Artifacts" section.

### Standard Installation from CRAN Package

After building the package, install it with a command like the following:
Expand Down Expand Up @@ -461,7 +467,7 @@ RDvalgrind \
| cat
```

These tests can also be triggered on any pull request by leaving a "Comment" review with the following comment:
These tests can also be triggered on any pull request by leaving a review on the "Files changed" tab in a pull request:

> /gha run r-valgrind

Expand Down

0 comments on commit 88a7344

Please sign in to comment.