diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c4978c7..2b08ed71 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,21 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - name: Check apps.json run: | - python -m json.tool apps.json + jq apps.json + - name: Check all working apps have consistent app id / app url + run: | + for LINE in $(cat apps.json | jq -r 'to_entries[] | select ( .value.state=="working" ) | "\(.key)|\(.value.url)"') + do + APP=$(echo $LINE | awk -F'|' '{print $1}') + URL_END=$(echo $LINE | awk -F'/' '{print $NF}') + [ "$APP" == "$(echo $APP | tr [A-Z] [a-z])" ] || echo "$APP : app id should be lowercase" >&2 + [ "$URL_END" == "${APP}_ynh" ] || echo "$APP : the url should end with ${APP}_ynh" >&2 + done + + - name: Check all working apps have a category + run: | + jq -e -r '.[] | select ( .state=="working" ) | select ( has("category") | not )' apps.json + [ $? -eq 4 ] || echo "Some working applications don't have their category defined ?" >&2 + diff --git a/check_id_unicity.py b/check_id_unicity.py deleted file mode 100644 index faee5a1c..00000000 --- a/check_id_unicity.py +++ /dev/null @@ -1,54 +0,0 @@ -import sys -import json -import requests - - -def get_json(url, verify=True, token=None): - - try: - # Retrieve and load manifest - if ".github" in url: - r = requests.get(url, verify=verify, auth=token) - else: - r = requests.get(url, verify=verify) - r.raise_for_status() - return r.json() - except requests.exceptions.RequestException as e: - print("-> Error: unable to request %s, %s" % (url, e)) - return None - except ValueError as e: - print("-> Error: unable to decode JSON from %s : %s" % (url, e)) - return None - - -def main(apps): - for app_id, app_data in apps.items(): - url = app_data["url"] - if app_data.get("state") != "working": - continue - github_repo_name = url.split("/")[-1].replace("_ynh", "") - - if app_id != github_repo_name: - print("[%s] GitHub repo name is not coherent with app id: '%s' vs '%s' (%s)" % (app_id, app_id, url.split("/")[-1], url)) - - owner, repo_name = url.split("/")[-2:] - - raw_url = "https://raw.githubusercontent.com/%s/%s/%s/manifest.json" % ( - owner, repo_name, app_data.get("branch", "master") - ) - - manifest = get_json(raw_url) - - if manifest is None: - continue - - manifest_id = manifest["id"] - if app_id != manifest_id: - print("[%s] manifest id is different from app id: '%s' vs '%s' (manifest_id" % (app_id, app_id, manifest_id)) - - if manifest_id != github_repo_name: - print("[%s] manifest id is different from GitHub repo name: '%s' vs '%s' (%s)" % (app_id, manifest_id, url.split("/")[-1], url)) - - -if __name__ == '__main__': - main(json.load(open("apps.json")))