diff --git a/.ci/setup.sh b/.ci/setup.sh index 752158ff3952..79c2bdc85d54 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -48,7 +48,7 @@ else # Linux fi fi -if [[ "${TASK:0:9}" != "r-package" ]]; then +if [[ "${TASK}" != "r-package" ]]; then if [[ $SETUP_CONDA != "false" ]]; then sh conda.sh -b -p $CONDA fi diff --git a/.ci/test.sh b/.ci/test.sh index 63c6e4af6c05..0f1c99d7882b 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -8,7 +8,7 @@ elif [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "clang" ]]; then export CC=clang fi -if [[ "${TASK:0:9}" == "r-package" ]]; then +if [[ "${TASK}" == "r-package" ]]; then bash ${BUILD_DIRECTORY}/.ci/test_r_package.sh || exit -1 exit 0 fi diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index f59d4efe1acc..4ed9a448edfc 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -105,24 +105,6 @@ if [[ $OS_NAME == "macos" ]]; then fi Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 -if [[ $TASK == "r-package-check-docs" ]]; then - Rscript build_r.R || exit -1 - Rscript --vanilla -e "install.packages('roxygen2', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 - Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 - num_doc_files_changed=$( - git diff --name-only | grep --count -E "\.Rd|NAMESPACE" - ) - if [[ ${num_doc_files_changed} -gt 0 ]]; then - echo "Some R documentation files have changed. Please re-generate them and commit those changes." - echo "" - echo " Rscript build_r.R" - echo " Rscript -e \"roxygen2::roxygenize('R-package/', load = 'installed')\"" - echo "" - exit -1 - fi - exit 0 -fi - cd ${BUILD_DIRECTORY} PKG_TARBALL="lightgbm_*.tar.gz" diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index e0d5e92833ad..54b2798fa40a 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -1,4 +1,4 @@ -name: R GitHub Actions +name: R-package on: push: @@ -40,11 +40,6 @@ jobs: compiler: clang r_version: 4.0 build_type: cmake - - os: ubuntu-latest - task: r-package-check-docs - compiler: gcc - r_version: 4.0 - build_type: cmake - os: macOS-latest task: r-package compiler: gcc diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml new file mode 100644 index 000000000000..ed9790c8bb06 --- /dev/null +++ b/.github/workflows/static_analysis.yml @@ -0,0 +1,85 @@ +# contains non-functional tests, like checks on docs +# and code style +name: Static Analysis + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COMPILER: 'gcc' + CONDA_ENV: test-env + GITHUB_ACTIONS: 'true' + OS_NAME: 'linux' + PYTHON_VERSION: 3.8 + +jobs: + test: + name: ${{ matrix.task }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - task: lint + - task: check-docs + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 5 + submodules: false + - name: Setup and run tests + shell: bash + run: | + export TASK="${{ matrix.task }}" + export BUILD_DIRECTORY="$GITHUB_WORKSPACE" + export CONDA=${HOME}/miniconda + export PATH=${CONDA}/bin:$HOME/.local/bin:${PATH} + $GITHUB_WORKSPACE/.ci/setup.sh || exit -1 + $GITHUB_WORKSPACE/.ci/test.sh || exit -1 + r-check-docs: + name: r-package-check-docs + timeout-minutes: 60 + runs-on: ubuntu-latest + container: rocker/verse + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 5 + submodules: true + - name: Install packages + shell: bash + run: | + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'roxygen2', 'testthat'), repos = 'https://cran.r-project.org')" + sh build-cran-package.sh || exit -1 + R CMD INSTALL --with-keep.source lightgbm_*.tar.gz || exit -1 + - name: Test documentation + shell: bash --noprofile --norc {0} + run: | + Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 + num_doc_files_changed=$( + git diff --name-only | grep --count -E "\.Rd|NAMESPACE" + ) + if [[ ${num_doc_files_changed} -gt 0 ]]; then + echo "Some R documentation files have changed. Please re-generate them and commit those changes." + echo "" + echo " sh build-cran-package.sh" + echo " R CMD INSTALL --with-keep.source lightgbm_*.tar.gz" + echo " Rscript -e \"roxygen2::roxygenize('R-package/', load = 'installed')\"" + echo "" + exit -1 + fi + all-successful: + # https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert + runs-on: ubuntu-latest + needs: [test, r-check-docs] + steps: + - name: Note that all tests succeeded + run: echo "🎉" diff --git a/.travis.yml b/.travis.yml index 930cc4d0f19e..82e5de10c653 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,6 @@ env: - TASK=sdist - TASK=bdist - TASK=if-else - - TASK=lint - - TASK=check-docs - TASK=mpi METHOD=source - TASK=mpi METHOD=pip PYTHON_VERSION=3.7 - TASK=mpi METHOD=wheel PYTHON_VERSION=3.7 @@ -37,10 +35,6 @@ matrix: env: TASK=gpu METHOD=pip PYTHON_VERSION=3.6 - os: osx env: TASK=gpu METHOD=wheel PYTHON_VERSION=3.7 - - os: osx - env: TASK=lint - - os: osx - env: TASK=check-docs before_install: - test -n $CC && unset CC diff --git a/README.md b/README.md index 4637f4430169..293dd32e2215 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Light Gradient Boosting Machine =============================== -[![GitHub Actions Build Status](https://github.com/microsoft/LightGBM/workflows/R%20GitHub%20Actions/badge.svg?branch=master)](https://github.com/microsoft/LightGBM/actions) +[![R-package GitHub Actions Build Status](https://github.com/microsoft/LightGBM/workflows/R-package/badge.svg?branch=master)](https://github.com/microsoft/LightGBM/actions) +[![Static Analysis GitHub Actions Build Status](https://github.com/microsoft/LightGBM/workflows/Static%20Analysis/badge.svg?branch=master)](https://github.com/microsoft/LightGBM/actions) [![Azure Pipelines Build Status](https://lightgbm-ci.visualstudio.com/lightgbm-ci/_apis/build/status/Microsoft.LightGBM?branchName=master)](https://lightgbm-ci.visualstudio.com/lightgbm-ci/_build/latest?definitionId=1) [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/1ys5ot401m0fep6l/branch/master?svg=true)](https://ci.appveyor.com/project/guolinke/lightgbm/branch/master) [![Travis Build Status](https://travis-ci.org/microsoft/LightGBM.svg?branch=master)](https://travis-ci.org/microsoft/LightGBM)