Anirban166 / Autocomment-atime-results

GitHub Action that automatically comments a plot and other atime-based results on PRs
https://github.com/marketplace/actions/autocomment-atime-results
0 stars 1 forks source link

Directory-based environment variable not properly set #7

Closed Anirban166 closed 8 months ago

Anirban166 commented 8 months ago

Running the commands like Siyao did results in errors after installation of atime from GitHub, more specifically first not being able to obtain the environment variable for the current workspace (should be /home/runner/work/Autocomment-plot-GA/Autocomment-plot-GA for ${{ github_workspace }} and /__w/Autocomment-plot-GA/Autocomment-plot-GA for the checkout directory or${GITHUB_WORKSPACE} here), and then not being able to install the package correspondingly (tried to hardcode it with aforementioned values to get to this step, but it didn't work):

    - name: atime-step
      env:
        GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      run: |
        devtools::install_github("tdhock/atime@compare-dt-tidy")
        src_dir <- Sys.getenv("GITHUB_WORKSPACE")
        devtools::install(src_dir)
        options(repos="http://cloud.r-project.org")
        atime::atime_pkg(src_dir)
        shell: Rscript {0}
...
* building ‘atime_[20](https://github.com/Anirban166/.../actions/runs/8011537068/job/21884991381#step:8:21)[23](https://github.com/Anirban166/.../actions/runs/8011537068/job/21884991381#step:8:24).3.31.tar.gz’
Installing package into ‘/__w/_temp/Library’
(as ‘lib’ is unspecified)
* installing *source* package ‘atime’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (atime)
...
Run src_dir <- Sys.getenv("GITHUB_WORKSPACE")
Run atime::atime_pkg(src_dir)
Error: Error: object 'src_dir' not found
Execution halted

Running the statements together lead to errors as well:

Run Rscript -e 'devtools::install_github("tdhock/atime@compare-dt-tidy"); src_dir <- Sys.getenv("GITHUB_WORKSPACE"); devtools::install(src_dir); options(repos="http://cloud.r-project.org"); result.list <- atime::atime_pkg(src_dir)'
Installing package into ‘/__w/_temp/Library’
(as ‘lib’ is unspecified)
* installing *source* package ‘atime’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (atime)
Error in `package_file()`:
! Could not find package root.
ℹ Is '/__w/<repository>/<repository>'
  inside a package?
Backtrace:
    ▆
 1. └─devtools::install(src_dir)
 2.   └─devtools::as.package(pkg)
 3.     └─devtools::package_file(path = x)
 4.       └─cli::cli_abort(c("Could not find package root.", i = "Is {.path {base_path}} inside a package?"))
 5.         └─rlang::abort(...)
Execution halted
Error: Process completed with exit code 1.
Anirban166 commented 8 months ago

Possibly, a git switch might be necessary. Especially given how git2r::checkout(repo, "another-branch") is done by atime::atime_pkg(src_dir) [1] (although to get to that step the environment variable must be properly set) and since that step only fetches the repository without creating any branches for atime to work on.

[1] https://cran.r-project.org/web/packages/atime/atime.pdf