Installing lintr for GitHub actions - r

I want to adapt the boilerplate code in the r-lib/actions repo to add a linting check to my (fake) package. I have my workflow yaml as follows:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: lint
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./mystarwars
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "../.github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "../.github/R-version")
shell: Rscript {0}
- name: Restore R package cache
uses: actions/cache#v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('../.github/R-version') }}-1-${{ hashFiles('../.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('../.github/R-version') }}-1-
- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
install.packages(c("lintr"))
shell: Rscript {0}
- name: Install package
run: R CMD INSTALL .
- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
However, I get errors when trying to install lintr in the "Install dependencies". This step fails (silently), so then when it reaches the "Lint" step it fails with Error: Error in loadNamespace(x) : there is no package called ‘lintr’.
This remains the case whether I use install.packages(c("lintr")) or remotes::install_cran("lintr").
HERE is the full log of the "Install dependencies" step on GitHub Actions.

Related

npm CI && npm run build is failing in github actions, I'm using firebase to deploy the project

npm CI && npm run build is failing in github actions I'll paste the yaml file below.
name: Deploy to Firebase Hosting on PR
"on": pull_request
jobs:
build_and_preview:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy#v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.SECRET }}"
projectId: projectId
enter image description here
I tried to remove npm CI, deleted node_modules package and package.json file in local and re-installed everything.
It looks like you don't have package-lock.json in the root directory.
You can add it using: npm i --package-lock-only
And try to set the ci to empty, eg:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout#v3
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
env:
CI: ""

How to fix yml config

https://github.com/KillerJoke623/Practic
I've got a problem with my University practic, can you help me please
name: Jupyter
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Setup Python
uses: actions/setup-python#v4.0.0
with:
cache: pip
python-version: '3.7'
- name: Install Dependencies
run: pip install -r requirements.txt
- name: Exeute Notebook
run: jupyter-nbconvert --to html practic.ipynb
- name: Upload a Build Artifact
uses: actions/upload-artifact#v3.1.0
with:
name: Artifact
path: practic.html

pkgdown workflow fails to deploy gh pages

I setup for my R package repository a pkgdown workflow.
The .github/workflows/pkgdown.yaml file:
on:
push:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-pandoc#v1
- uses: r-lib/actions/setup-r#v1
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies#v1
with:
extra-packages: pkgdown
needs: website
- name: Deploy package
if: contains(env.isPush, 'true')
run: |
git config --local user.email "actions#github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
The pkgdown workflow works fine, but it fails to update the GitHub pages.
I setup the gh-pages branch as explained in the GitHub documentation, so the workflow pages-build-deployment is present, but when I push on main branch it doesn't run.
I realized the problem was in the if: contains(env.isPush, 'true') line. The condition is never true nor false, since there is no attribute isPush under env, hence the lines
run: |
git config --local user.email "actions#github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
were never executed.
To solve the problem, either modify the env part:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
isPush: ${{ github.event_name == 'push' }}
or remove the if condition before the run command.

Testing an R package against a Julia package on github actions - works on all OS but fails on windows

This is a cross-post from the rstudio forum.
I have been working towards continuous integration testing of an algorithm wrapped in an R package against a Julia implementation, which I have also packaged in an R package via JuliaConnectoR.
I create a standard cmd-check workflow via usethis::use_github_actions(), but additionally install Julia, the required Julia package (WildBootTests.jl) and link R and Julia (the 'JULIA_BINDIR' part).
The code below successfully deploys the cmd check on github actions for Max and Ubuntu but fails for windows. The part that fails is run: julia -e 'using Pkg; Pkg.add("WildBootTests")', which installs the WildBootTests.jl package via the shell.
Does anyone have an idea why the installation of WildBootTests.jl fails on windows, but not on Mac and Ubuntu?
You can find more information on the workflow here: https://github.com/s3alfisc/fwildclusterboot/actions/runs/1583895387
Thanks for your help!
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-pandoc#v1
- uses: r-lib/actions/setup-r#v1
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies#v1
with:
extra-packages: rcmdcheck
# custom code starts here
# install julia
- uses: julia-actions/setup-julia#v1
# add julia to renviron
- name: Create and populate .Renviron file
run: echo JULIA_BINDIR= "${{ env.juliaLocation }}" >> ~/.Renviron
# install WildBootTests.jl
- name: install WildBootTests.jl
run: julia -e 'using Pkg; Pkg.add("WildBootTests")'
# custom code ends here
- uses: r-lib/actions/check-r-package#v1
- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Upload check results
if: failure()
uses: actions/upload-artifact#main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
Update: If I include the line shell: bash under the run: julia -e statements, package installation does not fail on windows.
Hence, the added part needs to look like this:
# custom code starts here
# install julia
- uses: julia-actions/setup-julia#v1
# add julia to renviron
- name: Create and populate .Renviron file
run: echo JULIA_BINDIR= "${{ env.juliaLocation }}" >> ~/.Renviron
shell: bash
# install WildBootTests.jl
- name: install WildBootTests.jl
run: julia -e 'using Pkg; Pkg.add("WildBootTests")'
shell: bash
# custom code ends here

Github Actions - R package R-CMD-Check "PhantomJS not found"

I am using GitHub actions for CI of my R package. I am trying using both testthat and shinytest in my package. I have the package structure set up correctly according to the shinytest documentation. When I run R-CMD-CHECK in RStudio, my package (including both testthat and shinytest testing works).
My GitHub Actions .yaml workflow is:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#v1
with:
r-version: ${{ matrix.config.r }}
- uses: r-lib/actions/setup-pandoc#v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache#v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- name: Upload check results
if: failure()
uses: actions/upload-artifact#main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
When I commit to the repository, the check fails on Windows and Mac OS but works on Ubuntu.
The error that I am I am getting on both Windows and Mac OS is:
> test_check("mypackage")
-- 1. Error: application works (#test-appdir.R#6) -----------------------------
PhantomJS not found.
I don't think this is a problem with my package or tests. I think there is something misconfigured about my .yaml. How can I resolve this issue with PhantomJS in my workflow?
The easy solution will be to go to the project where there is used PhantomJS and the Github Actions is turned on. We will go to shiny project and precisely to:
https://github.com/rstudio/shiny/blob/master/.github/workflows/R-CMD-check.yaml
We could find out there that:
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Find PhantomJS path
id: phantomjs
run: |
echo "::set-output name=path::$(Rscript -e 'cat(shinytest:::phantom_paths()[[1]])')"
- name: Cache PhantomJS
uses: actions/cache#v1
with:
path: ${{ steps.phantomjs.outputs.path }}
key: ${{ runner.os }}-phantomjs
restore-keys: ${{ runner.os }}-phantomjs
- name: Install PhantomJS
run: >
Rscript
-e "if (!shinytest::dependenciesInstalled()) shinytest::installDependencies()"
We easily could check that there is separate chunk of code only to be sure that PhantomJS localization is known or if it should be installed.
You could paste this part of code to your yaml file. However the best way might to be follow the pipeline of shiny project,
It's hard to investigate the issue without detailed logs and no information about what dependencies (remotes) are being installed in Query dependencies step. It seems the PhantomJS dependency is not being installed at all. The workflow succeeds on ubuntu-20.04 because the runner has PhantomJS installed out-of-the-box. You can see all the installed software on provided runner types here. The other runner types used in the workflow above (windows-latest and macOS-latest) are missing PhantomJS. That's why your workflow fails on Windows and MacOS but succeeds on Ubuntu.

Resources