Add preflight (#490)

* Add preflight

* fix syntax

* move check

* get event

* print

* return event

* use path

* tt

* move to helper

* add issue_comment

* remove should run

* check owner

* add more information to the logs

* test

* add finished

* move keys

* Update errors

* remove repo

* fix JQ run

* filter
This commit is contained in:
Joakim Sørensen
2020-05-28 16:53:45 +02:00
committed by GitHub
parent 51639d6624
commit 9e8788c060
19 changed files with 135 additions and 89 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ async def check():
repo = repository.attributes
if repo["archived"]:
exit("Repository is archived")
exit("::error::Repository is archived")
if __name__ == "__main__":
+1 -1
View File
@@ -29,7 +29,7 @@ async def check():
files = await repository.get_contents("custom_integrations")
if domain not in [x.attributes["name"] for x in files]:
exit(
f"{domain} is not added to https://github.com/home-assistant/brands, "
f"::error::{domain} is not added to https://github.com/home-assistant/brands, "
+ "this is needed to ensure the best possible experience for the user"
)
else:
+14
View File
@@ -0,0 +1,14 @@
from scripts.helpers.event import get_event
def check():
event = get_event()
labels = event.get("pull_request", {}).get("labels", [])
for label in labels:
if label["name"] == "Not finished":
exit("::error::Pull request is not ready for CI runs")
if __name__ == "__main__":
check()
+1 -1
View File
@@ -17,7 +17,7 @@ async def check():
repo = repository.attributes
if repo["fork"]:
exit(78)
print("::warning:: {repo} is a fork")
if __name__ == "__main__":
+3 -1
View File
@@ -9,10 +9,12 @@ def check():
return
manifest = get_hacs_manifest()
fail = "::error::Missing required value for key '{key}' in {path}"
path = "hacs.json"
issues = []
if manifest.get("name") is None:
issues.append("No name")
issues.append(fail.format(key="name", path=path))
if issues:
for issue in issues:
+1 -2
View File
@@ -13,8 +13,7 @@ def check():
print("Has image(s)")
return
print("There should be images to show the user what they get.")
exit(1)
exit("::error::There should be images to show the user what they get.")
if __name__ == "__main__":
+1 -3
View File
@@ -6,9 +6,7 @@ def check():
print("Information: https://hacs.xyz/docs/publish/include#check-info")
info = get_info()
if not info:
print("No information provided.")
exit(1)
exit("::error::No information provided.")
if __name__ == "__main__":
check()
+9 -7
View File
@@ -1,5 +1,6 @@
from scripts.changed.category import get_category
from scripts.helpers.manifest import get_manifest
from scripts.helpers.integration_path import get_integration_path
def check():
@@ -8,23 +9,24 @@ def check():
print("Only integrations are checked.")
return
fail = "::error::Missing required value for key '{key}' in {path}"
integration = get_integration_path()
path = f"{integration.replace('/tmp/repositories/addition/', '')}/manifest.json"
manifest = get_manifest()
issues = []
if manifest.get("domain") is None or manifest.get("domain") == "":
issues.append("No domain")
issues.append(fail.format(key="domain", path=path))
if manifest.get("documentation") is None or manifest.get("documentation") == "":
issues.append("No documentation")
issues.append(fail.format(key="documentation", path=path))
if manifest.get("issue_tracker") is None or manifest.get("issue_tracker") == "":
issues.append("No issue_tracker")
issues.append(fail.format(key="issue_tracker", path=path))
if manifest.get("codeowners") is None:
issues.append("No codeowners")
if manifest.get("homeassistant"):
issues.append("homeassistant is not valid here")
issues.append(fail.format(key="codeowners", path=path))
if issues:
for issue in issues:
+6 -15
View File
@@ -1,30 +1,21 @@
import asyncio
import json
import os
from glob import glob
from aiogithubapi import GitHub
from scripts.changed.repo import get_repo
TOKEN = os.getenv("GITHUB_TOKEN")
ACTOR = os.getenv("GITHUB_ACTOR")
from scripts.helpers.event import get_event
async def check():
print("Information: https://hacs.xyz/docs/publish/include#check-owner")
repo = get_repo()
async with GitHub(TOKEN) as github:
repository = await github.get_repo(repo)
repo = repository.attributes
event = get_event()
actor = event["pull_request"]["user"]["login"]
return
# Currently broken. can not use ACTOR
if ACTOR == repo["full_name"].split("/")[0]:
print(f"{ACTOR} is the owner of the repository")
if repo.split("/")[0] == event["pull_request"]["user"]["login"]:
print(f"{actor} is the owner of the repository")
return
exit(78)
print(f"::warning::{actor} is the owner of the repository")
if __name__ == "__main__":
+3 -3
View File
@@ -18,15 +18,15 @@ async def check():
repo = repository.attributes
if not repo["has_issues"]:
issues.append("Issues not enabled.")
issues.append("::error::Issues not enabled.")
if not repo["description"]:
issues.append(
"No description. (https://hacs.xyz/docs/publish/start#description)"
"::error::No description. (https://hacs.xyz/docs/publish/start#description)"
)
if not repo["topics"]:
issues.append("No topics. (https://hacs.xyz/docs/publish/start#topics)")
issues.append("::error::No topics. (https://hacs.xyz/docs/publish/start#topics)")
if issues:
for issue in issues:
+1 -1
View File
@@ -38,7 +38,7 @@ async def check():
)
return
exit(
f"{domain} is not added to https://github.com/home-assistant/wheels-custom-integrations, "
f"::error::{domain} is not added to https://github.com/home-assistant/wheels-custom-integrations, "
+ "this is needed to ensure the best possible experience for the user"
)