Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check all repos in Homu's cfg.toml are valid #606

Merged
merged 1 commit into from May 3, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Repository validator for Homu's cfg.toml

This test will read the deployed cfg.toml file for Homu, and report if
any repositories configured there are not available on github.

This will help to prevent typos in repo names.
  • Loading branch information
rwaweber committed May 2, 2017
commit 0acc2817a57fda0026720ae8c2ee818f3f18948f
@@ -0,0 +1,36 @@
from urllib.error import URLError
from urllib.request import Request, urlopen

import toml

from tests.util import Failure, Success


def repo_exists(url):
'''
Checks if the given repo exists on GitHub
'''
try:
request = Request("https://github.com/{}".format(url), method='HEAD')
with urlopen(request) as conn:
return conn.status == 200
except URLError:
return False


def run():
repo_cfg = toml.load('/home/servo/homu/cfg.toml')['repo']
homu_repos = (
"{}/{}".format(repo['owner'], repo['name'])
for repo in repo_cfg.values()
)
missing_repos = [
repository for repository in homu_repos
if not repo_exists(repository)
]
if len(missing_repos) > 0:
return Failure(
'Some repos set up for Homu do not exist on GitHub:',
"\n".join(" - {}".format(repo) for repo in missing_repos)
)
return Success('All repos in the Homu config exist on Github')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.