Unverified Commit 69779e6a authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] build CRAN R-package on Azure with every commit and attach it to releases (#4117)

* build CRAN R-package on Azure with every commit and attach to releases

* test CI

* fix path

* revert CI test
parent fe1b80a5
name: R artifact builds
on:
repository_dispatch:
types: [gha_run_build_r_artifacts]
jobs:
cran-package:
name: cran-package
timeout-minutes: 60
runs-on: ubuntu-latest
container: rocker/r-base
env:
SECRETS_WORKFLOW: ${{ secrets.WORKFLOW }}
steps:
- name: Install essential software before checkout
shell: bash
run: |
apt-get update
apt-get install --no-install-recommends -y \
curl \
git \
jq
- name: Checkout repository
uses: actions/checkout@v2.3.4
with:
fetch-depth: 5
submodules: true
repository: microsoft/LightGBM
ref: "refs/pull/${{ github.event.client_payload.pr_number }}/merge"
- name: Send init status
if: ${{ always() }}
run: |
$GITHUB_WORKSPACE/.ci/append_comment.sh \
"${{ github.event.client_payload.comment_number }}" \
"Workflow **${{ github.workflow }}** has been triggered! 🚀\r\n${GITHUB_SERVER_URL}/microsoft/LightGBM/actions/runs/${GITHUB_RUN_ID}"
- 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 }}
- name: Send final status
if: ${{ always() }}
run: |
$GITHUB_WORKSPACE/.ci/append_comment.sh \
"${{ github.event.client_payload.comment_number }}" \
"Status: ${{ job.status }}."
...@@ -25,14 +25,6 @@ jobs: ...@@ -25,14 +25,6 @@ jobs:
"${{ github.event.comment.id }}" \ "${{ github.event.comment.id }}" \
"gha_run_r_valgrind" "gha_run_r_valgrind"
- name: Trigger R artifact builds
if: github.event.comment.body == '/gha run build-r-artifacts'
run: |
$GITHUB_WORKSPACE/.ci/trigger_dispatch_run.sh \
"${{ github.event.issue.pull_request.url }}" \
"${{ github.event.comment.id }}" \
"gha_run_build_r_artifacts"
- name: Trigger R Solaris CRAN checks - name: Trigger R Solaris CRAN checks
if: github.event.comment.body == '/gha run r-solaris' if: github.event.comment.body == '/gha run r-solaris'
run: | run: |
......
...@@ -18,6 +18,8 @@ resources: ...@@ -18,6 +18,8 @@ resources:
- container: ubuntu-latest - container: ubuntu-latest
image: 'ubuntu:latest' image: 'ubuntu:latest'
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro" options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
- container: rbase
image: rocker/r-base
jobs: jobs:
########################################### ###########################################
- job: Linux - job: Linux
...@@ -200,7 +202,7 @@ jobs: ...@@ -200,7 +202,7 @@ jobs:
artifactName: PackageAssets artifactName: PackageAssets
artifactType: container artifactType: container
########################################### ###########################################
- job: MacOS - job: macOS
########################################### ###########################################
variables: variables:
COMPILER: clang COMPILER: clang
...@@ -274,6 +276,25 @@ jobs: ...@@ -274,6 +276,25 @@ jobs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)' pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: PackageAssets artifactName: PackageAssets
artifactType: container artifactType: container
###########################################
- job: R_artifact
###########################################
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
pool:
vmImage: 'ubuntu-latest'
container: rbase
steps:
- script: |
LGB_VER=$(head -n 1 VERSION.txt | sed "s/rc/-/g")
sh build-cran-package.sh || exit -1
mv lightgbm_${LGB_VER}.tar.gz $(Build.ArtifactStagingDirectory)/lightgbm-${LGB_VER}-r-cran.tar.gz
displayName: 'Build CRAN R-package'
- task: PublishBuildArtifacts@1
condition: succeeded()
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: R-package
artifactType: container
########################################### ###########################################
- job: Package - job: Package
...@@ -282,8 +303,9 @@ jobs: ...@@ -282,8 +303,9 @@ jobs:
- Linux - Linux
- Linux_latest - Linux_latest
- QEMU_multiarch - QEMU_multiarch
- MacOS - macOS
- Windows - Windows
- R_artifact
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
...@@ -314,6 +336,12 @@ jobs: ...@@ -314,6 +336,12 @@ jobs:
inputs: inputs:
artifactName: PackageAssets artifactName: PackageAssets
downloadPath: $(Build.SourcesDirectory)/binaries downloadPath: $(Build.SourcesDirectory)/binaries
- task: DownloadBuildArtifacts@0
displayName: Download R-package
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
inputs:
artifactName: R-package
downloadPath: $(Build.SourcesDirectory)/R
- script: | - script: |
python "$(Build.SourcesDirectory)/.nuget/create_nuget.py" "$(Build.SourcesDirectory)/binaries/PackageAssets" python "$(Build.SourcesDirectory)/.nuget/create_nuget.py" "$(Build.SourcesDirectory)/binaries/PackageAssets"
displayName: 'Create NuGet configuration files' displayName: 'Create NuGet configuration files'
...@@ -339,6 +367,7 @@ jobs: ...@@ -339,6 +367,7 @@ jobs:
title: '$(Build.SourceBranchName)' title: '$(Build.SourceBranchName)'
assets: | assets: |
$(Build.SourcesDirectory)/binaries/PackageAssets/* $(Build.SourcesDirectory)/binaries/PackageAssets/*
$(Build.SourcesDirectory)/R/R-package/*
$(Build.ArtifactStagingDirectory)/nuget/*.nupkg $(Build.ArtifactStagingDirectory)/nuget/*.nupkg
$(Build.ArtifactStagingDirectory)/archives/* $(Build.ArtifactStagingDirectory)/archives/*
assetUploadMode: 'delete' assetUploadMode: 'delete'
......
...@@ -266,11 +266,7 @@ sh build-cran-package.sh ...@@ -266,11 +266,7 @@ sh build-cran-package.sh
This will create a file `lightgbm_${VERSION}.tar.gz`, where `VERSION` is the version of `LightGBM`. 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, create a comment with this phrase: Also, CRAN package is generated with every commit to any repo's branch and can be found in "Artifacts" section of the associated Azure Pipelines run.
> /gha run 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 ### Standard Installation from CRAN Package
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment