Add HTI model 291; adjust metadata schema; allow failed CFF validation to error #17
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 metadata | |
on: | |
push: | |
paths: | |
- '**metadata.ya?ml' | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
yamale-validate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Yamale | |
run: "pip install yamale" | |
- name: Install ruamel | |
run: | | |
pip install ruamel.yaml \ | |
pip install ruamel.yaml.cmd | |
- name: Run Yamale on ./raw | |
run: | | |
yamale -s ./schemas/raw_schema.yaml \ | |
-p ruamel ./raw | |
cff-validate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- name: Set up R packages | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
packages: | |
any::yaml | |
any::cffr | |
- name: Validate citation | |
shell: Rscript {0} | |
run: | | |
dir.create(file.path(tempdir(), 'cff')) | |
files <- list.files(pattern = '^metadata\\.yaml$', recursive = TRUE, full.names = TRUE) | |
for(i in seq_along(files)){ | |
parsed_yaml <- yaml::read_yaml(files[i], readLines.warn = FALSE) | |
parsed_yaml$citation.cff |> | |
yaml::write_yaml( | |
file.path( | |
tempdir(), | |
'cff', | |
paste0( | |
gsub('[\\. ]', '_', parsed_yaml$name), | |
'.cff') | |
) | |
) | |
} | |
cff_files <- list.files(file.path(tempdir(), 'cff'), full.names = T) | |
validation_result <- vector("logical", length(cff_files)) | |
for(i in seq_along(cff_files)) { | |
validation_result[i] <- cffr::cff_validate(cff_files[i]) | |
} | |
if(!all(validation_result)) stop('Invalid cff detected.') |