|
| 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 | + R-CMD-check: |
| 21 | + runs-on: ${{ matrix.config.os }} |
| 22 | + |
| 23 | + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) |
| 24 | + |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + config: |
| 29 | + - {os: macOS-latest, r: 'release', visual_tests: true, node: "14.x", shinytest: true} |
| 30 | + - {os: windows-latest, r: 'release'} |
| 31 | + #- {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"} |
| 32 | + - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-18.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } |
| 33 | + # vdiffr & shinytest only runs on linux r-release since the results aren't cross-platform |
| 34 | + - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 35 | + - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 36 | + - {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 37 | + - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 38 | + |
| 39 | + env: |
| 40 | + RSPM: ${{ matrix.config.rspm }} |
| 41 | + VISUAL_TESTS: ${{ matrix.config.visual_tests }} |
| 42 | + SHINYTEST: ${{ matrix.config.shinytest }} |
| 43 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} |
| 45 | + plotly_username: ${{ secrets.PLOTLY_USERNAME }} |
| 46 | + plotly_api_key: ${{ secrets.PLOTLY_API_KEY }} |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v2 |
| 50 | + |
| 51 | + - uses: r-lib/actions/setup-r@v1 |
| 52 | + id: install-r |
| 53 | + with: |
| 54 | + r-version: ${{ matrix.config.r }} |
| 55 | + http-user-agent: ${{ matrix.config.http-user-agent }} |
| 56 | + |
| 57 | + - uses: r-lib/actions/setup-pandoc@v1 |
| 58 | + |
| 59 | + - name: Install pak and query dependencies |
| 60 | + run: | |
| 61 | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") |
| 62 | + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") |
| 63 | + shell: Rscript {0} |
| 64 | + |
| 65 | + - name: Restore R package cache |
| 66 | + uses: actions/cache@v2 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ${{ env.R_LIBS_USER }}/* |
| 70 | + !${{ env.R_LIBS_USER }}/pak |
| 71 | + key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} |
| 72 | + restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- |
| 73 | + |
| 74 | + - name: Install Linux sysdeps |
| 75 | + if: runner.os == 'Linux' |
| 76 | + run: | |
| 77 | + pak::local_system_requirements(execute = TRUE) |
| 78 | + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) |
| 79 | + shell: Rscript {0} |
| 80 | + |
| 81 | + - name: Install dependencies |
| 82 | + run: | |
| 83 | + if (Sys.info()[['sysname']] == 'Darwin') options(pkgType = 'mac.binary') |
| 84 | + pak::local_install_dev_deps(upgrade = FALSE) |
| 85 | + pak::pkg_install("rcmdcheck") |
| 86 | + shell: Rscript {0} |
| 87 | + |
| 88 | + - name: Set up Python 3.8 |
| 89 | + uses: actions/setup-python@v2 |
| 90 | + with: |
| 91 | + python-version: 3.8 |
| 92 | + |
| 93 | + - name: Install kaleido |
| 94 | + if: matrix.config.visual_tests == true |
| 95 | + run: | |
| 96 | + sudo chown -R $UID $CONDA # https://github.com/nextstrain/conda/issues/5 |
| 97 | + Rscript -e "reticulate::install_miniconda()" |
| 98 | + Rscript -e "reticulate::conda_install('r-reticulate', 'python-kaleido')" |
| 99 | + Rscript -e "reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')" |
| 100 | + Rscript -e "reticulate::use_miniconda('r-reticulate')" |
| 101 | + |
| 102 | + - name: Install shinytest deps |
| 103 | + if: matrix.config.shinytest == true |
| 104 | + run: | |
| 105 | + Rscript -e 'shinytest::installDependencies()' |
| 106 | + R CMD install . |
| 107 | + shell: bash |
| 108 | + |
| 109 | + # Run test() before R CMD check since, for some reason, rcmdcheck::rcmdcheck() skips vdiffr tests |
| 110 | + - name: Run Tests |
| 111 | + run: | |
| 112 | + options(crayon.enabled = TRUE, testthat.progress.max_fails=1000) |
| 113 | + if (!require(devtools)) pak::pak("devtools") |
| 114 | + if (!require(reshape2)) pak::pak("reshape2") |
| 115 | + res <- devtools::test() |
| 116 | + df <- as.data.frame(res) |
| 117 | + if (sum(df$failed) > 0 || any(df$error)) stop("GHA CI tests failed") |
| 118 | + shell: Rscript {0} |
| 119 | + |
| 120 | + # Upload the whole pkg since tests where run with devtools::test() |
| 121 | + - name: Upload check results |
| 122 | + if: always() |
| 123 | + uses: actions/upload-artifact@master |
| 124 | + with: |
| 125 | + name: ${{ runner.os }}-r${{ matrix.config.r }}-results |
| 126 | + path: ./ |
| 127 | + |
| 128 | + # Run check with --no-tests since we ran them abve |
| 129 | + - name: Check |
| 130 | + run: | |
| 131 | + options(crayon.enabled = TRUE) |
| 132 | + rcmdcheck::rcmdcheck(args = c("--no-tests", "--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") |
| 133 | + shell: Rscript {0} |
| 134 | + |
| 135 | + #- name: Show testthat output |
| 136 | + # if: always() |
| 137 | + # run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 138 | + # shell: bash |
| 139 | + |
| 140 | + - name: Don't use tar from old Rtools to store the cache |
| 141 | + if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} |
| 142 | + shell: bash |
| 143 | + run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH |
0 commit comments