Skip to content

Commit

Permalink
Add YAML validation workflow and schema definition (#1)
Browse files Browse the repository at this point in the history
* Add YAML validation workflow and schema definition

* Remove useless category for providers schema

* Add Massa Labs provider

* Fix wrong providers files paths in validate workflow

* Fix schema and add regex validation for URL and contact fields

* Update workflow to use Ubuntu 22.04 for YAML validation

* Add workflow to consolidate YAML files and upload as artifact
  • Loading branch information
thomas-senechal authored Nov 19, 2024
1 parent f481e01 commit e9124ee
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/consolidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Consolidate YAML Files

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
consolidate_yaml:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Consolidate YAML files
uses: mikefarah/yq@v4
with:
cmd: yq eval-all '. as $item ireduce ([]; . + [$item])' providers/*.yaml > providers.yaml

- name: Upload providers.yaml as artifact
uses: actions/upload-artifact@v4
with:
path: providers.yaml

- name: Commit and push consolidated file
if: github.ref == 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Auto-update providers.yaml"
file_pattern: providers.yaml
24 changes: 24 additions & 0 deletions .github/workflows/validate_yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Validate providers YAMLs

on:
pull_request:
paths:
- 'providers/**/*.yaml'

jobs:
validate_yaml:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Yamale
run: |
pip install yamale
- name: Validate YAML against schema
run: |
for file in providers/*.yaml; do
yamale -s schema.yaml "$file" || exit 1
done
10 changes: 10 additions & 0 deletions providers/MassaLabs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Massa Labs Official Provider

url: https://massa.network/

desc: The Official DeWeb Provider hosted by Massa Labs. Only allows access to officials Massa websites and some partner websites.

owner: Massa Labs

contact:
email: contact@massa.net
9 changes: 9 additions & 0 deletions schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: str(required=True)
url: str(required=True, regex='^https?://[\\w.-]+(?:\\.[\\w\\.-]+)+[/\\w\\.-]*$')
desc: str(required=True)
owner: str(required=True)
contact: map(required=True)
contact:
email: str(required=False, regex='^[\\w\\.-]+@[\\w\\.-]+\\.[a-zA-Z]{2,}$')
discord: str(required=False, regex='^@\\w{2,32}#\\d{4}$')
telegram: str(required=False, regex='^@\\w{5,32}$')

0 comments on commit e9124ee

Please sign in to comment.