New customer prediction: newcustomer.spending
#699
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Following Coverage.yaml | |
# Run tests for every PR and when commiting (push) to development or to the release branch | |
# pull_request: defaults to types [opened, synchronize, reopened] | |
on: | |
pull_request: | |
branches: | |
- '*' | |
push: | |
branches: | |
- 'release**' | |
- 'development' | |
name: testthat-tests | |
permissions: read-all | |
jobs: | |
tests-macos-latest: | |
runs-on: macOS-latest # run on mac for parallel testing | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: devtools, testthat | |
# Unfortunately still needed, despite setup-r-dependencies | |
- name: Install mac system dependencies | |
if: runner.os == 'macOS' | |
run: | | |
brew install gsl | |
- name: Diag output Num CPUS | |
run: sysctl hw.logicalcpu | |
- name: Run tests | |
run: | | |
library(testthat) | |
library(devtools) | |
# Ncpus=1 by default, and takes precedence over TESTTHAT_CPUS env var | |
# set to 3 which is default num cpus on mac GH actions runner | |
options(Ncpus=3) | |
# If on a release branch (name starts with 'release'), | |
# run all tests, including lengthy ones marked with skip_on_ci() | |
if(grepl(pattern = "^release", x = Sys.getenv("GITHUB_HEAD_REF"))){ | |
Sys.setenv(CI="") | |
print("On release branch: Run all tests") | |
}else{ | |
print("Not on release branch: Dont run all tests (skip_on_ci())") | |
} | |
reporter <- RStudioReporter$new() # has to be defined outside capture.output to still print | |
capture.output(devtools::test(reporter = reporter, stop_on_failure=TRUE, stop_on_warning=TRUE)) | |
shell: Rscript {0} |