Skip to content

Add scheduled CI workflow to detect and fix the plugin entry issue #310

@unkcpz

Description

@unkcpz

ok updated, when converting to GHA, we don't need that uglyKEYcheck anymore. so i don't bring it here.

import yaml
import requests
from uglyKEYcheck import search_in_url

maindomain = "https://aiidateam.github.io/aiida-registry/"

def load_yaml_file(file_path):
    with open(file_path, 'r') as file:
        return yaml.safe_load(file)

def save_yaml_file(file_path, data):
    with open(file_path, 'w') as file:
        yaml.safe_dump(data, file, sort_keys=False)

def check_if_toml(url):
    new_url = '/'.join(url.split('/')[:-1]) + '/pyproject.toml'
    response = requests.head(new_url, timeout=10)
    if response.status_code == 404:
        return None
    else:
        return new_url

def check_urls(data):
    updates = False
    for plugin, info in data.items():
        url = info.get("plugin_info")
        if url:
            try:
                response = requests.get(url, allow_redirects=True)
                if response.status_code == 404:
                    new_url = check_if_toml(url)
                    if new_url:
                        print(f"{plugin}: returned a 404 status. But *pyproject.toml* detected!")
                        if search_in_url(maindomain+plugin, 'W002'):
                            data[plugin]["plugin_info"] = new_url
                            updates = True
                            print(plugin, ' updated')
                    else:
                        print(f"{plugin}: returned a 404 status. No *pyproject.toml* detected.")
                else:
                    pass
            except requests.RequestException as e:
                print(f"Error checking {plugin}: {url}. Error: {e}")
    return updates

yaml_file_path = 'plugins.yaml'

data = load_yaml_file(yaml_file_path)
if check_urls(data):
    save_yaml_file('plugins-out.yaml', data)
    print("YAML file updated.")

Originally posted by @khsrali in #309 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions