Packaging now works. Updated the DESCRIPTION #67
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
name: "Unit tests: macOS" | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
test: | |
name: tests on macOS with R ${{ matrix.R }} | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
R: ['4.1.0'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.R }} | |
Ncpus: 2 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Query dependencies | |
run: | | |
install.packages('remotes') | |
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | |
shell: Rscript {0} | |
- name: cache R installed packages | |
uses: actions/cache@v2 | |
id: cache | |
with: | |
path: | | |
${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-R${{ matrix.R }}-2-${{ hashFiles('.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-R${{ matrix.R }}-2- | |
- name: Install packages | |
run: | | |
install.packages(c("devtools")) | |
remotes::install_deps(dependencies = TRUE) | |
remotes::install_cran("rcmdcheck") | |
shell: Rscript {0} | |
- name: setup r-reticulate venv | |
shell: Rscript {0} | |
run: | | |
library(reticulate) | |
reticulate::py_run_string(" | |
import sys | |
import subprocess | |
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip']) | |
") | |
# Install required packages | |
reticulate::py_run_string(" | |
import sys | |
import subprocess | |
# Install basic packages | |
packages = ['numpy', 'pandas', 'matplotlib'] | |
for package in packages: | |
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', package]) | |
# Install pyEpiabm from GitHub | |
subprocess.check_call([ | |
sys.executable, '-m', 'pip', 'install', '--upgrade', | |
'git+https://github.com/SABS-R3-Epidemiology/epiabm.git@main#egg=pyEpiabm&subdirectory=pyEpiabm' | |
]) | |
") | |
env_name <- "r-py-env" | |
python_version = "3.9" | |
tryCatch({ | |
# Check if virtualenv package is available | |
if (!reticulate::virtualenv_exists(env_name)) { | |
message(sprintf("Creating new Python virtual environment: %s", env_name)) | |
# Create virtual environment with system site packages to help with SSL | |
reticulate::virtualenv_create( | |
envname = env_name, | |
version = python_version, | |
packages = "pip", | |
system_site_packages = TRUE | |
) | |
} | |
# Activate the environment | |
reticulate::use_virtualenv(env_name, required = TRUE) | |
return(TRUE) | |
}, error = function(e) { | |
warning(sprintf("Failed to create/activate Python environment: %s", e$message)) | |
return(FALSE) | |
}) | |
- name: Check | |
env: | |
_R_CHECK_CRAN_INCOMING_REMOTE_: false | |
run: | | |
options(crayon.enabled = TRUE) | |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check") | |
shell: Rscript {0} | |
- name: Show testthat output | |
if: always() | |
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true | |
shell: bash |