From cee3b19b64ef088edd2c96597cea8e6dfc96404e Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 13:49:31 +0100 Subject: [PATCH 1/7] Add YAML validation workflow and schema definition --- .github/workflows/validate_yaml.yml | 24 ++++++++++++++++++++ schema.yaml | 35 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/validate_yaml.yml create mode 100644 schema.yaml diff --git a/.github/workflows/validate_yaml.yml b/.github/workflows/validate_yaml.yml new file mode 100644 index 0000000..ad723af --- /dev/null +++ b/.github/workflows/validate_yaml.yml @@ -0,0 +1,24 @@ +name: Validate providers YAMLs + +on: + pull_request: + paths: + - 'entries/**/*.yaml' + +jobs: + validate_yaml: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Yamale + run: | + pip install yamale + + - name: Validate YAML against schema + run: | + for file in entries/*.yaml; do + yamale -s schema.yaml "$file" || exit 1 + done diff --git a/schema.yaml b/schema.yaml new file mode 100644 index 0000000..4684c75 --- /dev/null +++ b/schema.yaml @@ -0,0 +1,35 @@ +title: + type: str + required: True + +url: + type: str + required: True + +desc: + type: str + required: True + +owner: + type: str + required: True + +contact: + type: map + required: True + schema: + email: + type: str + required: False + discord: + type: str + required: False + telegram: + type: str + required: False + +category: + type: list + required: True + schema: + type: str From d7d4a25ebce17a9f0625ca1534bc8faecd69f16d Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 13:54:08 +0100 Subject: [PATCH 2/7] Remove useless category for providers schema --- schema.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/schema.yaml b/schema.yaml index 4684c75..9d411e1 100644 --- a/schema.yaml +++ b/schema.yaml @@ -27,9 +27,3 @@ contact: telegram: type: str required: False - -category: - type: list - required: True - schema: - type: str From 6b2e2c7c07f6ded855700a04c0e9aabcedd1ce7d Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 13:54:29 +0100 Subject: [PATCH 3/7] Add Massa Labs provider --- providers/MassaLabs.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 providers/MassaLabs.yaml diff --git a/providers/MassaLabs.yaml b/providers/MassaLabs.yaml new file mode 100644 index 0000000..9c1c78c --- /dev/null +++ b/providers/MassaLabs.yaml @@ -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 From 0142d5e8ef701e6a5c092837ccdd436dc0907194 Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 13:56:48 +0100 Subject: [PATCH 4/7] Fix wrong providers files paths in validate workflow --- .github/workflows/validate_yaml.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_yaml.yml b/.github/workflows/validate_yaml.yml index ad723af..be9f11a 100644 --- a/.github/workflows/validate_yaml.yml +++ b/.github/workflows/validate_yaml.yml @@ -3,7 +3,7 @@ name: Validate providers YAMLs on: pull_request: paths: - - 'entries/**/*.yaml' + - 'providers/**/*.yaml' jobs: validate_yaml: @@ -19,6 +19,6 @@ jobs: - name: Validate YAML against schema run: | - for file in entries/*.yaml; do + for file in providers/*.yaml; do yamale -s schema.yaml "$file" || exit 1 done From cc89734b072d31e1245e3d8bec34205b70f47b57 Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 14:45:24 +0100 Subject: [PATCH 5/7] Fix schema and add regex validation for URL and contact fields --- schema.yaml | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/schema.yaml b/schema.yaml index 9d411e1..bd0b6b8 100644 --- a/schema.yaml +++ b/schema.yaml @@ -1,29 +1,9 @@ -title: - type: str - required: True - -url: - type: str - required: True - -desc: - type: str - required: True - -owner: - type: str - required: True - +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: - type: map - required: True - schema: - email: - type: str - required: False - discord: - type: str - required: False - telegram: - type: str - required: False + 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}$') From 2db2c2fa99617c4da03a7f5b1c7f46021cfb2cdd Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 14:52:48 +0100 Subject: [PATCH 6/7] Update workflow to use Ubuntu 22.04 for YAML validation --- .github/workflows/validate_yaml.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_yaml.yml b/.github/workflows/validate_yaml.yml index be9f11a..482ccef 100644 --- a/.github/workflows/validate_yaml.yml +++ b/.github/workflows/validate_yaml.yml @@ -7,7 +7,7 @@ on: jobs: validate_yaml: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout code From 37272c8ac030524db3be08e4e3d40baa3d470189 Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Mon, 18 Nov 2024 21:54:47 +0100 Subject: [PATCH 7/7] Add workflow to consolidate YAML files and upload as artifact --- .github/workflows/consolidate.yml | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/consolidate.yml diff --git a/.github/workflows/consolidate.yml b/.github/workflows/consolidate.yml new file mode 100644 index 0000000..998b186 --- /dev/null +++ b/.github/workflows/consolidate.yml @@ -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