From c0046016f948933a02c3409837e39fd7b5e22c8d Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Fri, 18 Feb 2022 13:47:38 +0100 Subject: [PATCH 1/6] feat: Call stop() if yarn fails --- DESCRIPTION | 1 + R/node.R | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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() { From 018f851978d2f43573462c966dc4554c8f7924fe Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Fri, 18 Feb 2022 13:51:05 +0100 Subject: [PATCH 2/6] feat: Add lint_js(), lint_sass() and test_r() check to Rhino CI --- .../workflows/{linter.yml => rhino-test.yml} | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) rename inst/templates/github_ci/dot.github/workflows/{linter.yml => rhino-test.yml} (56%) diff --git a/inst/templates/github_ci/dot.github/workflows/linter.yml b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml similarity index 56% rename from inst/templates/github_ci/dot.github/workflows/linter.yml rename to inst/templates/github_ci/dot.github/workflows/rhino-test.yml index 5c4fe905..25ac8319 100644 --- a/inst/templates/github_ci/dot.github/workflows/linter.yml +++ b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml @@ -1,8 +1,8 @@ -name: Linter +name: Rhino Test on: push jobs: main: - name: Run linter + name: Run linters and tests runs-on: ubuntu-20.04 steps: - name: Checkout repo @@ -26,8 +26,27 @@ jobs: 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() + 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() From e22616093b244b45f5e494382ad265d5eaef4fc0 Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Fri, 18 Feb 2022 13:51:34 +0100 Subject: [PATCH 3/6] feat: Set GITHUB_PAT in Rhino CI --- inst/templates/github_ci/dot.github/workflows/rhino-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml index 25ac8319..485ee7e5 100644 --- a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml +++ b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml @@ -1,9 +1,13 @@ name: Rhino Test on: push +permissions: + contents: read jobs: main: name: Run linters and tests runs-on: ubuntu-20.04 + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repo uses: actions/checkout@v2 From 0ddb671bbf1a16683bc473154794fdd62157d29d Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Mon, 21 Feb 2022 12:20:51 +0100 Subject: [PATCH 4/6] fix: Add dot prefix to .gitignore in Cypress template --- .../e2e_tests/tests/cypress/{.gitignore => dot.gitignore} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename inst/templates/e2e_tests/tests/cypress/{.gitignore => dot.gitignore} (100%) 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 From d4c4b773b1cddf96d7d0f1c427822ed6cf56cd21 Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Mon, 21 Feb 2022 12:29:22 +0100 Subject: [PATCH 5/6] feat: Add Cypress to Rhino app CI --- .../github_ci/dot.github/workflows/rhino-test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml index 485ee7e5..a81c38fe 100644 --- a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml +++ b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml @@ -54,3 +54,11 @@ jobs: 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 From 4c54168a1846210b2a5bd66625c1906263f33194 Mon Sep 17 00:00:00 2001 From: Kamil Zyla Date: Mon, 21 Feb 2022 12:54:11 +0100 Subject: [PATCH 6/6] feat: Use a more specific renv cache key --- .../github_ci/dot.github/workflows/rhino-test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml index a81c38fe..449cda8e 100644 --- a/inst/templates/github_ci/dot.github/workflows/rhino-test.yml +++ b/inst/templates/github_ci/dot.github/workflows/rhino-test.yml @@ -7,6 +7,7 @@ jobs: 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 @@ -15,14 +16,16 @@ jobs: - name: Setup R uses: r-lib/actions/setup-r@v1 with: - r-version: '4.1.0' + 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: renv-${{ hashFiles('renv.lock') }} - restore-keys: renv- + key: ${{ env.CACHE_KEY }}-${{ hashFiles('renv.lock') }} + restore-keys: ${{ env.CACHE_KEY }}- - name: Sync renv with lockfile shell: Rscript {0}