You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2022/10/16 20:57:11 UTC

[arrow-cookbook] branch main updated: [R]: Add R build against Arrow Nightlies version (#265)

This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-cookbook.git


The following commit(s) were added to refs/heads/main by this push:
     new fb85e4d  [R]: Add R build against Arrow Nightlies version (#265)
fb85e4d is described below

commit fb85e4dba63de5ffe40999ff1055db8062b471a4
Author: Raúl Cumplido <ra...@gmail.com>
AuthorDate: Sun Oct 16 22:57:06 2022 +0200

    [R]: Add R build against Arrow Nightlies version (#265)
    
    * Run R cookbooks against Arrow nightlies
    
    * Try to fix if condition on R
    
    * Install pyarrow nightlies in case of R nightlies
    
    * Fix for not reinstalling arrow nightlies if already installed
    
    * Fix use nightly in case of nightly already installed
    
    * Fix syntax
---
 .github/workflows/test_r_cookbook.yml | 32 ++++++++++++++++++++++++++++----
 Makefile                              |  4 ++++
 r/scripts/install_dependencies.R      | 14 +++++++-------
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/test_r_cookbook.yml b/.github/workflows/test_r_cookbook.yml
index 326e021..1c2e556 100644
--- a/.github/workflows/test_r_cookbook.yml
+++ b/.github/workflows/test_r_cookbook.yml
@@ -31,14 +31,38 @@ concurrency:
 
 jobs:
   test_r:
-    name: "Test R Cookbook"
+    name: "Test R Cookbook on Arrow stable"
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v3
       - name: Setup R
-        uses: r-lib/actions/setup-r@v1
+        uses: r-lib/actions/setup-r@v2
+        with:
+          use-public-rspm: true
       - name: Setup pandoc
-        uses: r-lib/actions/setup-pandoc@v1
+        uses: r-lib/actions/setup-pandoc@v2
+      - name: Install dependencies
+        run: |
+          sudo apt update
+          sudo apt install libcurl4-openssl-dev libssl-dev
+      - name: Run tests
+        run: make rtest
+      - name: Build cookbooks
+        run: make r
+
+  test_r_nightlies:
+    name: "Test R Cookbook on Arrow Nightlies"
+    runs-on: ubuntu-latest
+    env:
+      ARROW_NIGHTLY: 1
+    steps:
+      - uses: actions/checkout@v3
+      - name: Setup R
+        uses: r-lib/actions/setup-r@v2
+        with:
+          use-public-rspm: true
+      - name: Setup pandoc
+        uses: r-lib/actions/setup-pandoc@v2
       - name: Install dependencies
         run: |
           sudo apt update
diff --git a/Makefile b/Makefile
index 5ee8797..1265435 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,11 @@ ifdef arrow_r_version
 else
 	cd ./r && Rscript ./scripts/install_dependencies.R
 endif
+ifeq ($(ARROW_NIGHTLY), 1)
+	pip install --upgrade --extra-index-url https://pypi.fury.io/arrow-nightlies/ --prefer-binary --pre pyarrow
+else
 	pip install pyarrow
+endif
 
 
 r: rdeps
diff --git a/r/scripts/install_dependencies.R b/r/scripts/install_dependencies.R
index f309081..60eec6d 100644
--- a/r/scripts/install_dependencies.R
+++ b/r/scripts/install_dependencies.R
@@ -64,19 +64,19 @@ install_arrow_version <- function(version_to_install) {
   Sys.setenv("ARROW_HOME" = "")
   on.exit(Sys.setenv("ARROW_HOME" = old_home))
   
-  # TODO: refactor this to get the latest available version on the nightlies
-  # given we set NOT_CRAN = TRUE (#29)
   latest_release <- package_version(available.packages()["arrow", ]["Version"])
+  latest_nightly <- package_version(available.packages(repos = "https://nightlies.apache.org/arrow/r")["arrow", ]["Version"])
   installed_version <- get_installed_version("arrow")
+  use_nightly <- !is.na(Sys.getenv("ARROW_NIGHTLY", NA))
 
   # Only install the latest released version if it's not already installed
-  if (version_to_install == latest_release && installed_version != latest_release) {
+  if (use_nightly && installed_version != latest_nightly) {
+    Sys.setenv(NOT_CRAN = TRUE)
+    install.packages("arrow", repos = c(arrow = "https://nightlies.apache.org/arrow/r", getOption("repos")))
+  } else if (!use_nightly && version_to_install == latest_release && installed_version != latest_release) {
     Sys.setenv(NOT_CRAN = TRUE)
     install.packages("arrow")
-    # Otherwise install the build version specified if not already installed
-    # TODO: refactor this to install the specific version from the nightlies if
-    # a binary is available (#29)
-  } else if (installed_version != version_to_install) {
+  } else if (!use_nightly && installed_version != version_to_install) {
     remotes::install_version("arrow", version = version_to_install)
   }
 }