Compare commits
2 Commits
main
...
fix/ci-val
| Author | SHA1 | Date | |
|---|---|---|---|
| e8f2ecd2ea | |||
| 941cb25cbe |
@@ -112,23 +112,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
- name: Install PyYAML
|
||||||
|
run: pip install pyyaml
|
||||||
- name: Validate playbook structure
|
- name: Validate playbook structure
|
||||||
run: |
|
run: python3 scripts/validate_playbook_schema.py
|
||||||
python3 -c "
|
|
||||||
import yaml, sys, glob
|
|
||||||
required_keys = {'name', 'description'}
|
|
||||||
for f in glob.glob('playbooks/*.yaml'):
|
|
||||||
with open(f) as fh:
|
|
||||||
try:
|
|
||||||
data = yaml.safe_load(fh)
|
|
||||||
if not isinstance(data, dict):
|
|
||||||
print(f'ERROR: {f} is not a YAML mapping')
|
|
||||||
sys.exit(1)
|
|
||||||
missing = required_keys - set(data.keys())
|
|
||||||
if missing:
|
|
||||||
print(f'WARNING: {f} missing keys: {missing}')
|
|
||||||
print(f'OK: {f}')
|
|
||||||
except yaml.YAMLError as e:
|
|
||||||
print(f'ERROR: {f}: {e}')
|
|
||||||
sys.exit(1)
|
|
||||||
"
|
|
||||||
|
|||||||
22
scripts/validate_playbook_schema.py
Normal file
22
scripts/validate_playbook_schema.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Validate playbook YAML files have required keys."""
|
||||||
|
import yaml
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
|
||||||
|
required_keys = {'name', 'description'}
|
||||||
|
|
||||||
|
for f in glob.glob('playbooks/*.yaml'):
|
||||||
|
with open(f) as fh:
|
||||||
|
try:
|
||||||
|
data = yaml.safe_load(fh)
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
print(f'ERROR: {f} is not a YAML mapping')
|
||||||
|
sys.exit(1)
|
||||||
|
missing = required_keys - set(data.keys())
|
||||||
|
if missing:
|
||||||
|
print(f'WARNING: {f} missing keys: {missing}')
|
||||||
|
print(f'OK: {f}')
|
||||||
|
except yaml.YAMLError as e:
|
||||||
|
print(f'ERROR: {f}: {e}')
|
||||||
|
sys.exit(1)
|
||||||
Reference in New Issue
Block a user