diff --git a/.appveyor.yml b/.appveyor.yml index 75ce5c83..b1683c96 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -54,7 +54,7 @@ test_script: Get-ChildItem env: | Export-CliXml ./env-vars.clixml } else {pytest tests/ -v} - - IF "%TASK%" == "R_PACKAGE" powershell.exe -ExecutionPolicy Bypass -File .\R-package\.R.appveyor.ps1 + - IF "%TASK%" == "R_PACKAGE" powershell.exe -ExecutionPolicy Bypass -File .\.ci\.R.appveyor.ps1 after_test: - ps: >- diff --git a/R-package/.R.appveyor.ps1 b/.ci/.R.appveyor.ps1 similarity index 94% rename from R-package/.R.appveyor.ps1 rename to .ci/.R.appveyor.ps1 index 3d94932c..94470c1a 100644 --- a/R-package/.R.appveyor.ps1 +++ b/.ci/.R.appveyor.ps1 @@ -28,8 +28,8 @@ if (!(Get-Command R.exe -errorAction SilentlyContinue)) { appveyor DownloadFile https://miktex.org/download/win/miktexsetup-x64.zip -FileName ./miktexsetup-x64.zip Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("miktexsetup-x64.zip", "miktex") - .\miktex\miktexsetup.exe --local-package-repository=.\miktex\download --package-set=essential --quiet download - .\miktex\download\miktexsetup.exe --portable="$env:R_LIB_PATH\miktex" --quiet install + .\miktex\miktexsetup_standalone.exe --local-package-repository=.\miktex\download --package-set=essential --quiet download + .\miktex\download\miktexsetup_standalone.exe --portable="$env:R_LIB_PATH\miktex" --quiet install } initexmf --set-config-value [MPM]AutoInstall=1 diff --git a/.ci/python_tests.sh b/.ci/python_tests.sh new file mode 100755 index 00000000..0168971e --- /dev/null +++ b/.ci/python_tests.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +if [[ $OS_NAME == "macos-latest" ]]; then + brew install gcc + curl -sL https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh +else + apt-get update + apt-get install --no-install-recommends -y \ + apt-transport-https \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + gnupg-agent \ + software-properties-common + if [[ $TASK != "R_PACKAGE" ]]; then + add-apt-repository -y ppa:ubuntu-toolchain-r/test + apt-get update + apt-get install --no-install-recommends -y g++-5 + export CXX=g++-5 && export CC=gcc-5 + fi + curl -sL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh +fi +bash miniconda.sh -b -p $CONDA_PATH +conda config --set always_yes yes --set changeps1 no +conda update -q conda +if [[ $TASK == "R_PACKAGE" ]]; then + conda create -q -n $CONDA_ENV python=$PYTHON_VERSION pip openssl libffi --no-deps + source activate $CONDA_ENV + pip install setuptools joblib numpy "scikit-learn<0.24" scipy pandas wheel +else + conda create -q -n $CONDA_ENV python=$PYTHON_VERSION joblib numpy "scikit-learn<0.24" scipy pandas pytest + source activate $CONDA_ENV +fi +cd $GITHUB_WORKSPACE/python-package +python setup.py sdist --formats gztar || exit -1 +pip install dist/rgf_python-$RGF_VER.tar.gz -v || exit -1 +if [[ $TASK != "R_PACKAGE" ]]; then + pytest tests/ -v || exit -1 +fi diff --git a/.ci/r_tests.sh b/.ci/r_tests.sh new file mode 100755 index 00000000..45240550 --- /dev/null +++ b/.ci/r_tests.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +source activate $CONDA_ENV + +cd $GITHUB_WORKSPACE/R-package +if [[ $OS_NAME == "macos-latest" ]]; then + brew install r qpdf pandoc + brew install --cask basictex + export PATH="/Library/TeX/texbin:$PATH" + sudo tlmgr --verify-repo=none update --self + sudo tlmgr --verify-repo=none install inconsolata helvetic + + echo 'options(pkgType = "mac.binary")' > .Rprofile + echo 'options(install.packages.check.source = "no")' >> .Rprofile +else + tlmgr --verify-repo=none install ec +fi + +R_LIB_PATH=$HOME/R +mkdir -p $R_LIB_PATH +echo "R_LIBS=$R_LIB_PATH" > .Renviron + +if [[ $OS_NAME == "macos-latest" ]]; then + Rscript -e "install.packages('devtools', dependencies = TRUE, repos = 'https://cran.r-project.org')" +fi +Rscript -e 'devtools::install_deps(pkg = ".", dependencies = TRUE)' + +R CMD build . || exit -1 + +PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1) +PKG_NAME="${PKG_FILE_NAME%%_*}" +LOG_FILE_NAME="$PKG_NAME.Rcheck/00check.log" +COVERAGE_FILE_NAME="$PKG_NAME.Rcheck/coverage.log" + +R CMD check "${PKG_FILE_NAME}" --as-cran || exit -1 +if grep -q -E "WARNING|ERROR" "$LOG_FILE_NAME"; then + echo "WARNINGs or ERRORs have been found by R CMD check" + exit -1 +fi + +Rscript -e 'covr::codecov(quiet = FALSE)' 2>&1 | tee "$COVERAGE_FILE_NAME" +if [[ "$(grep -R "RGF Coverage:" $COVERAGE_FILE_NAME | rev | cut -d" " -f1 | rev | cut -d"." -f1)" -le 50 ]]; then + echo "Code coverage is extremely small!" + exit -1 +fi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..a7501a7e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,98 @@ +name: Python and R tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + name: ${{ matrix.task == 'R_PACKAGE' && format('R {0}', matrix.os) || format('Python {0} ({1})', matrix.python_version, matrix.os) }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + container: ubuntu:trusty + python_version: 3.6 + - os: macos-latest + python_version: 3.6 + - os: ubuntu-latest + container: ubuntu:trusty + python_version: 3.7 + - os: macos-latest + python_version: 3.7 + - os: ubuntu-latest + container: ubuntu:trusty + python_version: 3.8 + - os: macos-latest + python_version: 3.8 + - os: ubuntu-latest + container: rocker/verse:latest + python_version: 3.8 + task: R_PACKAGE + - os: macos-latest + python_version: 3.8 + task: R_PACKAGE + container: ${{ matrix.container }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 5 + - name: Setup and run tests + shell: bash + run: | + export OS_NAME="${{ matrix.os }}" + export PYTHON_VERSION="${{ matrix.python_version }}" + export CONDA_ENV=test-env + echo "CONDA_ENV=$CONDA_ENV" >> $GITHUB_ENV + export CONDA_PATH=$HOME/miniconda + echo "CONDA_PATH=$CONDA_PATH" >> $GITHUB_ENV + export PATH="$CONDA_PATH/bin:$PATH" + export TASK="${{ matrix.task }}" + if [[ $OS_NAME == "macos-latest" ]]; then + export CXX=g++-10 && export CC=gcc-10 + fi + export RGF_VER=$(head -n 1 $GITHUB_WORKSPACE/python-package/rgf/VERSION) + echo "RGF_VER=$RGF_VER" >> $GITHUB_ENV + $GITHUB_WORKSPACE/.ci/python_tests.sh || exit -1 + if [[ $TASK == "R_PACKAGE" ]]; then + $GITHUB_WORKSPACE/.ci/r_tests.sh || exit -1 + fi + - name: Create Wheel + if: matrix.python_version == 3.8 && matrix.task != 'R_PACKAGE' && github.ref == 'refs/heads/master' + shell: bash + run: | + export PATH="${{ env.CONDA_PATH }}/bin:$PATH" + source activate ${{ env.CONDA_ENV }} + cd $GITHUB_WORKSPACE/python-package + if [[ ${{ matrix.os }} == "macos-latest" ]]; then + python setup.py bdist_wheel --plat-name=macosx --python-tag py3; + mv dist/rgf_python-${{ env.RGF_VER }}-py3-none-macosx.whl dist/rgf_python-${{ env.RGF_VER }}-py3-none-macosx_10_14_x86_64.macosx_10_15_x86_64.macosx_11_0_x86_64.whl; + else + python setup.py bdist_wheel --plat-name=manylinux1_x86_64 --python-tag py3; + fi + - name: Create GitHub Release + if: matrix.python_version == 3.8 && matrix.task != 'R_PACKAGE' && github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RGF_VER }} + name: ${{ env.RGF_VER }} + draft: true + prerelease: false + files: ${{ github.workspace }}/python-package/dist/*.whl + 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] + steps: + - name: Note that all tests succeeded + run: echo "🎉" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 73096716..00000000 --- a/.travis.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Travis CI does not currently support Python on macOS -language: generic - -os: - - linux - - osx -dist: trusty -osx_image: xcode12 - -env: - global: - - R_LIB_PATH=~/Rlib - matrix: - - PYTHON_VERSION=2.7 - - PYTHON_VERSION=3.6 - - PYTHON_VERSION=3.7 - - PYTHON_VERSION=3.8 - - PYTHON_VERSION=3.8 TASK=R_PACKAGE - -before_install: - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then - brew install gcc; - export CXX=g++-10 && export CC=gcc-10; - curl https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION:0:1}-latest-MacOSX-x86_64.sh -o miniconda.sh; - else - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; - sudo apt-get update; - sudo apt-get install g++-5; - export CXX=g++-5 && export CC=gcc-5; - wget https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION:0:1}-latest-Linux-x86_64.sh -O miniconda.sh; - fi - - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - - if [[ $TASK == "R_PACKAGE" ]] && [[ $TRAVIS_OS_NAME == "linux" ]]; then - conda create -q -n test-environment python=$PYTHON_VERSION pip openssl libffi=3.2.1 --no-deps; - source activate test-environment; - pip install setuptools wheel joblib six numpy scipy pandas scikit-learn; - else - conda create -q -n test-environment python=$PYTHON_VERSION joblib six numpy scipy pandas scikit-learn pytest; - source activate test-environment; - fi - - - RGF_VER=$(head -n 1 python-package/rgf/VERSION) - -install: - - cd $TRAVIS_BUILD_DIR/python-package - - python setup.py sdist --formats gztar - - pip install dist/rgf_python-$RGF_VER.tar.gz -v - -script: - - if [[ $TASK == "R_PACKAGE" ]]; then - bash $TRAVIS_BUILD_DIR/R-package/.R.travis.sh; - else - pytest tests/ -v; - fi - -before_deploy: - - cd $TRAVIS_BUILD_DIR/python-package - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then - python setup.py bdist_wheel --plat-name=any --universal; - mv dist/rgf_python-${RGF_VER}-py2.py3-none-any.whl dist/rgf_python-${RGF_VER}-py2.py3-none-macosx_10_13_x86_64.macosx_10_14_x86_64.macosx_10_15_x86_64.whl; - else - python setup.py bdist_wheel --plat-name=manylinux1_x86_64 --universal; - python setup.py bdist_wheel --plat-name=manylinux1_i686 --universal; - cd $TRAVIS_BUILD_DIR/python-package/dist; - zip -d rgf_python-${RGF_VER}-py2.py3-none-manylinux1_i686.whl rgf/rgf rgf/forest_train rgf/forest_predict; - mkdir rgf; - wget https://github.com/RGF-team/rgf/releases/download/3.2.0/rgf -O rgf/rgf; - wget https://github.com/RGF-team/rgf/releases/download/3.2.0/forest_train -O rgf/forest_train; - wget https://github.com/RGF-team/rgf/releases/download/3.2.0/forest_predict -O rgf/forest_predict; - zip rgf_python-${RGF_VER}-py2.py3-none-manylinux1_i686.whl rgf/rgf rgf/forest_train rgf/forest_predict; - fi - - cd $TRAVIS_BUILD_DIR - -notifications: - email: false - -cache: - directories: - - $R_LIB_PATH - -deploy: - file_glob: true - file: python-package/dist/*.whl - skip_cleanup: true - draft: true - provider: releases - api-key: - secure: "WGMJ/0VoQ34g1m9k6RkxLOS796HRgK0M8JsVUSs2zW3miwmGGRvh5p8cn+IlOJD0uJyZQksueyN5aEVwUZ5tDuNHb21CDUDupxNjt74EqWAB1fc9Dp72sSWImIPY6PEA/f8OTwQKI00B9WfDJJMPOdlPN57gq7+DlJLsEtWxXssvs/l5JiBc4qO1CwA+y4460cpTrBgB3VnhAF6tju6H4dJtj8lWtXdnFc9gUF/3xTi1QliGrE4doQyLoNOAr4pzNgNjeUjkw9yVKUfa2XsQhyCcLZjBg4Z1t4P15nN/NRaQv/IaYu2WjbRIW1bVadfHUVmuf5F2oRLmR2KrWaJSYTd7wsr+6/Pd/ejZXoL5XJCjCFRxJKHbdL4zIUJa50Auqw6NAwoZSqrLatfsxEjXZaUhaGPg63f44GOA8RSB4X3txPwTXPwXCb8QSq51rfm2zPe6UEvfiVGlyylHtTwP+GKqy1Ml4q+0HPCjne1qufLtNhy+Ke6rD7KgODJi/XElmJwhF8pPCeDp+AmMYbd+Ppid0sISJFCv4IJmAl3FUJ5dtH/wGFUWMQDH8zsF1v94AFXmuO0zvaoOnKOC7P+j3/UXqOUopdC4z0YYqkjJU+OkWO/rnhHhFoWQjys3f1D1q/++yF7wwEu/DkUbxr/29YV2hfa5yH/gHusLmX01d1o=" - tag_name: $TRAVIS_TAG - on: - branch: master - condition: "$PYTHON_VERSION = 3.8 && $TASK != R_PACKAGE" - tags: true diff --git a/R-package/.R.travis.sh b/R-package/.R.travis.sh deleted file mode 100644 index 23274a52..00000000 --- a/R-package/.R.travis.sh +++ /dev/null @@ -1,69 +0,0 @@ -mkdir -p $R_LIB_PATH -cd $TRAVIS_BUILD_DIR/R-package -echo "R_LIBS=$R_LIB_PATH" > .Renviron -echo 'options(repos = "https://cran.rstudio.com")' > .Rprofile -if [[ $TRAVIS_OS_NAME == "osx" ]]; then - echo 'options(pkgType = "mac.binary")' >> .Rprofile -fi -echo 'options(install.packages.check.source = "no")' >> .Rprofile - -export PATH="$R_LIB_PATH/R/bin:$PATH" - -if [[ $TRAVIS_OS_NAME == "linux" ]]; then - sudo apt-get install gfortran-5 libcurl4-openssl-dev - sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-5 10 - - sudo apt-get install texlive-latex-recommended texlive-fonts-recommended texlive-fonts-extra qpdf - - if ! command -v R &> /dev/null; then - R_VER=3.6.2 - cd $TRAVIS_BUILD_DIR - wget https://cran.r-project.org/src/base/R-3/R-$R_VER.tar.gz - tar -xzf R-$R_VER.tar.gz - R-$R_VER/configure --enable-R-shlib --prefix=$R_LIB_PATH/R - make - make install - cd $TRAVIS_BUILD_DIR/R-package - fi -else - brew install r qpdf - brew cask install basictex - export PATH="/Library/TeX/texbin:$PATH" - sudo tlmgr update --self - sudo tlmgr install inconsolata helvetic -fi - -conda install -y --no-deps pandoc - -Rscript -e 'if(!"devtools" %in% rownames(installed.packages())) { install.packages("devtools", dependencies = TRUE) }' -Rscript -e 'if(!"roxygen2" %in% rownames(installed.packages())) { install.packages("roxygen2", dependencies = TRUE) }' -Rscript -e 'if(!"testthat" %in% rownames(installed.packages())) { install.packages("testthat", dependencies = TRUE) }' -Rscript -e 'if(!"knitr" %in% rownames(installed.packages())) { install.packages("knitr", dependencies = TRUE) }' -Rscript -e 'if(!"covr" %in% rownames(installed.packages())) { install.packages("covr", dependencies = TRUE) }' -Rscript -e 'if(!"rmarkdown" %in% rownames(installed.packages())) { install.packages("rmarkdown", dependencies = TRUE) }' -Rscript -e 'if(!"reticulate" %in% rownames(installed.packages())) { install.packages("reticulate", dependencies = TRUE) }' -Rscript -e 'if(!"R6" %in% rownames(installed.packages())) { install.packages("R6", dependencies = TRUE) }' -Rscript -e 'if(!"Matrix" %in% rownames(installed.packages())) { install.packages("Matrix", dependencies = TRUE) }' - -Rscript -e 'update.packages(ask = FALSE, instlib = Sys.getenv("R_LIB_PATH"))' - -Rscript -e 'devtools::install_deps(pkg = ".", dependencies = TRUE)' - -R CMD build . || exit -1 - -PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1) -PKG_NAME="${PKG_FILE_NAME%%_*}" -LOG_FILE_NAME="$PKG_NAME.Rcheck/00check.log" -COVERAGE_FILE_NAME="$PKG_NAME.Rcheck/coverage.log" - -R CMD check "${PKG_FILE_NAME}" --as-cran || exit -1 -if grep -q -R "WARNING" "$LOG_FILE_NAME"; then - echo "WARNINGS have been found in the build log!" - exit -1 -fi - -Rscript -e 'covr::codecov(quiet = FALSE)' 2>&1 | tee "$COVERAGE_FILE_NAME" -if [[ "$(grep -R "RGF Coverage:" $COVERAGE_FILE_NAME | rev | cut -d" " -f1 | rev | cut -d"." -f1)" -le 50 ]]; then - echo "Code coverage is extremely small!" - exit -1 -fi