Develop #847
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| branches: | |
| - master | |
| - testing | |
| - develop | |
| pull_request: | |
| branches: | |
| - master | |
| - testing | |
| - develop | |
| name: R-CMD-check | |
| jobs: | |
| R-CMD-check: | |
| # 0. Define the systems to run on: | |
| runs-on: ${{ matrix.config.os }} | |
| name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| # Latest macOS will use the big-sur-arm64 folder when deploying to the drat repo: | |
| - {os: macOS-latest, r: 'release', pkgext: '.tgz'} | |
| - {os: macOS-latest, r: 'oldrel', pkgext: '.tgz'} | |
| # macos-15-intel will use the big-sur-x86_64 folder when deploying to the drat repo. This is the last intel-macOS supported by GitHub Actions: | |
| - {os: macos-15-intel, r: 'release', pkgext: '.tgz'} | |
| - {os: macos-15-intel, r: 'oldrel', pkgext: '.tgz'} | |
| - {os: windows-latest, r: 'release', pkgext: '.zip'} | |
| - {os: windows-latest, r: 'oldrel', pkgext: '.zip'} | |
| # ubuntu-latest is 24 as of 2024-10-31. Should we use it? | |
| - {os: ubuntu-22.04, r: 'release', pkgext: '.tar.gz', rspm: "https://cloud.r-project.org"} | |
| - {os: ubuntu-22.04, r: 'oldrel', pkgext: '.tar.gz', rspm: "https://cloud.r-project.org"} | |
| # - {os: ubuntu-22.04, r: 'oldrel-2', pkgext: '.tar.gz', rspm: "https://cloud.r-project.org"} # Skipping the oldrel-2, as we need equal requirements across platforms | |
| env: | |
| R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
| RSPM: ${{ matrix.config.rspm }} | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| ################### | |
| #### 1. Setup: #### | |
| ################### | |
| - uses: actions/checkout@v4 | |
| - name: Prepare for deployment at push | |
| if: github.event_name == 'push' | |
| run: | | |
| curl "https://raw.githubusercontent.com/StoXProject/unstableRepo/main/scripts/checktag-actions.sh" --output unstableRepo_checktag.sh | |
| curl "https://raw.githubusercontent.com/StoXProject/unstableRepo/main/scripts/deploy-actions.sh" --output unstableRepo_deploy.sh | |
| chmod +x ./unstableRepo_checktag.sh ./unstableRepo_deploy.sh | |
| . unstableRepo_checktag.sh | |
| curl "https://raw.githubusercontent.com/StoXProject/testingRepo/main/scripts/checktag-actions.sh" --output testingRepo_checktag.sh | |
| curl "https://raw.githubusercontent.com/StoXProject/testingRepo/main/scripts/deploy-actions.sh" --output testingRepo_deploy.sh | |
| chmod +x ./testingRepo_checktag.sh ./testingRepo_deploy.sh | |
| . testingRepo_checktag.sh | |
| curl "https://raw.githubusercontent.com/StoXProject/repo/master/scripts/checktag-actions.sh" --output repo_checktag.sh | |
| curl "https://raw.githubusercontent.com/StoXProject/repo/master/scripts/deploy-actions.sh" --output repo_deploy.sh | |
| chmod +x ./repo_checktag.sh ./repo_deploy.sh | |
| . repo_checktag.sh | |
| echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV | |
| echo "FINAL_TAG=${FINAL_TAG}" >> $GITHUB_ENV | |
| echo "PKG_FILE_PREFIX=${PKG_FILE_PREFIX}" >> $GITHUB_ENV | |
| echo "PKG_FILE=${PKG_FILE_PREFIX}${{ matrix.config.pkgext }}" >> $GITHUB_ENV | |
| echo "PKG_FREL=${PKG_FILE_PREFIX}-R.${{ matrix.config.r }}-${{ runner.os }}${{ matrix.config.pkgext }}" >> $GITHUB_ENV | |
| echo "PKG_REPO=${GITHUB_WORKSPACE}" >> $GITHUB_ENV | |
| shell: bash | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: ${{ matrix.config.r }} | |
| - uses: r-lib/actions/setup-pandoc@v2 | |
| ############################################################################# | |
| #### 2. R package installation (with system and R package dependencies): #### | |
| ############################################################################# | |
| ## 2a. System dependencies: | |
| - name: Install system dependencies on macOS | |
| if: runner.os == 'macOS' | |
| run: | | |
| # gfortran may not exist in a period after a new R minor release: | |
| gfortranFile='/usr/local/bin/gfortran' | |
| if [ -f "$gfortranFile" ] ; then | |
| rm "$gfortranFile" | |
| fi | |
| rm -f '/usr/local/bin/2to3' | |
| rm -f '/usr/local/bin/2to3-3.11' | |
| rm -f '/usr/local/bin/idle3' | |
| rm -f '/usr/local/bin/idle3.11' | |
| rm -f '/usr/local/bin/pydoc3' | |
| rm -f '/usr/local/bin/pydoc3.11' | |
| rm -f '/usr/local/bin/python3' | |
| rm -f '/usr/local/bin/python3.11' | |
| rm -f '/usr/local/bin/python3-config' | |
| rm -f '/usr/local/bin/python3.11-config' | |
| export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK= # This (the value should actually be empty...) prevents Homebrew from re-installing R, which will lead to .Platform$pkgType = "source". | |
| brew install gdal udunits | |
| shell: bash | |
| - name: Prepare for CRANdependencies on Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get install -y libcurl4-openssl-dev | |
| sudo apt-get install -y libudunits2-dev | |
| shell: bash | |
| ## 2b. R packages needed for this yaml script (not related to the Rstox package itself): | |
| - name: Install CRANdependencies | |
| run: | | |
| install.packages(c("rcmdcheck", "git2r", "sessioninfo", "knitr", "drat")) | |
| shell: Rscript {0} | |
| ## 2c. Rstox packages and dependencies (the complicated if condition is needed since the reference to branch name is not consistent across event names). There is the issue that R sorts packge versions alphabetically, while StoX uses semantic versioning. Consequently a pre-release such as 1.2.3-9001 will be considered as newer than the official release 1.2.3 by R. We have solved this by separating the pre-releases and official releases into different repos "unstableRepo" and "testingRepo" for pre-releases and "repo" of official releases). This potentially breaks with remotes::install_deps() as it silently appends the Additional_repositories from the DESCRIPTION file to the repos, but since this would only be a problem if a pre-release is ranked as newer than the official release it will not be a problem when installing dependencies from the "repo" since the Additional_repositories points to that same repo: | |
| - name: Install R package dependencies | |
| run: | | |
| # We hard code the list of top level dependencies, since the behavior of remotes::install_deps() that we used before is very unclear (e.g. how is the Additional_repositories included in the list of repos?): | |
| topLevelDeps <- c( | |
| # Imports: | |
| "data.table", | |
| "Rcpp", | |
| "stringi", | |
| "units", | |
| "xml2", | |
| # Suggests: | |
| "httr", | |
| "knitr", | |
| "rmarkdown", | |
| "tinytest" | |
| ) | |
| install.packages( | |
| topLevelDeps, | |
| dependencies = TRUE | |
| ) | |
| shell: Rscript {0} | |
| ## 2d. Session info: | |
| - name: Session info | |
| run: | | |
| options(width = 100) | |
| pkgs <- installed.packages()[, "Package"] | |
| sessioninfo::session_info(pkgs, include_base = TRUE) | |
| shell: Rscript {0} | |
| ##################################### | |
| #### 3. Check the Rstox package: #### | |
| ##################################### | |
| - name: Check | |
| env: | |
| _R_CHECK_CRAN_INCOMING_: false | |
| run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") | |
| shell: Rscript {0} | |
| - name: Upload check results | |
| if: failure() | |
| uses: actions/upload-artifact@main | |
| with: | |
| name: ${{ runner.os }}-r${{ matrix.config.r }}-results | |
| path: check | |
| ####################################################### | |
| #### 4. Build the package source and binary files: #### | |
| ####################################################### | |
| - name: Build package source archive from branches develop, testing and master (on Linux for some reason) | |
| if: runner.os == 'Linux' && matrix.config.r == 'release' && github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'testing' || github.ref_name == 'develop') | |
| run: | | |
| pkgbuild::build(".", dest_path = ".", binary = FALSE) | |
| system(paste0("PKG_FREL=", Sys.getenv("PKG_FILE"), " >> ", Sys.getenv("GITHUB_ENV"))) | |
| shell: Rscript {0} | |
| - name: Build package binary archive from branches develop, testing and master for Windows and macOS | |
| if: (runner.os == 'Windows' || runner.os == 'macOS') && github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'testing' || github.ref_name == 'develop') | |
| run: | | |
| pkgbuild::build(".", dest_path = ".", binary = TRUE) | |
| print("PKG_FILE") | |
| print(Sys.getenv("PKG_FILE")) | |
| print("PKG_FREL") | |
| print(Sys.getenv("PKG_FREL")) | |
| file.copy(Sys.getenv("PKG_FILE"), Sys.getenv("PKG_FREL")) | |
| shell: Rscript {0} | |
| ###################################### | |
| #### 5. Deploy to the drat repos: #### | |
| ###################################### | |
| ## 5a. Upload to the official (DRAT) repo, but only from the master branch: | |
| - name: Upload to the official (DRAT) repo | |
| if: ( (runner.os == 'Windows') || (runner.os == 'macOS') || (runner.os == 'Linux' && matrix.config.r == 'release') ) && github.event_name == 'push' && github.ref_name == 'master' | |
| env: | |
| BUILD_NUMBER: ${{ github.sha }} | |
| DRAT_DEPLOY_TOKEN: ${{ secrets.DRAT_DEPLOY_TOKEN }} | |
| run: . repo_deploy.sh | |
| shell: bash | |
| ## 5b. Upload to the (DRAT) testingRepo, but only from the testing branch: | |
| - name: Upload to the testing (DRAT) repo | |
| if: ( (runner.os == 'Windows') || (runner.os == 'macOS') || (runner.os == 'Linux' && matrix.config.r == 'release') ) && github.event_name == 'push' && github.ref_name == 'testing' | |
| env: | |
| BUILD_NUMBER: ${{ github.sha }} | |
| DRAT_DEPLOY_TOKEN: ${{ secrets.DRAT_DEPLOY_TOKEN }} | |
| run: . testingRepo_deploy.sh | |
| shell: bash | |
| ## 5c. Upload to the (DRAT) unstableRepo, but only from the develop branch: | |
| - name: Upload to the unstable (DRAT) repo | |
| if: ( (runner.os == 'Windows') || (runner.os == 'macOS') || (runner.os == 'Linux' && matrix.config.r == 'release') ) && github.event_name == 'push' && github.ref_name == 'develop' | |
| env: | |
| BUILD_NUMBER: ${{ github.sha }} | |
| DRAT_DEPLOY_TOKEN: ${{ secrets.DRAT_DEPLOY_TOKEN }} | |
| run: . unstableRepo_deploy.sh | |
| shell: bash | |
| ############################### | |
| #### 6. Release on GitHub: #### | |
| ############################### | |
| - name: Create release on GitHub and upload files for testing branch | |
| if: ( (runner.os == 'Windows') || (runner.os == 'macOS') || (runner.os == 'Linux' && matrix.config.r == 'release') ) && github.event_name == 'push' && github.ref_name == 'testing' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| allowUpdates: true | |
| commit: testing | |
| tag: ${{ env.FINAL_TAG }} | |
| name: ${{ env.FINAL_TAG }} | |
| artifacts: ${{ env.PKG_REPO }}/${{ env.PKG_FREL }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create release on GitHub and upload files for master branch | |
| if: ( (runner.os == 'Windows') || (runner.os == 'macOS') || (runner.os == 'Linux' && matrix.config.r == 'release') ) && github.event_name == 'push' && github.ref_name == 'master' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| allowUpdates: true | |
| commit: master | |
| tag: ${{ env.FINAL_TAG }} | |
| name: ${{ env.FINAL_TAG }} | |
| artifacts: ${{ env.PKG_REPO }}/${{ env.PKG_FREL }} | |
| token: ${{ secrets.GITHUB_TOKEN }} |