mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
Get rid of check_id_unicity ... implement the check url<->appid consistency check using jq, the manifest id check is already handled by the linter
This commit is contained in:
parent
8e8b9a1594
commit
998273f926
2 changed files with 16 additions and 59 deletions
21
.github/workflows/main.yml
vendored
21
.github/workflows/main.yml
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -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")))
|
Loading…
Add table
Reference in a new issue