|
| 1 | +# NOTE: This workflow is overkill for most R packages |
| 2 | +# check-standard.yaml is likely a better choice |
| 3 | +# usethis::use_github_action("check-standard") will install it. |
| 4 | +# |
| 5 | +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. |
| 6 | +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - master |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + - master |
| 16 | + |
| 17 | +name: R-CMD-check |
| 18 | + |
| 19 | +jobs: |
| 20 | + rversions: |
| 21 | + name: R Versions |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + devel: ${{ steps.devel.outputs.installed-r-version }} |
| 25 | + release: ${{ steps.release.outputs.installed-r-version }} |
| 26 | + oldrel1: ${{ steps.oldrel1.outputs.installed-r-version }} |
| 27 | + oldrel2: ${{ steps.oldrel2.outputs.installed-r-version }} |
| 28 | + oldrel3: ${{ steps.oldrel3.outputs.installed-r-version }} |
| 29 | + oldrel4: ${{ steps.oldrel4.outputs.installed-r-version }} |
| 30 | + steps: |
| 31 | + - name: devel |
| 32 | + uses: r-lib/actions/setup-r@master |
| 33 | + id: devel |
| 34 | + with: |
| 35 | + r-version: devel |
| 36 | + install-r: false # No need to install. Just need version |
| 37 | + |
| 38 | + - name: release |
| 39 | + uses: r-lib/actions/setup-r@master |
| 40 | + id: release |
| 41 | + with: |
| 42 | + r-version: release |
| 43 | + install-r: false # No need to install. Just need version |
| 44 | + |
| 45 | + - name: oldrel/1 |
| 46 | + uses: r-lib/actions/setup-r@master |
| 47 | + id: oldrel1 |
| 48 | + with: |
| 49 | + r-version: oldrel/1 |
| 50 | + install-r: false # No need to install. Just need version |
| 51 | + |
| 52 | + - name: oldrel/2 |
| 53 | + uses: r-lib/actions/setup-r@master |
| 54 | + id: oldrel2 |
| 55 | + with: |
| 56 | + r-version: oldrel/2 |
| 57 | + install-r: false # No need to install. Just need version |
| 58 | + |
| 59 | + - name: oldrel/3 |
| 60 | + uses: r-lib/actions/setup-r@master |
| 61 | + id: oldrel3 |
| 62 | + with: |
| 63 | + r-version: oldrel/3 |
| 64 | + install-r: false # No need to install. Just need version |
| 65 | + |
| 66 | + - name: oldrel/4 |
| 67 | + uses: r-lib/actions/setup-r@master |
| 68 | + id: oldrel4 |
| 69 | + with: |
| 70 | + r-version: oldrel/4 |
| 71 | + install-r: false # No need to install. Just need version |
| 72 | + |
| 73 | + - name: Set Output |
| 74 | + id: set_versions |
| 75 | + run: | |
| 76 | + echo "devel: ${{ steps.devel.outputs.installed-r-version }}" |
| 77 | + echo "release: ${{ steps.release.outputs.installed-r-version }}" |
| 78 | + echo "oldrel1: ${{ steps.oldrel1.outputs.installed-r-version }}" |
| 79 | + echo "oldrel2: ${{ steps.oldrel2.outputs.installed-r-version }}" |
| 80 | + echo "oldrel3: ${{ steps.oldrel3.outputs.installed-r-version }}" |
| 81 | + echo "oldrel4: ${{ steps.oldrel4.outputs.installed-r-version }}" |
| 82 | +
|
| 83 | +
|
| 84 | + R-CMD-check: |
| 85 | + runs-on: ${{ matrix.config.os }} |
| 86 | + |
| 87 | + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) |
| 88 | + |
| 89 | + needs: |
| 90 | + - rversions |
| 91 | + strategy: |
| 92 | + fail-fast: false |
| 93 | + matrix: |
| 94 | + config: |
| 95 | + - {os: macOS-latest, r: '${{ needs.rversions.outputs.release }}'} |
| 96 | + - {os: windows-latest, r: '${{ needs.rversions.outputs.release }}'} |
| 97 | + - {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} |
| 98 | + - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "release" } |
| 99 | + - {os: ubuntu-18.04, r: '${{ needs.rversions.outputs.release }}', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 100 | + - {os: ubuntu-18.04, r: '${{ needs.rversions.outputs.oldrel1 }}', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 101 | + - {os: ubuntu-18.04, r: '${{ needs.rversions.outputs.oldrel2 }}', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 102 | + - {os: ubuntu-18.04, r: '${{ needs.rversions.outputs.oldrel3 }}', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 103 | + - {os: ubuntu-18.04, r: '${{ needs.rversions.outputs.oldrel4 }}', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 104 | + |
| 105 | + env: |
| 106 | + RSPM: ${{ matrix.config.rspm }} |
| 107 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v2 |
| 111 | + |
| 112 | + - uses: r-lib/actions/setup-r@master |
| 113 | + id: install-r |
| 114 | + with: |
| 115 | + r-version: ${{ matrix.config.r }} |
| 116 | + http-user-agent: ${{ matrix.config.http-user-agent }} |
| 117 | + |
| 118 | + - uses: r-lib/actions/setup-pandoc@v1 |
| 119 | + |
| 120 | + - name: Install pak and query dependencies |
| 121 | + run: | |
| 122 | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") |
| 123 | + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") |
| 124 | + shell: Rscript {0} |
| 125 | + |
| 126 | + - name: Restore R package cache |
| 127 | + uses: actions/cache@v2 |
| 128 | + with: |
| 129 | + path: | |
| 130 | + ${{ env.R_LIBS_USER }}/* |
| 131 | + !${{ env.R_LIBS_USER }}/pak |
| 132 | + key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} |
| 133 | + restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- |
| 134 | + |
| 135 | + - name: Install system dependencies |
| 136 | + if: runner.os == 'Linux' |
| 137 | + run: | |
| 138 | + pak::local_system_requirements(execute = TRUE) |
| 139 | + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) |
| 140 | + shell: Rscript {0} |
| 141 | + |
| 142 | + - name: Install dependencies |
| 143 | + run: | |
| 144 | + pak::local_install_dev_deps(upgrade = TRUE) |
| 145 | + pak::pkg_install("rcmdcheck") |
| 146 | + shell: Rscript {0} |
| 147 | + |
| 148 | + - name: Session info |
| 149 | + run: | |
| 150 | + options(width = 100) |
| 151 | + pkgs <- installed.packages()[, "Package"] |
| 152 | + sessioninfo::session_info(pkgs, include_base = TRUE) |
| 153 | + shell: Rscript {0} |
| 154 | + |
| 155 | + - name: Check |
| 156 | + env: |
| 157 | + _R_CHECK_CRAN_INCOMING_: false |
| 158 | + run: | |
| 159 | + options(crayon.enabled = TRUE) |
| 160 | + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") |
| 161 | + shell: Rscript {0} |
| 162 | + |
| 163 | + - name: Show testthat output |
| 164 | + if: always() |
| 165 | + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 166 | + shell: bash |
| 167 | + |
| 168 | + - name: Upload check results |
| 169 | + if: failure() |
| 170 | + uses: actions/upload-artifact@main |
| 171 | + with: |
| 172 | + name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results |
| 173 | + path: check |
| 174 | + |
| 175 | + - name: Don't use tar from old Rtools to store the cache |
| 176 | + if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} |
| 177 | + shell: bash |
| 178 | + run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH |
0 commit comments