Open ThierryO opened 3 years ago
I try to replicate the CRAN environment. Do your tests run on CRAN?
Perhaps the easiest solution is the converse: to enable your tests only when you detect that the secret envvar is set?
By the way, I see that your INLA package is rejected because the files are too large. Is this intended??
I was refering to the failure in the checklist package. Which is not relevant for CRAN. Hence I was not worring about unit tests passing on CRAN. Would testthat::skip_on_cran()
have the same effect on R-universe as on CRAN?
INLA is not my package, but a package on which some of my packages depend. The INLA repo is a readonly mirror that I created because the source code was not available on GitHub nor CRAN. Probably not on CRAN because of the size. Currently it is available on GitHub so I might points my Remotes
to the orignal GitHub repo. And remove my mirror after some time?
INLA provides binaries on their own CRAN like repo. Is there a Remotes
like way to point to that repo as dependency? Then R-universe (and my users) could use those binaries instead of the source code.
Would testthat::skip_on_cran() have the same effect on R-universe as on CRAN?
Yes that works.
INLA provides binaries on their own CRAN like repo. Is there a Remotes like way to point to that repo as dependency?
Usually remotes would work but in this case it will get blocked as well due to the size.
I'll try to talk to the inla folks, because it seems that the only reason their package is so big is that it includes a lot of unnecessary binaries.
@jeroen I have the same challenge:
Some unit tests in some of my Packages also depend on environment variables.
As part of my continuous integration setup, I have configured a GitHub Action, here is an overview for my R-Package.yaml
:
on:
push:
branches: [main, staging]
pull_request:
branches: [main, staging]
name: R-Package
jobs:
R-Package:
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-latest, r: "release" }
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
DSN: ${{ secrets.DSN }}
DRIVER: ${{ secrets.DRIVER }}
SERVER: ${{ secrets.SERVER }}
DATABASE: ${{ secrets.DATABASE }}
UID: ${{ secrets.UID}}
PWD: ${{ secrets.PWD }}
ENVIRONMENT: "ci"
steps:
- name: Checkout Code Base
uses: actions/checkout@v3
- name: Set up R Environment
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- name: Install Dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- name: Create and Populate .Renviron file
run: |
echo DSN="$DSN" >> ~/.Renviron
echo DRIVER="$DRIVER" >> ~/.Renviron
echo SERVER="$SERVER" >> ~/.Renviron
echo DATABASE="$DATABASE" >> ~/.Renviron
echo UID="$UID" >> ~/.Renviron
echo PWD="$PWD" >> ~/.Renviron
shell: bash
- name: Run Unit Tests
uses: r-lib/actions/check-r-package@v2
with:
You will notice I load some secrets
from GitHub and then later load those secrets
into .Renviron
file.
However, I use the ENVIRONMENT
environment variable to detect which unit test should run when push
or pull_request
on main
in Github.
Since r-universe
also runs checks on the package, which includes running the unit tests, the build will fail as the required environment variables are not set and therefore not found.
Is there an environment variable I can read and use to detect that the unit tests are running on r-universe?
If not, what is the possibility of doing so in the build workflows you run: in your yaml
add the following:
env:
ENVIRONMENT: "r-universe"
I could use such an environment variable to exclude some unit tests. This will resolve the current build issues I am seeing in the logs. This might also help others with similar use cases.
There is an environment variable MY_UNIVERSE
which is always set to the URL of your universe, see here: https://github.com/r-universe/workflows/blob/v1/.github/workflows/build.yml#L10
Also r-universe environment mimics CRAN, so if you use skip_on_cran()
in testthat, those will also be skipped.
But wouldn't it be easier for you to make your tests opt-in, based on the required variables that you set yourself, such as DATABASE
and SERVER
?
@jeroen I see your point, I could set those Environment variables and enable those tests. Thanks anyway for the pointer to the environment Variable I can check for. This will help. Great project by the way! Thanks!
The unit tests for my package fail on R-universe because some environment variables are not set. I'm passing them from GitHub secrets.
Probably the best solution would be to skip these test on R-universe. How can I detect that unit tests are running on R-universe?