Skip to content

Commit e2c55ab

Browse files
authored
Merge pull request #6 from caviddhen/main
update for workshop 2024
2 parents 08317b7 + a474bb9 commit e2c55ab

11 files changed

Lines changed: 65 additions & 101 deletions

.buildlibrary

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
ValidationKey: '4105710'
1+
ValidationKey: '4182653'
22
AcceptedWarnings:
33
- 'Warning: package ''.*'' was built under R version'
44
- 'Warning: namespace ''.*'' is not available and has been replaced'
55
AcceptedNotes: ~
66
AutocreateReadme: yes
77
allowLinterWarnings: yes
8+
enforceVersionUpdate: no

.github/workflows/check.yaml

Lines changed: 30 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Run CI for R using https://eddelbuettel.github.io/r-ci/
2-
31
name: check
42

53
on:
@@ -8,96 +6,53 @@ on:
86
pull_request:
97
branches: [main, master]
108

11-
env:
12-
USE_BSPM: "true"
13-
_R_CHECK_FORCE_SUGGESTS_: "false"
14-
NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")'
15-
169
jobs:
1710
check:
1811
runs-on: ubuntu-latest
1912

2013
steps:
21-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
2215

23-
- name: Bootstrap
24-
run: |
25-
sudo chown runner -R .
26-
sudo locale-gen en_US.UTF-8
27-
sudo add-apt-repository -y ppa:ubuntugis/ppa
28-
curl -OLs https://eddelbuettel.github.io/r-ci/run.sh
29-
chmod 0755 run.sh
30-
./run.sh bootstrap
31-
rm -f bspm_*.tar.gz
32-
33-
- name: Enable r-universe repo, modify bspm integration
34-
run: |
35-
# install packages from https://pik-piam.r-universe.dev and CRAN
36-
echo '
37-
options(repos = c(universe = "https://pik-piam.r-universe.dev",
38-
CRAN = "https://cloud.r-project.org"))
39-
' >> .Rprofile
40-
cat .Rprofile
41-
# modify bspm integration to never install binary builds of PIK CRAN packages
42-
sudo sed -i '/bspm::enable()/d' /etc/R/Rprofile.site
43-
# need double % because of printf, %s is replaced with "$NO_BINARY_INSTALL_R_PACKAGES" (see "env:" above)
44-
printf '
45-
local({
46-
expr <- quote({
47-
if (!is.null(repos)) {
48-
noBinaryInstallRPackages <- %s
49-
pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]),
50-
pkgs[pkgs %%in%% noBinaryInstallRPackages])
51-
}
52-
type <- "source"
53-
})
54-
trace(utils::install.packages, expr, print = FALSE)
55-
})
56-
' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null
57-
cat /etc/R/Rprofile.site
16+
- uses: r-lib/actions/setup-pandoc@v2
5817

59-
- name: Set up Pandoc
60-
uses: r-lib/actions/setup-pandoc@v2
61-
62-
- name: Set up Python 3.9
63-
uses: actions/setup-python@v4
18+
- uses: r-lib/actions/setup-r@v2
6419
with:
65-
python-version: 3.9
20+
use-public-rspm: true
21+
extra-repositories: "https://rse.pik-potsdam.de/r/packages"
6622

67-
- name: Cache R libraries
68-
if: ${{ !env.ACT }} # skip when running locally via nektos/act
69-
uses: pat-s/always-upload-cache@v3
23+
- uses: r-lib/actions/setup-r-dependencies@v2
7024
with:
71-
path: /usr/local/lib/R/
72-
key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }}
73-
restore-keys: |
74-
3-${{ runner.os }}-usr-local-lib-R-
75-
76-
- name: Restore R library permissions
77-
run: |
78-
sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library
79-
80-
- name: Install dependencies
81-
run: |
82-
./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev
83-
./run.sh install_all
84-
./run.sh install_r_binary covr rstudioapi
85-
./run.sh install_r lucode2
25+
extra-packages: |
26+
any::lucode2
27+
any::covr
28+
any::madrat
29+
any::magclass
30+
any::citation
31+
any::gms
32+
any::goxygen
33+
any::GDPuc
34+
# piam packages also available on CRAN (madrat, magclass, citation,
35+
# gms, goxygen, GDPuc) will usually have an outdated binary version
36+
# available; by using extra-packages we get the newest version
37+
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: 3.9
8641

8742
- name: Install python dependencies if applicable
8843
run: |
8944
[ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true
9045
[ -f requirements.txt ] && pip install -r requirements.txt || true
9146
92-
- name: Remove bspm integration # to get rid of error when running install.packages
93-
run: |
94-
sudo sed -i '/ trace(utils::install.packages, expr, print = FALSE)/d' /etc/R/Rprofile.site
95-
cat /etc/R/Rprofile.site
96-
9747
- name: Verify validation key
9848
shell: Rscript {0}
9949
run: lucode2:::validkey(stopIfInvalid = TRUE)
10050

51+
- name: Verify that lucode2::buildLibrary was successful
52+
if: github.event_name == 'pull_request'
53+
shell: Rscript {0}
54+
run: lucode2:::isVersionUpdated()
55+
10156
- name: Checks
10257
shell: Rscript {0}
10358
run: |
@@ -106,6 +61,8 @@ jobs:
10661
10762
- name: Test coverage
10863
shell: Rscript {0}
109-
run: covr::codecov(quiet = FALSE)
64+
run: |
65+
nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps"))
66+
if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE)
11067
env:
11168
NOT_CRAN: "true"

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exclude: '^tests/testthat/_snaps/.*$'
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.4.0
6+
rev: v4.5.0
77
hooks:
88
- id: check-case-conflict
99
- id: check-json
@@ -15,7 +15,7 @@ repos:
1515
- id: mixed-line-ending
1616

1717
- repo: https://github.com/lorenzwalthert/precommit
18-
rev: v0.3.2.9013
18+
rev: v0.4.0
1919
hooks:
2020
- id: parsable-R
2121
- id: deps-in-desc

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ cff-version: 1.2.0
22
message: If you use this software, please cite it using the metadata from this file.
33
type: software
44
title: 'mrtutorial: Tutorial Package For Madrat Package Library'
5-
version: 0.2.10
6-
date-released: '2023-07-13'
5+
version: 0.2.11
6+
date-released: '2024-04-10'
77
abstract: 'Example package of mr- world libraries, in conjunction with MAgPIE MADRat
88
tutorial. For more information please see: https://github.com/magpiemodel/tutorials/tree/master/madrat
99
.'

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: mrtutorial
33
Title: Tutorial Package For Madrat Package Library
4-
Version: 0.2.10
5-
Date: 2023-07-13
4+
Version: 0.2.11
5+
Date: 2024-04-10
66
Authors@R:
77
person("David Meng-Chuen", "Chen", , "david.chen@pik-potsdam.de", role = c("aut", "cre"))
88
Description: Example package of mr- world libraries, in conjunction with

R/downloadTutorialWDI.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ downloadTutorialWDI<-function(){
1919
"NV.AGR.TOTL.CD") # Ag GDP current US$
2020
wdi <- WDI(indicator = indicator,start= 1960, end = 2018)
2121
save(wdi,file = paste("WDI","rda",sep="."))
22-
22+
2323
return(list(url = "https://data.worldbank.org/indicator/",
2424
doi = NULL,
2525
title = "World Bank Development Indicators",
2626
description = "GDP and Population indicators",
2727
author = NULL,
28+
license = NULL,
2829
unit = NULL))
29-
30+
3031
}

R/imports.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Generated by lucode2: do not edit by hand
22

3-
#' @import magclass madrat
3+
#' @import madrat magclass
44
NULL

R/readTutorialWDI.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@
2222
#' @importFrom magclass as.magpie
2323
#' @importFrom rlang .data
2424

25-
readTutorialWDI<-function(subtype){
25+
readTutorialWDI<-function(subtype = "SP.POP.TOTL"){
2626

2727
load("WDI.rda")
2828

29-
#convert the iso2c to iso3c using madrat tool
30-
wdi$iso2c <- toolCountry2isocode(wdi$iso2c)
31-
29+
#clean up: remove other country ids, remove rows with NAs as country,
30+
#pivot to long format and convert to magclass object
3231
wdi <- wdi %>%
33-
dplyr::select(!.data$country) %>%
34-
filter(!is.na(.data$iso2c)) %>%
35-
pivot_longer(cols=3:6) %>%
32+
dplyr::select(!c(.data$country, .data$iso2c)) %>%
33+
filter(!is.na(.data$iso3c), .data$iso3c != "") %>%
34+
pivot_longer(cols = c("NY.GDP.MKTP.CD", "SP.POP.TOTL",
35+
"SL.AGR.EMPL.ZS", "NV.AGR.TOTL.CD"),
36+
names_to = "variable") %>%
3637
as.magpie(spatial = 1, temporal = 2, replacement =".")
3738

38-
wdi <- wdi[,,subtype]
39+
#select the subtype
40+
wdi <- wdi[, , subtype]
3941

4042
getNames(wdi) <- gsub("\\.", "_", getNames(wdi))
4143
# Replacement of . with _ in dimension is also done automatically in as.magpie()

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Tutorial Package For Madrat Package Library
22

3-
R package **mrtutorial**, version **0.2.10**
3+
R package **mrtutorial**, version **0.2.11**
44

5-
[![CRAN status](https://www.r-pkg.org/badges/version/mrtutorial)](https://cran.r-project.org/package=mrtutorial) [![R build status](https://github.com/whitehacker/mrtutorial/workflows/check/badge.svg)](https://github.com/whitehacker/mrtutorial/actions) [![codecov](https://codecov.io/gh/whitehacker/mrtutorial/branch/master/graph/badge.svg)](https://app.codecov.io/gh/whitehacker/mrtutorial) [![r-universe](https://pik-piam.r-universe.dev/badges/mrtutorial)](https://pik-piam.r-universe.dev/builds)
5+
[![CRAN status](https://www.r-pkg.org/badges/version/mrtutorial)](https://cran.r-project.org/package=mrtutorial) [![R build status](https://github.com/caviddhen/mrtutorial/workflows/check/badge.svg)](https://github.com/caviddhen/mrtutorial/actions) [![codecov](https://codecov.io/gh/caviddhen/mrtutorial/branch/master/graph/badge.svg)](https://app.codecov.io/gh/caviddhen/mrtutorial) [![r-universe](https://pik-piam.r-universe.dev/badges/mrtutorial)](https://pik-piam.r-universe.dev/builds)
66

77
## Purpose and Functionality
88

9-
Example package of mr- world libraries, in conjunction with MAgPIE MADRat tutorial. For more information please see: https://github.com/magpiemodel/tutorials/tree/master/madrat .
9+
Example package of mr- world libraries, in conjunction with
10+
MAgPIE MADRat tutorial. For more information please see:
11+
https://github.com/magpiemodel/tutorials/tree/master/madrat .
1012

1113

1214
## Installation
@@ -38,15 +40,15 @@ In case of questions / problems please contact David Meng-Chuen Chen <david.chen
3840

3941
To cite package **mrtutorial** in publications use:
4042

41-
Chen D (2023). _mrtutorial: Tutorial Package For Madrat Package Library_. R package version 0.2.10.
43+
Chen D (2024). _mrtutorial: Tutorial Package For Madrat Package Library_. R package version 0.2.11.
4244

4345
A BibTeX entry for LaTeX users is
4446

4547
```latex
4648
@Manual{,
4749
title = {mrtutorial: Tutorial Package For Madrat Package Library},
4850
author = {David Meng-Chuen Chen},
49-
year = {2023},
50-
note = {R package version 0.2.10},
51+
year = {2024},
52+
note = {R package version 0.2.11},
5153
}
5254
```

man/fullTUTORIAL.Rd

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)