JuliaInterop / RCall.jl

Call R from Julia
Other
318 stars 59 forks source link

Could we add a point in the docs about setting up CI ? #522

Open lrnv opened 2 months ago

lrnv commented 2 months ago

Hey,

In one of my packahe, I wanted to use RCall in tests to compare the results I have with existing R packages that are supposed to compute the same quantities.

To do that locally, it was really easy with RCall and shout out for that !

But On github actions, it was waaaaaay harder to setup. I finally found a proper way to do it copying the solution from https://github.com/szcf-weiya/MonotoneSplines.jl/actions/runs/7955113426/job/21713557684#step:6:2 that i found.. i dont even know how. I looked around for a few hours before finding a solution.

Considering the hassle and the burden of setting this up, I wander if a specific piece of documentation (which has to live here in RCalll) would be possible so that, next time, it would be easier to setup.

I could propose a PR to the docs to write down what i found.

evangorstein commented 2 months ago

Agreed! I just had a similar experience struggling to figure out how to use RCall in the automatic testing environment with github actions (locally, testing run smoothly). Considering that one huge use case of RCall is to compare the results of your Julia implementation with the results from a given R package, it would be extremely helpful to have it documented how to set up the automatic testing environment so that RCall works.

lrnv commented 2 months ago

@evangorstein could you share your setup ? Mine is unfortunately still in private repo but will be released soon

evangorstein commented 2 months ago

I ended up copy-pasting from the workflow for MonotoneSplines.jl that you linked to. That is, I included the following in my workflow file

      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.r-version }}
      # actually it seems that without installing `libcurl4-openssl-dev`, there also exists a libcurl.so, but at `/lib/x86_64-linux-gnu/libcurl.so.4` instead of `/usr/lib/x86_64-linux-gnu/libcurl.so.4`
      # for consistency with previous setting and also recommended at https://github.com/r-lib/actions/tree/v2/setup-r-dependencies, continue to install `libcurl4-openssl-dev`
      - name: Install libcurl on Linux
        if: runner.os == 'Linux'
        run: sudo apt-get update -y && sudo apt-get install -y libcurl4-openssl-dev
      - name: Install Dependencies for R
        run: |
          r = getOption("repos")
          r["CRAN"] = "https://cloud.r-project.org/"
          options(repos=r)
          install.packages("some_package")
        shell: sudo Rscript {0}

and then later

      - uses: julia-actions/julia-runtest@v1
        env:
          LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libcurl.so.4
          LD_LIBRARY_PATH: /opt/R/${{ matrix.r-version }}/lib/R/lib

I'm not sure whether all of this is necessary, but I included it all just in case.

palday commented 2 months ago

I'm not opposed to adding some tips to the docs in a section titled something like "Using RCall in CI". Two other places to look for examples:

lrnv commented 2 months ago

Just to give a small status update since this is runing on a private repo EDIT: not anymore got published, the file is there. The way of setting R packages that i used (the r-lib/actions/setup-r-dependencies@v2 action) gives automatic caching of them from a run to the next and is the actual recomended way of doing this.

However I still struggle to get it stable : it installs the last version of every R package each times, which is known to be buggy, and in 3 weeks I had to upload the R version twice from 4.1 to 4.3 to 4.4.0 now... Maybe there is something that could be done to freeze package versions with R::renv but I was not able to make it work.

cecileane commented 1 month ago

I also recently struggled with this, mostly to make Julia RCall find the path to R under macos-latest. It worked with this setup.