From 69779e6a6ba7b2f66347b497f06f3cb3d186d4a4 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Sat, 27 Mar 2021 19:47:33 +0300 Subject: [PATCH] [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 --- .github/workflows/r_artifacts.yml | 57 ----------------------- .github/workflows/triggering_comments.yml | 8 ---- .vsts-ci.yml | 33 ++++++++++++- R-package/README.md | 6 +-- 4 files changed, 32 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/r_artifacts.yml diff --git a/.github/workflows/r_artifacts.yml b/.github/workflows/r_artifacts.yml deleted file mode 100644 index d69a1f4d2656..000000000000 --- a/.github/workflows/r_artifacts.yml +++ /dev/null @@ -1,57 +0,0 @@ -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 }}." diff --git a/.github/workflows/triggering_comments.yml b/.github/workflows/triggering_comments.yml index 6803bf59fbc7..44cad11c1539 100644 --- a/.github/workflows/triggering_comments.yml +++ b/.github/workflows/triggering_comments.yml @@ -25,14 +25,6 @@ jobs: "${{ github.event.comment.id }}" \ "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 if: github.event.comment.body == '/gha run r-solaris' run: | diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 5a7472511020..9991de15e9c7 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -18,6 +18,8 @@ resources: - container: ubuntu-latest image: 'ubuntu:latest' options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro" + - container: rbase + image: rocker/r-base jobs: ########################################### - job: Linux @@ -200,7 +202,7 @@ jobs: artifactName: PackageAssets artifactType: container ########################################### -- job: MacOS +- job: macOS ########################################### variables: COMPILER: clang @@ -274,6 +276,25 @@ jobs: pathtoPublish: '$(Build.ArtifactStagingDirectory)' artifactName: PackageAssets 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 @@ -282,8 +303,9 @@ jobs: - Linux - Linux_latest - QEMU_multiarch - - MacOS + - macOS - Windows + - R_artifact condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) pool: vmImage: 'ubuntu-latest' @@ -314,6 +336,12 @@ jobs: inputs: artifactName: PackageAssets 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: | python "$(Build.SourcesDirectory)/.nuget/create_nuget.py" "$(Build.SourcesDirectory)/binaries/PackageAssets" displayName: 'Create NuGet configuration files' @@ -339,6 +367,7 @@ jobs: title: '$(Build.SourceBranchName)' assets: | $(Build.SourcesDirectory)/binaries/PackageAssets/* + $(Build.SourcesDirectory)/R/R-package/* $(Build.ArtifactStagingDirectory)/nuget/*.nupkg $(Build.ArtifactStagingDirectory)/archives/* assetUploadMode: 'delete' diff --git a/R-package/README.md b/R-package/README.md index 3dbe706a44ac..0d8f7d98e81a 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -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`. -Alternatively, GitHub Actions can generate this file for you. On a pull request, create a comment with this phrase: - -> /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. +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. ### Standard Installation from CRAN Package