Skip to content

...

... #1

name: Plugin Validation
on:
pull_request:
paths:
- 'data/**'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install jsonschema pyyaml bandit ruff coverage pytest
- name: Validate Plugin Structure
run: |
for plugin_dir in data/*/; do
if [ -d "$plugin_dir" ]; then
echo "Validating $plugin_dir..."
# Check manifest.json
if [ ! -f "$plugin_dir/manifest.json" ]; then
echo "Error: manifest.json missing in $plugin_dir"
exit 1
fi
# Check required manifest fields
python3 -c "import json, sys; m = json.load(open('$plugin_dir/manifest.json')); req = ['id', 'name', 'version', 'description', 'author', 'dependencies']; missing = [f for f in req if f not in m]; sys.exit(f'Missing {missing}') if missing else sys.exit(0)" || exit 1
# Check entry point
ENTRY_POINT=$(python3 -c "import json; print(json.load(open('$plugin_dir/manifest.json')).get('entry_point', 'plugin.weeb'))")
if [ ! -f "$plugin_dir/$ENTRY_POINT" ]; then
echo "Error: Entry point $ENTRY_POINT missing in $plugin_dir"
exit 1
fi
# Check README.md
if [ ! -f "$plugin_dir/README.md" ]; then
echo "Error: README.md missing in $plugin_dir"
exit 1
fi
# Check screenshots dir
if [ ! -d "$plugin_dir/screenshots" ] || [ -z "$(ls -A $plugin_dir/screenshots)" ]; then
echo "Error: screenshots directory missing or empty in $plugin_dir"
exit 1
fi
fi
done
- name: Security Scan (Bandit)
run: |
bandit -r data/
- name: Linting (Ruff)
run: |
ruff check data/
- name: Run Tests & Check Coverage
run: |
# We check if there are tests, run them, and ensure 80% coverage
for plugin_dir in data/*/; do
if [ -d "$plugin_dir" ] && [ -d "$plugin_dir/tests" ]; then
echo "Running tests for $plugin_dir"
coverage run -m pytest $plugin_dir/tests/
coverage report --fail-under=80
fi
done
- name: Validation Successful
run: echo "Plugin validation passed!"