-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (62 loc) · 2.26 KB
/
validate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
name: Validate
on: [push] # yamllint disable-line rule:truthy
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: yamllint
uses: ibiqlik/action-yamllint@v3
with:
config_data: |
extends: default
rules:
document-start: disable
empty-lines: disable
trailing-spaces: disable
line-length:
max: 2000
schema-validate-readme:
runs-on: ubuntu-latest
env:
AJV_OPTS: '-c ajv-formats --verbose --coerce-types=array --remove-additional=true --changes'
steps:
- uses: actions/checkout@v4
with:
repository: legumeinfo/datastore-specifications
path: datastore-specifications
- uses: actions/checkout@v4
with:
path: datastore-metadata
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install AJV
run: npm install -g [email protected] [email protected]
- name: Check READMEs
run: ajv ${AJV_OPTS} -s datastore-specifications/readme.schema.json -d '**/README.*.yml'
- name: Check genera
if: always()
run: ajv ${AJV_OPTS} -s datastore-specifications/description_genus.schema.json -d '**/GENUS/about_this_collection/description_*.yml'
- name: Check species
if: always()
run: ajv ${AJV_OPTS} -s datastore-specifications/description_genus_species.schema.json -d 'datastore-metadata/!(LEGUMES)/**/description_*_*.yml'
- name: Install PyYAML
run: |
pip install --no-cache-dir PyYAML
rm -rf datastore-specifications
if: always()
- name: Check identifiers
# ensure <id>/README.<id>.yml contains "identifier: <id>"
if: always()
shell: python {0}
run: |
import sys, pathlib, yaml
if (errpath := [path for path in pathlib.Path(".").rglob("README.*.yml")
if (identifier := path.name.removeprefix("README.").removesuffix(".yml")) != path.parent.name
or identifier != yaml.safe_load(open(path)).get("identifier")]):
sys.exit(errpath)