-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec6e831
commit 26c7106
Showing
2 changed files
with
207 additions
and
41 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: "Set up pharmr" | ||
description: "Set up pharmr" | ||
inputs: | ||
as-release: | ||
description: "Whether to use latest dev branch or latest tag" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: "release" | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- name: Query dependencies | ||
working-directory: pharmr_repo | ||
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} | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Restore R package cache | ||
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 | ||
working-directory: pharmr_repo | ||
if: runner.os == 'Linux' | ||
run: | | ||
while read -r cmd | ||
do | ||
eval sudo $cmd | ||
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') | ||
sudo apt install libcurl4-openssl-dev | ||
- name: Install png (temporary) | ||
working-directory: pharmr_repo | ||
if: runner.os == 'Windows' | ||
run: | | ||
install.packages('png', repos='https://mran.microsoft.com/snapshot/2022-11-27') | ||
shell: Rscript {0} | ||
|
||
- name: Install R packages | ||
working-directory: pharmr_repo | ||
run: | | ||
remotes::install_deps(dependencies = TRUE) | ||
remotes::install_cran("rcmdcheck") | ||
install.packages('reticulate') | ||
install.packages('devtools') | ||
install.packages('promises') | ||
remotes::install_local(force=TRUE) | ||
shell: Rscript {0} | ||
|
||
- name: Checkout Pharmpy | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: pharmpy/pharmpy | ||
path: pharmpy_repo | ||
fetch-depth: 0 | ||
|
||
- name: Set up Pharmpy release version | ||
working-directory: pharmpy_repo | ||
if: ${{ inputs.as-release == true }} | ||
run: | | ||
git checkout -b release_latest "$(git rev-list --tags --max-count=1)" | ||
- id: get_pharmpy_version | ||
working-directory: pharmpy_repo | ||
if: ${{ inputs.as-release == true && runner.os == 'Linux'}} | ||
run: | | ||
echo "pharmpy_version=`git describe --tags`" >> $GITHUB_OUTPUT | ||
- name: Install Pharmpy in venv | ||
working-directory: pharmpy_repo | ||
if: runner.os != 'Windows' | ||
run: | | ||
python3 -m venv pharmpy_venv | ||
source pharmpy_venv/bin/activate | ||
pip install . | ||
- name: Install Pharmpy in venv | ||
working-directory: pharmpy_repo | ||
if: runner.os == 'Windows' | ||
run: | | ||
python -m venv pharmpy_venv | ||
pharmpy_venv\Scripts\activate | ||
pip install . | ||
- name: Start Pharmpy venv | ||
working-directory: pharmr_repo | ||
run: | | ||
reticulate::py_discover_config() | ||
venv_path = file.path('..', 'pharmpy_repo', 'pharmpy_venv') | ||
if(.Platform$OS.type == "unix") { | ||
venv_path = file.path(venv_path, 'bin') | ||
} else { | ||
venv_path = file.path(venv_path, 'Scripts') | ||
} | ||
reticulate::use_python(venv_path) | ||
pharmr::print_pharmpy_version() | ||
shell: Rscript {0} | ||
|
||
- name: Update DESCRIPTION and documentation | ||
working-directory: pharmr_repo/deploy | ||
run: | | ||
venv_path = file.path('..', '..', 'pharmpy_repo', 'pharmpy_venv') | ||
if(.Platform$OS.type == "unix") { | ||
venv_path = file.path(venv_path, 'bin') | ||
} else { | ||
venv_path = file.path(venv_path, 'Scripts') | ||
} | ||
reticulate::use_python(venv_path) | ||
pharmpy <- reticulate::import("pharmpy") | ||
pharmpy_version <- pharmpy$`__version__` | ||
desc::desc_set('Version', pharmpy_version) | ||
desc::desc_set('Date', Sys.Date()) | ||
reticulate::py_run_file('build_functions.py') | ||
devtools::document() | ||
shell: Rscript {0} | ||
|
||
- name: Check pharmr | ||
working-directory: pharmr_repo | ||
env: | ||
_R_CHECK_CRAN_INCOMING_REMOTE_: false | ||
run: | | ||
venv_path = file.path('..', 'pharmpy_repo', 'pharmpy_venv') | ||
if(.Platform$OS.type == "unix") { | ||
venv_path = file.path(venv_path, 'bin') | ||
} else { | ||
venv_path = file.path(venv_path, 'Scripts') | ||
} | ||
reticulate::use_python(venv_path) | ||
pharmr::print_pharmpy_version() | ||
options(crayon.enabled = TRUE) | ||
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") | ||
rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check") | ||
shell: Rscript {0} | ||
|
||
- name: Upload check results | ||
if: failure() | ||
uses: actions/upload-artifact@main | ||
with: | ||
name: results-cran | ||
path: check |
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