Fixes bug in as_epiparam()
#219
Workflow file for this run
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: Validate JSONs | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
jobs: | |
validate-json: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
packages: | |
any::jsonlite | |
any::jsonvalidate | |
any::yaml | |
- name: Validate JSON | |
run: | | |
# read in epiparameter database | |
data <- utils::read.csv( | |
file = file.path("inst", "extdata", "parameters.csv"), | |
header = TRUE | |
) | |
# convert cells with arrays to numeric | |
for (i in grep(pattern = "_ci_limits$", x = colnames(data))) { | |
if (!all(is.na(data[[i]]))) { | |
data[[i]] <- lapply( | |
strsplit(x = data[[i]], split = ",", fixed = TRUE), | |
as.numeric | |
) | |
} | |
} | |
data_json <- jsonlite::toJSON( | |
x = data, | |
dataframe = "columns", | |
na = NULL, | |
pretty = TRUE | |
) | |
# read schema | |
schema <- yaml::read_yaml( | |
file.path("inst", "extdata", "data_dictionary.yaml") | |
) | |
schema_json <- jsonlite::toJSON( | |
x = schema, | |
dataframe = "column", | |
auto_unbox = TRUE, | |
pretty = TRUE | |
) | |
jsonvalidate::json_validate( | |
json = data_json, | |
schema = schema_json, | |
engine = "ajv", | |
verbose = TRUE, | |
greedy = TRUE, | |
strict = TRUE, | |
error = TRUE | |
) | |
shell: Rscript {0} |