Skip to content

Update GH Action validation to check internal CITATION.cff YAML #7

Update GH Action validation to check internal CITATION.cff YAML

Update GH Action validation to check internal CITATION.cff YAML #7

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
run: |
yamale -s ./test/metadata_schema.yaml \
-p ruamel \
$(find -iname metadata.yaml)
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)
for(i in seq_along(cff_files)) {
cffr::cff_validate(cff_files[i])
}