diff --git a/DESCRIPTION b/DESCRIPTION index 638f7b32..aec0a46a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,6 +19,7 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 Imports: cli, + glue, fs, lintr (>= 2.0.0), renv, diff --git a/R/node.R b/R/node.R index bf9f7013..68dbfdbe 100644 --- a/R/node.R +++ b/R/node.R @@ -1,8 +1,11 @@ system_yarn <- function(...) { - system2( + status <- system2( command = "yarn", args = c("--cwd", shQuote(node_path()), ...) ) + if (status != 0) { + stop(glue::glue("yarn failed with exit status {status}"), call. = FALSE) + } } add_node <- function() { diff --git a/inst/templates/e2e_tests/tests/cypress/.gitignore b/inst/templates/e2e_tests/tests/cypress/dot.gitignore similarity index 100% rename from inst/templates/e2e_tests/tests/cypress/.gitignore rename to inst/templates/e2e_tests/tests/cypress/dot.gitignore diff --git a/inst/templates/github_ci/dot.github/workflows/linter.yml b/inst/templates/github_ci/dot.github/workflows/linter.yml deleted file mode 100644 index 5c4fe905..00000000 --- a/inst/templates/github_ci/dot.github/workflows/linter.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Linter -on: push -jobs: - main: - name: Run linter - runs-on: ubuntu-20.04 - steps: - - name: Checkout repo - uses: actions/checkout@v2 - - - name: Setup R - uses: r-lib/actions/setup-r@v1 - with: - r-version: '4.1.0' - - - name: Restore renv from cache - uses: actions/cache@v2 - with: - path: renv/library - key: renv-${{ hashFiles('renv.lock') }} - restore-keys: renv- - - - name: Sync renv with lockfile - shell: Rscript {0} - run: | - options(renv.config.cache.symlinks = FALSE) - renv::restore(clean = TRUE) - - - name: Lint R - if: always() - shell: Rscript {0} - run: | - rhino::lint_r() diff --git a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml new file mode 100644 index 00000000..449cda8e --- /dev/null +++ b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml @@ -0,0 +1,67 @@ +name: Rhino Test +on: push +permissions: + contents: read +jobs: + main: + name: Run linters and tests + runs-on: ubuntu-20.04 + env: + R_VERSION: '4.1.0' + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Setup R + uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ env.R_VERSION }} + + - name: Restore renv from cache + uses: actions/cache@v2 + env: + CACHE_KEY: renv-${{ runner.arch }}-${{ runner.os }}-${{ env.R_VERSION }} + with: + path: renv/library + key: ${{ env.CACHE_KEY }}-${{ hashFiles('renv.lock') }} + restore-keys: ${{ env.CACHE_KEY }}- + + - name: Sync renv with lockfile + shell: Rscript {0} + run: | + options(renv.config.cache.symlinks = FALSE) + renv::restore(clean = TRUE) + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Lint R + if: always() + shell: Rscript {0} + run: rhino::lint_r() + + - name: Lint JavaScript + if: always() + shell: Rscript {0} + run: rhino::lint_js() + + - name: Lint Sass + if: always() + shell: Rscript {0} + run: rhino::lint_sass() + + - name: Run R unit tests + if: always() + shell: Rscript {0} + run: rhino::test_r() + + - name: Run Cypress end-to-end tests + if: always() + uses: cypress-io/github-action@v2 + with: + working-directory: .rhino/node # Created by earlier commands which use Node.js + start: yarn run-app + project: root/tests