|
| 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'} |
| 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', vdiffr: true, shinytest: true, 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 | + - {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} |
| 39 | + |
| 40 | + env: |
| 41 | + RSPM: ${{ matrix.config.rspm }} |
| 42 | + VDIFFR: ${{ matrix.config.vdiffr }} |
| 43 | + SHINYTEST: ${{ matrix.config.shinytest }} |
| 44 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v2 |
| 48 | + |
| 49 | + - uses: r-lib/actions/setup-r@v1 |
| 50 | + id: install-r |
| 51 | + with: |
| 52 | + r-version: ${{ matrix.config.r }} |
| 53 | + http-user-agent: ${{ matrix.config.http-user-agent }} |
| 54 | + |
| 55 | + - uses: r-lib/actions/setup-pandoc@v1 |
| 56 | + |
| 57 | + - name: Install pak and query dependencies |
| 58 | + run: | |
| 59 | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") |
| 60 | + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") |
| 61 | + shell: Rscript {0} |
| 62 | + |
| 63 | + - name: Restore R package cache |
| 64 | + uses: actions/cache@v2 |
| 65 | + with: |
| 66 | + path: | |
| 67 | + ${{ env.R_LIBS_USER }}/* |
| 68 | + !${{ env.R_LIBS_USER }}/pak |
| 69 | + key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} |
| 70 | + restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- |
| 71 | + |
| 72 | + - name: Install system dependencies |
| 73 | + if: runner.os == 'Linux' |
| 74 | + run: | |
| 75 | + pak::local_system_requirements(execute = TRUE) |
| 76 | + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) |
| 77 | + shell: Rscript {0} |
| 78 | + |
| 79 | + #- name: Install google chrome |
| 80 | + # if: matrix.config.vdiffr == true |
| 81 | + # shell: bash |
| 82 | + # run: | |
| 83 | + # wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - |
| 84 | + # sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' |
| 85 | + # apt-get update -y |
| 86 | + # apt-get install -y google-chrome-stable |
| 87 | + |
| 88 | + # TODO: maybe this should install via conda or npm instead? |
| 89 | + - name: Install orca |
| 90 | + if: matrix.config.vdiffr == true |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + sudo apt-get -y update |
| 94 | + sudo apt-get install -y libgtk2.0-0 libgconf-2-4 xvfb xauth libxtst6 libxss1 libnss3 libasound2 desktop-file-utils |
| 95 | + mkdir -p /opt/orca |
| 96 | + cd /opt/orca |
| 97 | + wget https://github.com/plotly/orca/releases/download/v1.3.1/orca-1.3.1.AppImage |
| 98 | + sudo chmod +x orca-1.3.1.AppImage |
| 99 | + sudo ./orca-1.3.1.AppImage --appimage-extract |
| 100 | + sudo rm orca-1.3.1.AppImage |
| 101 | + sudo printf '#!/bin/bash \nargs=("$@") \nif [[ ! " ${args[@]} " =~ "--no-sandbox" ]]; then \n args+=("--no-sandbox") \nfi \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /opt/orca/squashfs-root/orca "${args[@]}"' > /usr/bin/orca \ |
| 102 | + sudo chmod +x /usr/bin/orca |
| 103 | + sudo orca graph '{ "data": [{"y": [1,2,1]}] }' -o fig.png |
| 104 | +
|
| 105 | + - name: Install dependencies |
| 106 | + run: | |
| 107 | + pak::local_install_dev_deps(upgrade = TRUE) |
| 108 | + pak::pkg_install("rcmdcheck") |
| 109 | + shell: Rscript {0} |
| 110 | + |
| 111 | + - name: Session info |
| 112 | + run: | |
| 113 | + options(width = 100) |
| 114 | + pkgs <- installed.packages()[, "Package"] |
| 115 | + sessioninfo::session_info(pkgs, include_base = TRUE) |
| 116 | + shell: Rscript {0} |
| 117 | + |
| 118 | + - name: Check |
| 119 | + env: |
| 120 | + _R_CHECK_CRAN_INCOMING_: false |
| 121 | + run: | |
| 122 | + options(crayon.enabled = TRUE) |
| 123 | + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") |
| 124 | + shell: Rscript {0} |
| 125 | + |
| 126 | + - name: Show testthat output |
| 127 | + if: always() |
| 128 | + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 129 | + shell: bash |
| 130 | + |
| 131 | + - name: Upload check results |
| 132 | + if: failure() |
| 133 | + uses: actions/upload-artifact@main |
| 134 | + with: |
| 135 | + name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results |
| 136 | + path: check |
| 137 | + |
| 138 | + - name: Don't use tar from old Rtools to store the cache |
| 139 | + if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} |
| 140 | + shell: bash |
| 141 | + run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH |
0 commit comments